🎥 Make videos programmatically with React
`@remotion/studio`: Fix subscription churn when trimming parent sequences
Jonny Burgerafb455d8d2ad
diff --git a/packages/browser-studio/e2e/app.tsx b/packages/browser-studio/e2e/app.tsxindex 8ea1cf27d1..158a62db2b 100644--- a/packages/browser-studio/e2e/app.tsx+++ b/packages/browser-studio/e2e/app.tsx@@ -45,6 +45,16 @@ ${`;}+ if (source === 'source-expressions') {+ project.files['/project/src/Composition.tsx'] = await (+ await fetch('/source-expressions.tsx')+ ).text();+ project.files['/project/src/Root.tsx'] =+ `import {Composition} from 'remotion';+import {SourceSubscriptionChurn} from './Composition';+export const RemotionRoot = () => <Composition id="SourceSubscriptionChurn" component={SourceSubscriptionChurn} durationInFrames={600} fps={30} width={1280} height={720} />;`;+ }+const root = document.getElementById('root');if (!root) {throw new Error('Could not find root element');diff --git a/packages/browser-studio/e2e/server.ts b/packages/browser-studio/e2e/server.tsindex b87b4444dd..cc2e250b46 100644--- a/packages/browser-studio/e2e/server.ts+++ b/packages/browser-studio/e2e/server.ts@@ -87,6 +87,18 @@ Bun.serve({});}+ if (url.pathname === '/source-expressions.tsx') {+ return new Response(+ Bun.file(+ path.join(+ workspacePackagesDir,+ 'example/src/SourceSubscriptionChurn.tsx',+ ),+ ),+ {headers},+ );+ }+if (url.pathname === '/frame.html') {return new Response(document('', null), {headers: {...headers, 'Content-Type': 'text/html'},diff --git a/packages/browser-studio/e2e/source-expressions.test.ts b/packages/browser-studio/e2e/source-expressions.test.tsnew file mode 100644index 0000000000..d5ace04ab0--- /dev/null+++ b/packages/browser-studio/e2e/source-expressions.test.ts@@ -0,0 +1,132 @@+import {expect, test} from '@playwright/test';+import type {BrowserStudioOperations} from '@remotion/studio-shared';++test.use({viewport: {width: 1920, height: 1200}});++test('evaluates shared source expressions while trimming without replacing Browser Studio subscriptions', async ({+ page,+}) => {+ const errors: string[] = [];+ page.on('pageerror', (error) => errors.push(error.message));+ await page.goto('/?source=source-expressions');+ const studio = page.frameLocator('iframe');+ await studio.locator('[data-compname="SourceSubscriptionChurn"]').click();+ const parent = studio.locator(+ '[data-timeline-marquee-item][aria-label="Trim this parent"]',+ );+ await expect(parent).toBeVisible();+ await page.keyboard.press('g');+ await studio.locator('input:focus').fill('30');+ await studio.locator('input:focus').press('Enter');+ await expect(+ studio.getByText('Expression A: 150 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ studio.getByText('Expression B: 200 frames', {exact: true}),+ ).toBeVisible();+ await parent.click();+ await page.waitForTimeout(500);+ // Observe the actual host protocol without replacing its implementation.+ await studio.locator('body').evaluate(() => {+ const win = window as typeof window & {+ remotion_browserStudio: BrowserStudioOperations;+ subscriptionOperations: number;+ };+ win.subscriptionOperations = 0;+ const subscribe = win.remotion_browserStudio.subscribeToSequenceProps;+ const unsubscribe = win.remotion_browserStudio.unsubscribeFromSequenceProps;+ win.remotion_browserStudio.subscribeToSequenceProps = (request) => {+ win.subscriptionOperations++;+ return subscribe(request);+ };++ win.remotion_browserStudio.unsubscribeFromSequenceProps = (request) => {+ win.subscriptionOperations++;+ return unsubscribe(request);+ };+ });+ const end = await parent+ .getByRole('separator', {name: 'Drag to change duration', exact: true})+ .boundingBox();+ const start = await parent+ .getByRole('separator', {name: 'Drag to trim start', exact: true})+ .boundingBox();+ if (!end || !start) throw new Error('Expected parent trim handles');+ const pixelsPerFrame = (end.x - start.x) / 300;+ const x = end.x + end.width / 2;+ const y = end.y + end.height / 2;+ await page.mouse.move(x, y);+ await page.mouse.down();+ for (const delta of [20, 40, 60]) {+ await page.mouse.move(x + pixelsPerFrame * delta, y, {steps: 3});+ await expect(+ studio.getByText(`Parent scope: ${300 + delta} frames`, {exact: true}),+ ).toBeVisible();+ await expect(+ studio.getByText(`Expression A: ${(300 + delta) / 2} frames`, {+ exact: true,+ }),+ ).toBeVisible();+ await expect(+ studio.getByText('Expression B: 200 frames', {exact: true}),+ ).toBeVisible();+ await expect+ .poll(() =>+ studio+ .getByTestId('Expression A')+ .evaluate((element) =>+ Number(getComputedStyle(element.parentElement!).opacity),+ ),+ )+ .toBeCloseTo(30 / (299 + delta), 5);+ expect(+ await studio+ .locator('body')+ .evaluate(+ () =>+ (window as typeof window & {subscriptionOperations: number})+ .subscriptionOperations,+ ),+ ).toBe(0);+ }++ await page.mouse.up();+ const source = () =>+ page.evaluate(+ () =>+ (+ window as typeof window & {+ __browserStudioProject: {files: Record<string, string>};+ }+ ).__browserStudioProject.files['/project/src/Composition.tsx'],+ );+ await expect+ .poll(source)+ .toMatch(/name="Trim this parent"\s+durationInFrames=\{360\}/);+ const expression = studio.locator(+ '[data-timeline-marquee-item][aria-label="Expression A"]',+ );+ await expression.click();+ const edge = await expression+ .getByRole('separator', {name: 'Drag to change duration', exact: true})+ .boundingBox();+ if (!edge) throw new Error('Expected expression trim handle');+ await page.mouse.move(edge.x + edge.width / 2, edge.y + edge.height / 2);+ await page.mouse.down();+ await page.mouse.move(+ edge.x + edge.width / 2 + pixelsPerFrame * 36,+ edge.y + edge.height / 2,+ {steps: 5},+ );+ await page.mouse.up();+ await expect.poll(source).toMatch(/durationInFrames=\{duration \* 0\.6\}/);+ await expect(+ studio.getByText('Expression A: 216 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ studio.getByText('Expression B: 240 frames', {exact: true}),+ ).toBeVisible();+ expect(errors.filter((error) => /maximum update depth/i.test(error))).toEqual(+ [],+ );+});diff --git a/packages/browser-studio/src/browser-studio-operations.ts b/packages/browser-studio/src/browser-studio-operations.tsindex d46b392fa5..8cfd707bd5 100644--- a/packages/browser-studio/src/browser-studio-operations.ts+++ b/packages/browser-studio/src/browser-studio-operations.ts@@ -279,7 +279,10 @@ const makeSequencePropsSubscriptionKey = ({JSON.stringify({clientId,fileName,- nodePath,+ nodePath: {+ absolutePath: nodePath.absolutePath,+ nodePath: nodePath.nodePath,+ },sequenceKeys,assetKeys,effectKeys,@@ -815,7 +818,6 @@ export const createBrowserStudioOperations = ({componentIdentity: null,keys: getAllSchemaKeys(mutation.schema),effectKeys: [],- videoConfig: mutation.nodePath.videoConfigValues ?? undefined,});const nodePath = {...mutation.nodePath,@@ -849,7 +851,6 @@ export const createBrowserStudioOperations = ({componentIdentity: null,keys: [],effectKeys: effects,- videoConfig: mutation.sequenceNodePath.videoConfigValues ?? undefined,});return (@@ -902,7 +903,6 @@ export const createBrowserStudioOperations = ({keys: request.keys,assetKeys: request.assetKeys,effects: request.effects,- videoConfigValues: request.videoConfigValues,});} catch {return {@@ -928,7 +928,6 @@ export const createBrowserStudioOperations = ({keys: request.keys,assetKeys: request.assetKeys,effectKeys: request.effects,- videoConfig: request.videoConfigValues ?? undefined,});const nextEffectChain = nextStatus.effects.map((effect) => (effect.canUpdate ? effect.callee : false))@@ -1012,7 +1011,6 @@ export const createBrowserStudioOperations = ({effectKeys: Array.from({length: effectIndex + 1}, (_, index) =>index === effectIndex ? getAllSchemaKeys(schema) : [],),- videoConfig: sequenceNodePath.videoConfigValues ?? undefined,});return (status.effects[effectIndex] ?? {diff --git a/packages/browser-studio/src/save-sequence-props.ts b/packages/browser-studio/src/save-sequence-props.tsindex 0d25fba845..86f54a34d8 100644--- a/packages/browser-studio/src/save-sequence-props.ts+++ b/packages/browser-studio/src/save-sequence-props.ts@@ -129,7 +129,6 @@ export const saveSequencePropsInProject = ({},componentIdentity: null,effectKeys: [],- videoConfig: target.nodePath.videoConfigValues ?? undefined,});return {diff --git a/packages/browser-studio/src/test/browser-studio-operations.test.ts b/packages/browser-studio/src/test/browser-studio-operations.test.tsindex fb57fc7eee..1b60212911 100644--- a/packages/browser-studio/src/test/browser-studio-operations.test.ts+++ b/packages/browser-studio/src/test/browser-studio-operations.test.ts@@ -279,12 +279,6 @@ export const Root = () => <Composition id="MyComp" component={Component} duratioassetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription to succeed');@@ -375,12 +369,6 @@ registerRoot(Root);`,assetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription to succeed');@@ -472,12 +460,6 @@ registerRoot(Root);`,assetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!currentSubscription.success) {throw new Error('Expected the updated Video node path');@@ -878,12 +860,6 @@ registerRoot(Root);`,assetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription to succeed');@@ -1034,12 +1010,6 @@ registerRoot(Root);`,assetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription to succeed');@@ -1128,12 +1098,6 @@ export const Comp = () => {assetKeys: [],effects: [['amount']],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription');@@ -1639,12 +1603,6 @@ registerRoot(Root);`,assetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription to succeed');@@ -1911,12 +1869,6 @@ export const Comp = () => (assetKeys: [],effects: [['amount'], ['amount']],clientId: 'browser-studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});if (!subscription.success) {throw new Error('Expected sequence props subscription');diff --git a/packages/codemods/src/get-node-props.ts b/packages/codemods/src/get-node-props.tsindex f34e017dde..319b7a8ef8 100644--- a/packages/codemods/src/get-node-props.ts+++ b/packages/codemods/src/get-node-props.ts@@ -1,7 +1,6 @@import type {CanUpdateSequencePropsResponseTrue,JsxComponentIdentity,- VideoConfigValues,} from 'remotion';import type {CodemodProject} from './codemod-project';import {findProjectFile} from './internals';@@ -20,7 +19,6 @@ export type GetNodePropsOptions = {effectKeys?: string[][];assetKeys?: string[];componentIdentity?: JsxComponentIdentity | null;- videoConfig?: VideoConfigValues;};export type NodeProps = Pick<@@ -35,7 +33,6 @@ export const getNodeProps = ({effectKeys,assetKeys,componentIdentity,- videoConfig,}: GetNodePropsOptions): NodeProps => {const filePath = findProjectFile({project, filePath: node.filePath});let effects = effectKeys;@@ -74,7 +71,6 @@ export const getNodeProps = ({assetKeys,keys,effects,- videoConfigValues: videoConfig ?? null,});return result;};diff --git a/packages/codemods/src/index.ts b/packages/codemods/src/index.tsindex 042c937af8..da71eff188 100644--- a/packages/codemods/src/index.ts+++ b/packages/codemods/src/index.ts@@ -22,6 +22,7 @@ import {getRootFileForProject,} from './internals';import {computeSequencePropsSubscriptionFromContent} from './sequence-props';+import {computeEffectPropsStatusesFromContent} from './sequence-props/can-update-effect-props';import {JsxElementIdentityMismatchError} from './sequence-props/jsx-component-identity';import {JsxElementNotFoundAtLocationError} from './sequence-props/jsx-element-not-found-at-location-error';import {getKeyframeInterpolationFunctionForCallee} from './sequence-props/keyframe-interpolation-function';@@ -170,6 +171,7 @@ export type {} from './update-sequence-props';export const CodemodsInternals = {+ computeEffectPropsStatusesFromContent,JsxElementIdentityMismatchError,JsxElementNotFoundAtLocationError,basicCaptionsElementSource,diff --git a/packages/codemods/src/sequence-props-snapshot.ts b/packages/codemods/src/sequence-props-snapshot.tsindex 87b928f39d..a280b2e592 100644--- a/packages/codemods/src/sequence-props-snapshot.ts+++ b/packages/codemods/src/sequence-props-snapshot.ts@@ -4,7 +4,7 @@ import type {VideoConfigIdentifierValues} from './sequence-props/video-config-vatype SourceSnapshot = {ast: File;- videoConfigIdentifierValues: Map<string, VideoConfigIdentifierValues>;+ videoConfigIdentifierValues: VideoConfigIdentifierValues | null;};// Public reads share immutable source snapshots, including across the awaits in@@ -16,7 +16,7 @@ const maximumSnapshots = 8;export const getReadOnlySourceSnapshot = (input: string): SourceSnapshot => {const snapshot = snapshots.get(input) ?? {ast: parseAst(input),- videoConfigIdentifierValues: new Map<string, VideoConfigIdentifierValues>(),+ videoConfigIdentifierValues: null,};// Refresh recency without retaining an unbounded number of edited versions.snapshots.delete(input);diff --git a/packages/codemods/src/sequence-props.ts b/packages/codemods/src/sequence-props.tsindex 79866f82d5..f9966c3167 100644--- a/packages/codemods/src/sequence-props.ts+++ b/packages/codemods/src/sequence-props.ts@@ -18,14 +18,14 @@ import {LINEAR_KEYFRAME_EASING} from '@remotion/studio-shared/keyframe-easing-primport * as recast from 'recast';import type {CanUpdateSequencePropsResponseTrue,- CanUpdateSequencePropStatus,+ CanUpdateSequencePropSource,+ SourceNumericValue,ExtrapolateType,InterpolateOutputOption,InterpolateOutputType,JsxComponentIdentity,SequenceNodePath,VideoConfigNumericExpression,- VideoConfigValues,} from 'remotion';import {NoReactInternals} from 'remotion/no-react';import {getReadOnlySourceSnapshot} from './sequence-props-snapshot';@@ -44,11 +44,11 @@ import {parseBorderRadiusShorthand} from './sequence-props/parse-border-radius-simport {parseKeyframeEasingExpression} from './sequence-props/parse-keyframe-easing-expression';import {parseVideoConfigNumericExpression} from './sequence-props/video-config-numeric-expression';import {- getVideoConfigIdentifierValues,+ getVideoConfigIdentifiers,type VideoConfigIdentifierValues,} from './sequence-props/video-config-values';-type CanUpdatePropStatus = CanUpdateSequencePropStatus;+type CanUpdatePropStatus = CanUpdateSequencePropSource;type KeyframedPropStatus = Extract<CanUpdatePropStatus, {status: 'keyframed'}>;type PropKeyframes = KeyframedPropStatus['keyframes'];type PropEasing = KeyframedPropStatus['easing'];@@ -598,6 +598,21 @@ const findNodePath = (return found;};+const combineSourceNumericValues = (+ operator: '+' | '-' | '*' | '/',+ left: SourceNumericValue,+ right: SourceNumericValue,+): SourceNumericValue => {+ const expression: VideoConfigNumericExpression = {+ type: 'binary',+ operator,+ left,+ right,+ };+ const value = NoReactInternals.evaluateSourceNumericValue(expression, null);+ return Number.isFinite(value) ? value : expression;+};+const getJsxNumericAttribute = ({openingElement,name,@@ -608,7 +623,7 @@ const getJsxNumericAttribute = ({name: string;defaultValue: number;videoConfigValues: VideoConfigIdentifierValues;-}): number | null => {+}): SourceNumericValue | null => {if (openingElement.attributes.some((attribute) => attribute.type === 'JSXSpreadAttribute',@@ -634,12 +649,11 @@ const getJsxNumericAttribute = ({return null;}- return (- parseVideoConfigNumericExpression({- node: attribute.value.expression,- videoConfigValues,- })?.value ?? null- );+ const expression = parseVideoConfigNumericExpression({+ node: attribute.value.expression,+ videoConfigValues,+ });+ return expression?.type === 'literal' ? expression.value : expression;}return defaultValue;@@ -690,7 +704,7 @@ const getJsxFrom = ({jsxPath: recast.types.NodePath;ast: File;videoConfigValues: VideoConfigIdentifierValues;-}): number | null => {+}): SourceNumericValue | null => {const element = jsxPath.value as JSXElement;if (getJsxComponentIdentity({ast, jsxElement: element.openingElement}) !==@@ -728,7 +742,7 @@ const getJsxFrom = ({// Series derives each start from the preceding siblings, including their// offsets and playback rates. Unknown children must keep the runtime value.const children = [...parent.children].reverse();- let start = 0;+ let start: SourceNumericValue = 0;while (children.length > 0) {const child = children.pop()!;if (child.type === 'JSXText' && child.value.trim() === '') {@@ -767,9 +781,9 @@ const getJsxFrom = ({return null;}- start += offset;+ start = combineSourceNumericValues('+', start, offset);if (child === element) {- return Number.isFinite(start) ? start : null;+ return typeof start !== 'number' || Number.isFinite(start) ? start : null;}const duration = getJsxNumericAttribute({@@ -786,16 +800,19 @@ const getJsxFrom = ({});if (duration === null ||- !Number.isFinite(duration) ||- duration <= 0 ||+ (typeof duration === 'number' &&+ (!Number.isFinite(duration) || duration <= 0)) ||rate === null ||- !Number.isFinite(rate) ||- rate <= 0+ (typeof rate === 'number' && (!Number.isFinite(rate) || rate <= 0))) {return null;}- start += duration / rate;+ start = combineSourceNumericValues(+ '+',+ start,+ combineSourceNumericValues('/', duration, rate),+ );}return null;@@ -812,15 +829,15 @@ const getFrameDisplayOffsetAdjustmentBetweenPaths = ({ast: File;videoConfigValues: VideoConfigIdentifierValues;}): {- readonly adjustment: number;- readonly playbackRateAdjustment: number;+ readonly adjustment: SourceNumericValue;+ readonly playbackRateAdjustment: SourceNumericValue;readonly hasEnclosingElement: boolean;} | null => {let current: recast.types.NodePath | null = startPath;let hasSeenControlledElement = false;let hasEnclosingElement = false;- let adjustment = 0;- let playbackRateAdjustment = 1;+ let adjustment: SourceNumericValue = 0;+ let playbackRateAdjustment: SourceNumericValue = 1;while (current && current.value !== endPath.value) {const currentNode = current.value as Node;if (@@ -866,16 +883,28 @@ const getFrameDisplayOffsetAdjustmentBetweenPaths = ({playbackRate === null ||loop === null ||loop ||- !Number.isFinite(playbackRate) ||- playbackRate <= 0+ (typeof playbackRate === 'number' &&+ (!Number.isFinite(playbackRate) || playbackRate <= 0))) {return null;}// Walk from the controlled element back to the hook's scope.// A sequence maps parent time to (parent - from) * rate + trimBefore.- adjustment = (adjustment + trimBefore) / playbackRate - from;- playbackRateAdjustment /= playbackRate;+ adjustment = combineSourceNumericValues(+ '-',+ combineSourceNumericValues(+ '/',+ combineSourceNumericValues('+', adjustment, trimBefore),+ playbackRate,+ ),+ from,+ );+ playbackRateAdjustment = combineSourceNumericValues(+ '/',+ playbackRateAdjustment,+ playbackRate,+ );}}@@ -896,8 +925,8 @@ const getDefaultFrameDisplayOffsetAdjustment = ({ast: File;videoConfigValues: VideoConfigIdentifierValues;}): {- adjustment: number;- playbackRateAdjustment: number;+ adjustment: SourceNumericValue;+ playbackRateAdjustment: SourceNumericValue;canKeyframe: boolean;} | null => {let functionPath: recast.types.NodePath | null = jsxPath.parentPath;@@ -1096,8 +1125,8 @@ const getCurrentFrameDisplayOffsetAdjustment = ({ast: File;videoConfigValues: VideoConfigIdentifierValues;}): {- readonly adjustment: number;- readonly playbackRateAdjustment: number;+ readonly adjustment: SourceNumericValue;+ readonly playbackRateAdjustment: SourceNumericValue;readonly hasEnclosingElement: boolean;} | null => {if (node.type === 'TSAsExpression') {@@ -1132,7 +1161,11 @@ const getCurrentFrameDisplayOffsetAdjustment = ({...frameDisplayOffset,// interpolate(frame + offset, [keyframe], ...) reaches the keyframe at// composition frame `keyframe - offset`.- adjustment: frameDisplayOffset.adjustment - resolved.offset,+ adjustment: combineSourceNumericValues(+ '-',+ frameDisplayOffset.adjustment,+ resolved.offset,+ ),};};@@ -1148,8 +1181,8 @@ const getInterpolationKeyframes = (posterize: PropPosterize;output: PropOutput;interpolationFunction: PropInterpolationFunction;- keyframeDisplayOffsetAdjustment: number | null;- keyframePlaybackRateAdjustment: number;+ keyframeDisplayOffsetAdjustment: SourceNumericValue | null;+ keyframePlaybackRateAdjustment: SourceNumericValue;}| undefined => {if (node.type === 'TSAsExpression') {@@ -1253,7 +1286,10 @@ const getInterpolationKeyframes = (}keyframes.push({- frame: frameExpression.value,+ frame:+ frameExpression.type === 'literal'+ ? frameExpression.value+ : frameExpression,value: extractStaticValue(outputElement),...(frameExpression.type === 'literal' ? {} : {frameExpression}),});@@ -1331,18 +1367,30 @@ export const retimeSequenceKeyframes = ({}const {openingElement} = jsxElement;- const previousPlaybackRate = getJsxNumericAttribute({+ const previousPlaybackRateExpression = getJsxNumericAttribute({openingElement,name: 'playbackRate',defaultValue: 1,videoConfigValues,});- const from = getJsxNumericAttribute({+ const fromExpression = getJsxNumericAttribute({openingElement,name: 'from',defaultValue: 0,videoConfigValues,});+ const previousPlaybackRate =+ previousPlaybackRateExpression === null+ ? null+ : NoReactInternals.evaluateSourceNumericValue(+ previousPlaybackRateExpression,+ null,+ );+ const from =+ fromExpression === null+ ? null+ : NoReactInternals.evaluateSourceNumericValue(fromExpression, null);+if (previousPlaybackRate === null ||!Number.isFinite(previousPlaybackRate) ||@@ -1399,8 +1447,12 @@ export const retimeSequenceKeyframes = ({}const anchor =- from * clock.playbackRateAdjustment -- clock.adjustment ++ from *+ NoReactInternals.evaluateSourceNumericValue(+ clock.playbackRateAdjustment,+ null,+ ) -+ NoReactInternals.evaluateSourceNumericValue(clock.adjustment, null) +resolved.offset;const inputRange = call.arguments[1];if (inputRange.type !== 'ArrayExpression') {@@ -1409,7 +1461,11 @@ export const retimeSequenceKeyframes = ({inputRange.elements = interpolation.keyframes.map<NumericLiteral>((keyframe) => {- const frame = anchor + (keyframe.frame - anchor) * ratio;+ const frame =+ anchor ++ (NoReactInternals.evaluateSourceNumericValue(keyframe.frame, null) -+ anchor) *+ ratio;const nearestInteger = Math.round(frame);const value =Math.abs(frame - nearestInteger) <=@@ -1479,7 +1535,12 @@ const getPropsStatus = (videoConfigValues,});props[name] = numericExpression- ? staticStatus(numericExpression.value, numericExpression)+ ? staticStatus(+ numericExpression.type === 'literal'+ ? numericExpression.value+ : undefined,+ numericExpression,+ ): getComputedStatus(expression, ast, videoConfigValues);continue;}@@ -1880,8 +1941,16 @@ const getBorderRadiusShorthandStatus = ({node: propValue,videoConfigValues,});- if (numericExpression !== null && numericExpression.value >= 0) {- return staticStatus(numericExpression.value, numericExpression);+ if (+ numericExpression !== null &&+ (numericExpression.type !== 'literal' || numericExpression.value >= 0)+ ) {+ return staticStatus(+ numericExpression.type === 'literal'+ ? numericExpression.value+ : undefined,+ numericExpression,+ );}const computed = getComputedStatus(propValue, ast, videoConfigValues);@@ -2038,7 +2107,12 @@ const getNestedPropStatus = ({videoConfigValues,});return numericExpression- ? staticStatus(numericExpression.value, numericExpression)+ ? staticStatus(+ numericExpression.type === 'literal'+ ? numericExpression.value+ : undefined,+ numericExpression,+ ): getComputedStatus(propValue, ast, videoConfigValues);}@@ -2251,8 +2325,8 @@ const computeSequencePropsStatusFromAstAndIdentifiers = ({videoConfigValues: videoConfigIdentifierValues,});const addDefaultKeyframeDisplayOffsetAdjustment = (- status: CanUpdateSequencePropStatus,- ): CanUpdateSequencePropStatus => {+ status: CanUpdateSequencePropSource,+ ): CanUpdateSequencePropSource => {if (status.status !== 'static') {return status;}@@ -2316,7 +2390,6 @@ export const computeSequencePropsStatusFromContent = ({keys,assetKeys = [],effects,- videoConfigValues,}: {fileContents: string;nodePath: SequenceNodePath;@@ -2324,32 +2397,12 @@ export const computeSequencePropsStatusFromContent = ({keys: string[];assetKeys?: string[];effects: string[][];- videoConfigValues: VideoConfigValues | null;}): CanUpdateSequencePropsResponseTrue => {const cachedAst = getReadOnlySourceSnapshot(fileContents);const {ast} = cachedAst;- const videoConfigCacheKey = JSON.stringify(videoConfigValues);- let videoConfigIdentifierValues =- cachedAst.videoConfigIdentifierValues.get(videoConfigCacheKey);- if (videoConfigIdentifierValues === undefined) {- videoConfigIdentifierValues = getVideoConfigIdentifierValues({- ast,- videoConfigValues,- });- }-- // A source snapshot may outlive many composition metadata changes. Bound- // derived values as well, retaining the configurations most recently read.- cachedAst.videoConfigIdentifierValues.delete(videoConfigCacheKey);- cachedAst.videoConfigIdentifierValues.set(- videoConfigCacheKey,- videoConfigIdentifierValues,- );- if (cachedAst.videoConfigIdentifierValues.size > 8) {- cachedAst.videoConfigIdentifierValues.delete(- cachedAst.videoConfigIdentifierValues.keys().next().value!,- );- }+ const videoConfigIdentifierValues =+ cachedAst.videoConfigIdentifierValues ?? getVideoConfigIdentifiers({ast});+ cachedAst.videoConfigIdentifierValues = videoConfigIdentifierValues;return computeSequencePropsStatusFromAstAndIdentifiers({ast,@@ -2371,7 +2424,6 @@ export const computeSequencePropsSubscriptionFromContent = ({keys,assetKeys = [],effects,- videoConfigValues,}: {fileContents: string;absolutePath: string;@@ -2381,7 +2433,6 @@ export const computeSequencePropsSubscriptionFromContent = ({keys: string[];assetKeys?: string[];effects: string[][];- videoConfigValues: VideoConfigValues;}): SubscribeToSequencePropsResponse => {if (preferredNodePath) {try {@@ -2394,14 +2445,13 @@ export const computeSequencePropsSubscriptionFromContent = ({keys,assetKeys,effects,- videoConfigValues,}),nodePath: {absolutePath,nodePath: preferredNodePath,sequenceKeys: keys,effectKeys: effects,- videoConfigValues,+ videoConfigValues: null,},};} catch (error) {@@ -2438,14 +2488,13 @@ export const computeSequencePropsSubscriptionFromContent = ({keys,assetKeys,effects,- videoConfigValues,}),nodePath: {absolutePath,nodePath: resolvedNodePath,sequenceKeys: keys,effectKeys: effects,- videoConfigValues,+ videoConfigValues: null,},};} catch {diff --git a/packages/codemods/src/sequence-props/can-update-effect-props.ts b/packages/codemods/src/sequence-props/can-update-effect-props.tsindex 48065da3bb..e6aa26db9e 100644--- a/packages/codemods/src/sequence-props/can-update-effect-props.ts+++ b/packages/codemods/src/sequence-props/can-update-effect-props.ts@@ -9,10 +9,9 @@ import type {} from '@babel/types';import type {CanUpdateEffectPropsResponse,- CanUpdateSequencePropStatus,+ CanUpdateSequencePropSource,SequenceNodePath,InteractivitySchema,- VideoConfigValues,} from 'remotion';import {extractStaticValue,@@ -27,11 +26,11 @@ import {import {parseAst} from './parse-ast';import {parseVideoConfigNumericExpression} from './video-config-numeric-expression';import {- getVideoConfigIdentifierValues,+ getVideoConfigIdentifiers,type VideoConfigIdentifierValues,} from './video-config-values';-const staticStatus = (codeValue: unknown): CanUpdateSequencePropStatus => ({+const staticStatus = (codeValue: unknown): CanUpdateSequencePropSource => ({status: 'static',keyframeDisplayOffsetAdjustment: null,codeValue,@@ -192,8 +191,8 @@ const getPropsFromObjectExpression = ({objExpr: ObjectExpression;keys: string[];videoConfigValues: VideoConfigIdentifierValues;-}): Record<string, CanUpdateSequencePropStatus> => {- const out: Record<string, CanUpdateSequencePropStatus> = {};+}): Record<string, CanUpdateSequencePropSource> => {+ const out: Record<string, CanUpdateSequencePropSource> = {};for (const key of keys) {const prop = objExpr.properties.find(@@ -219,7 +218,10 @@ const getPropsFromObjectExpression = ({? {status: 'static',keyframeDisplayOffsetAdjustment: null,- codeValue: numericExpression.value,+ codeValue:+ numericExpression.type === 'literal'+ ? numericExpression.value+ : undefined,...(numericExpression.type === 'literal'? {}: {numericExpression}),@@ -286,7 +288,7 @@ export const computeEffectPropStatus = ({fallbackCallee: target.callee,});if (call.arguments.length === 0) {- const emptyProps: Record<string, CanUpdateSequencePropStatus> = {};+ const emptyProps: Record<string, CanUpdateSequencePropSource> = {};for (const key of keys) {emptyProps[key] = staticStatus(undefined);}@@ -330,18 +332,15 @@ export const computeEffectPropsStatusesFromContent = ({sequenceNodePath,effects,keysFor,- videoConfigValues,}: {fileContents: string;sequenceNodePath: SequenceNodePath;effects: InteractivitySchema[];keysFor: (effect: InteractivitySchema) => string[];- videoConfigValues: VideoConfigValues | null;}): CanUpdateEffectPropsResponse[] => {const ast = parseAst(fileContents);- const videoConfigIdentifierValues = getVideoConfigIdentifierValues({+ const videoConfigIdentifierValues = getVideoConfigIdentifiers({ast,- videoConfigValues,});const jsx = findJsxElementAtNodePath(ast, sequenceNodePath);if (!jsx) {diff --git a/packages/codemods/src/sequence-props/video-config-numeric-expression.ts b/packages/codemods/src/sequence-props/video-config-numeric-expression.tsindex 8670a69db1..7a3fbc69c8 100644--- a/packages/codemods/src/sequence-props/video-config-numeric-expression.ts+++ b/packages/codemods/src/sequence-props/video-config-numeric-expression.ts@@ -1,7 +1,11 @@import type {Expression} from '@babel/types';import type {ExpressionKind} from 'ast-types/lib/gen/kinds';import * as recast from 'recast';-import type {VideoConfigNumericExpression} from 'remotion';+import type {+ VideoConfigNumericBinding,+ VideoConfigNumericExpression,+} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';import type {VideoConfigIdentifierValues} from './video-config-values';const b = recast.types.builders;@@ -34,7 +38,7 @@ const getVideoConfigValue = ({}: {node: Expression;videoConfigValues: VideoConfigIdentifierValues;-}): {identifier: string; value: number} | null => {+}): {identifier: string; binding: VideoConfigNumericBinding} | null => {if (node.type === 'TSAsExpression') {return getVideoConfigValue({node: node.expression as Expression,@@ -46,12 +50,12 @@ const getVideoConfigValue = ({return null;}- const value = videoConfigValues[node.name];- if (value === undefined || !Number.isFinite(value)) {+ const binding = videoConfigValues[node.name];+ if (binding === undefined) {return null;}- return {identifier: node.name, value};+ return {identifier: node.name, binding};};export const parseVideoConfigNumericExpression = ({@@ -94,17 +98,11 @@ export const parseVideoConfigNumericExpression = ({return null;}- const resolvedValue = minuend.value - subtrahend;- if (!Number.isFinite(resolvedValue)) {- return null;- }-return {type: 'video-config-subtraction',identifier: minuend.identifier,- minuend: minuend.value,+ binding: minuend.binding,subtrahend,- value: resolvedValue,};}@@ -136,18 +134,12 @@ export const parseVideoConfigNumericExpression = ({const multiplier = factorPosition === 'left' ? leftNumber! : rightNumber!;const configValue =factorPosition === 'left' ? rightVideoConfig! : leftVideoConfig!;- const value = multiplier * configValue.value;- if (!Number.isFinite(value)) {- return null;- }-return {type: 'video-config-multiplication',identifier: configValue.identifier,multiplier,- multiplicand: configValue.value,+ binding: configValue.binding,factorPosition,- value,};};@@ -171,16 +163,24 @@ export const updateVideoConfigNumericExpression = ({}if (expression.type === 'video-config-value') {- return value === expression.value+ return value ===+ NoReactInternals.evaluateSourceNumericValue(expression, null)? b.identifier(expression.identifier): numericExpression(value);}if (expression.type === 'video-config-subtraction') {- const subtrahend = expression.minuend - value;+ const subtrahend =+ (expression.binding.type === 'constant'+ ? expression.binding.value+ : NaN) - value;if (!Number.isFinite(subtrahend) ||- expression.minuend - subtrahend !== value+ (expression.binding.type === 'constant'+ ? expression.binding.value+ : NaN) -+ subtrahend !==+ value) {return numericExpression(value);}@@ -196,12 +196,18 @@ export const updateVideoConfigNumericExpression = ({return numericExpression(value);}- const multiplier = value / expression.multiplicand;+ const multiplier =+ value /+ (expression.binding.type === 'constant' ? expression.binding.value : NaN);// Preserve the expression only if evaluating it reproduces the requested value.if (!Number.isFinite(multiplier) ||multiplier === 0 ||- multiplier * expression.multiplicand !== value+ multiplier *+ (expression.binding.type === 'constant'+ ? expression.binding.value+ : NaN) !==+ value) {return numericExpression(value);}diff --git a/packages/codemods/src/sequence-props/video-config-values.ts b/packages/codemods/src/sequence-props/video-config-values.tsindex acce8cbbe2..797a225365 100644--- a/packages/codemods/src/sequence-props/video-config-values.ts+++ b/packages/codemods/src/sequence-props/video-config-values.ts@@ -1,19 +1,23 @@import type {File} from '@babel/types';import * as recast from 'recast';-import type {VideoConfigValues} from 'remotion';+import type {VideoConfigNumericBinding, VideoConfigValues} from 'remotion';-export type VideoConfigIdentifierValues = Record<string, number>;+export type VideoConfigIdentifierValues = Record<+ string,+ VideoConfigNumericBinding+>;-export const getVideoConfigIdentifierValues = ({+export const getVideoConfigIdentifiers = ({ast,- videoConfigValues,}: {ast: File;- videoConfigValues: VideoConfigValues | null;}): VideoConfigIdentifierValues => {- const candidates = new Map<string, number>();+ const candidates = new Map<string, VideoConfigNumericBinding>();const otherDeclarations = new Set<string>();- const addCandidate = (identifier: string, value: number) => {+ const addCandidate = (+ identifier: string,+ value: VideoConfigNumericBinding,+ ) => {if (candidates.has(identifier) || otherDeclarations.has(identifier)) {candidates.delete(identifier);otherDeclarations.add(identifier);@@ -27,7 +31,6 @@ export const getVideoConfigIdentifierValues = ({visitVariableDeclarator(path) {const {id, init} = path.node;const isVideoConfigDeclaration =- videoConfigValues !== null &&id.type === 'ObjectPattern' &&init?.type === 'CallExpression' &&init.callee.type === 'Identifier' &&@@ -50,14 +53,19 @@ export const getVideoConfigIdentifierValues = ({: property.key.type === 'StringLiteral'? property.key.value: null;- if (configKey === null || !(configKey in videoConfigValues)) {+ if (+ configKey !== 'durationInFrames' &&+ configKey !== 'fps' &&+ configKey !== 'width' &&+ configKey !== 'height'+ ) {continue;}- const value = videoConfigValues[configKey as keyof VideoConfigValues];- if (Number.isFinite(value)) {- addCandidate(property.value.name, value);- }+ addCandidate(property.value.name, {+ type: 'video-config',+ field: configKey,+ });}} else if (id.type === 'Identifier') {const declaration = path.parentPath.node;@@ -70,7 +78,7 @@ export const getVideoConfigIdentifierValues = ({: null;if (numericConstant !== null) {- addCandidate(id.name, numericConstant);+ addCandidate(id.name, {type: 'constant', value: numericConstant});} else {candidates.delete(id.name);otherDeclarations.add(id.name);@@ -87,3 +95,23 @@ export const getVideoConfigIdentifierValues = ({return Object.fromEntries(candidates);};++// Editing uses the current instance's configuration supplied with the mutation.+export const getVideoConfigIdentifierValues = ({+ ast,+ videoConfigValues,+}: {+ ast: File;+ videoConfigValues: VideoConfigValues | null;+}): VideoConfigIdentifierValues =>+ Object.fromEntries(+ Object.entries(getVideoConfigIdentifiers({ast})).flatMap(+ ([identifier, binding]) => {+ if (binding.type === 'constant') return [[identifier, binding]];+ const value = videoConfigValues?.[binding.field];+ return value === undefined || !Number.isFinite(value)+ ? []+ : [[identifier, {type: 'constant', value}]];+ },+ ),+ );diff --git a/packages/codemods/src/split-jsx-sequence.ts b/packages/codemods/src/split-jsx-sequence.tsindex e419518125..f2e6934b6c 100644--- a/packages/codemods/src/split-jsx-sequence.ts+++ b/packages/codemods/src/split-jsx-sequence.ts@@ -22,6 +22,7 @@ import type {VideoConfigNumericExpression,VideoConfigValues,} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';import {findJsxElementPathForDeletion,getJsxElementTagLabel,@@ -184,11 +185,16 @@ const readSequenceTiming = ({}if (name === 'playbackRate') {- if (!Number.isFinite(value.value) || value.value <= 0) {+ if (+ !Number.isFinite(+ NoReactInternals.evaluateSourceNumericValue(value, null),+ ) ||+ NoReactInternals.evaluateSourceNumericValue(value, null) <= 0+ ) {throw new Error('Cannot split sequence with invalid playbackRate');}- playbackRate = value.value;+ playbackRate = NoReactInternals.evaluateSourceNumericValue(value, null);}}@@ -470,8 +476,17 @@ export const splitJsxSequences = ({videoConfigValues,}),});- const from = timing.from?.value ?? 0;- const contentDuration = timing.durationInFrames?.value ?? Infinity;+ const from =+ timing.from === null+ ? 0+ : NoReactInternals.evaluateSourceNumericValue(timing.from, null);+ const contentDuration =+ timing.durationInFrames === null+ ? Infinity+ : NoReactInternals.evaluateSourceNumericValue(+ timing.durationInFrames,+ null,+ );const timelineDuration = contentDuration / timing.playbackRate;const finiteEnd =timelineDuration === Infinity ? Infinity : from + timelineDuration;@@ -509,7 +524,12 @@ export const splitJsxSequences = ({? Infinity: normalizeComputedTiming(contentDuration - leftDuration);const rightTrimBefore = normalizeComputedTiming(- (timing.trimBefore?.value ?? 0) + leftDuration,+ (timing.trimBefore === null+ ? 0+ : NoReactInternals.evaluateSourceNumericValue(+ timing.trimBefore,+ null,+ )) + leftDuration,);setNumericAttribute({diff --git a/packages/codemods/src/split-sequences.ts b/packages/codemods/src/split-sequences.tsindex 6384545b81..8b5aaa7dc4 100644--- a/packages/codemods/src/split-sequences.ts+++ b/packages/codemods/src/split-sequences.ts@@ -52,7 +52,6 @@ export const splitSequences = async <Project extends CodemodProject>({project,node: split.node,keys: ['from', 'durationInFrames', 'trimBefore'],- videoConfig: split.videoConfig,});if (Object.values(status.props).some((prop) => prop.status !== 'static')diff --git a/packages/codemods/src/test/sequence-props-spread.test.ts b/packages/codemods/src/test/sequence-props-spread.test.tsindex 3e163405d0..fe29406d3e 100644--- a/packages/codemods/src/test/sequence-props-spread.test.ts+++ b/packages/codemods/src/test/sequence-props-spread.test.ts@@ -1,13 +1,6 @@import {expect, test} from 'bun:test';import {computeSequencePropsSubscriptionFromContent} from '../sequence-props';-const videoConfigValues = {- durationInFrames: 120,- fps: 30,- height: 1080,- width: 1920,-};-const subscribe = (input: string, line: number, keys: string[]) => {const result = computeSequencePropsSubscriptionFromContent({fileContents: input,@@ -17,7 +10,6 @@ const subscribe = (input: string, line: number, keys: string[]) => {componentIdentity: 'dev.remotion.remotion.Sequence',keys,effects: [],- videoConfigValues,});if (!result.success || !result.status.canUpdate) {diff --git a/packages/codemods/src/update-keyframes.ts b/packages/codemods/src/update-keyframes.tsindex 505c48e6fd..09e72496fc 100644--- a/packages/codemods/src/update-keyframes.ts+++ b/packages/codemods/src/update-keyframes.ts@@ -37,6 +37,7 @@ import type {VideoConfigNumericExpression,VideoConfigValues,} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';import {ensureRemotionImports,ensureUseCurrentFrameHook,@@ -490,10 +491,13 @@ const getInterpolationExpression = (}keyframes.push({- frame: frameExpression.value,+ frame: NoReactInternals.evaluateSourceNumericValue(frameExpression, null),frameExpression: inputElement as ExpressionKind,frameNumericExpression: frameExpression,- originalFrame: frameExpression.value,+ originalFrame: NoReactInternals.evaluateSourceNumericValue(+ frameExpression,+ null,+ ),output: outputElement as ExpressionKind,value: extractStaticValue(outputElement),});@@ -1400,7 +1404,12 @@ const addKeyframe = ({}const staticValue =- staticNumericExpression?.value ?? extractStaticValue(expression);+ staticNumericExpression === null+ ? extractStaticValue(expression)+ : NoReactInternals.evaluateSourceNumericValue(+ staticNumericExpression,+ null,+ );const keyframes: InterpolateKeyframe[] = [{frame,diff --git a/packages/codemods/src/update-node-props.ts b/packages/codemods/src/update-node-props.tsindex 6d28e75af7..6534acb59d 100644--- a/packages/codemods/src/update-node-props.ts+++ b/packages/codemods/src/update-node-props.ts@@ -82,7 +82,6 @@ export const updateMultipleNodeProps = <Project extends CodemodProject>({project,node: change.node,keys,- videoConfig: change.videoConfig,});for (const key of keys) {if (diff --git a/packages/codemods/src/update-sequence-props.ts b/packages/codemods/src/update-sequence-props.tsindex c4dc253626..99b89b44c7 100644--- a/packages/codemods/src/update-sequence-props.ts+++ b/packages/codemods/src/update-sequence-props.ts@@ -1061,7 +1061,8 @@ const updateSequencePropsNode = ({return parseValueExpression(value);}- return expression.value === value+ return NoReactInternals.evaluateSourceNumericValue(expression, null) ===+ value? (existing as ExpressionKind): updateVideoConfigNumericExpression({expression, value});};diff --git a/packages/core/src/HtmlInCanvas.tsx b/packages/core/src/HtmlInCanvas.tsxindex 55de76973f..c007716828 100644--- a/packages/core/src/HtmlInCanvas.tsx+++ b/packages/core/src/HtmlInCanvas.tsx@@ -537,6 +537,7 @@ const HtmlInCanvasContent = forwardRef<const memoizedEffects = useMemoizedEffects({effects,overrideId: controls?.overrideId ?? null,+ videoConfigValues: controls?.videoConfigValues ?? null,});// Refs so the paint handler always reads fresh values.diff --git a/packages/core/src/SequenceManager.tsx b/packages/core/src/SequenceManager.tsxindex c266ff014a..87a90b802e 100644--- a/packages/core/src/SequenceManager.tsx+++ b/packages/core/src/SequenceManager.tsx@@ -15,6 +15,7 @@ import type {GetEffectDragOverrides,PropStatuses,} from './use-schema.js';+import type {SourceNumericValue} from './use-schema.js';import {useSyncExternalStore} from './use-sync-external-store.js';import type {VideoConfigValues} from './video-config.js';@@ -231,12 +232,12 @@ export type VisualModeBatchSetters = {) => void;};-export type CanUpdateEffectPropsResponseTrue = {+export type CanUpdateEffectPropsResponseTrue<Numeric = SourceNumericValue> = {canUpdate: true;callee: string;importPath: string | null;effectIndex: number;- props: Record<string, CanUpdateSequencePropStatus>;+ props: Record<string, CanUpdateSequencePropStatus<Numeric>>;};export type CannotUpdateEffectReason =@@ -252,14 +253,14 @@ export type CanUpdateEffectPropsResponseFalse = {reason: CannotUpdateEffectReason;};-export type CanUpdateEffectPropsResponse =- | CanUpdateEffectPropsResponseTrue+export type CanUpdateEffectPropsResponse<Numeric = SourceNumericValue> =+ | CanUpdateEffectPropsResponseTrue<Numeric>| CanUpdateEffectPropsResponseFalse;-export type CanUpdateSequencePropsResponseTrue = {+export type CanUpdateSequencePropsResponseTrue<Numeric = SourceNumericValue> = {canUpdate: true;- props: Record<string, CanUpdateSequencePropStatus>;- effects: CanUpdateEffectPropsResponse[];+ props: Record<string, CanUpdateSequencePropStatus<Numeric>>;+ effects: CanUpdateEffectPropsResponse<Numeric>[];};export type CanUpdateSequencePropsResponseFalse = {@@ -267,8 +268,8 @@ export type CanUpdateSequencePropsResponseFalse = {reason: CannotUpdateSequenceReason;};-export type CanUpdateSequencePropsResponse =- | CanUpdateSequencePropsResponseTrue+export type CanUpdateSequencePropsResponse<Numeric = SourceNumericValue> =+ | CanUpdateSequencePropsResponseTrue<Numeric>| CanUpdateSequencePropsResponseFalse;export const makeSequencePropsSubscriptionKey = (@@ -406,6 +407,7 @@ export type SequencePropsSubscriptionKey = {nodePath: SequenceNodePath;sequenceKeys: string[];effectKeys: string[][];+ /** Evaluation context of a rendered instance. Never part of source identity. */videoConfigValues: VideoConfigValues | null;};diff --git a/packages/core/src/animated-image/AnimatedImage.tsx b/packages/core/src/animated-image/AnimatedImage.tsxindex e4695895d8..f492984622 100644--- a/packages/core/src/animated-image/AnimatedImage.tsx+++ b/packages/core/src/animated-image/AnimatedImage.tsx@@ -133,6 +133,7 @@ const AnimatedImageContent = forwardRef<const memoizedEffects = useMemoizedEffects({effects,overrideId: controls?.overrideId ?? null,+ videoConfigValues: controls?.videoConfigValues ?? null,});useImperativeHandle(canvasRef, () => {diff --git a/packages/core/src/canvas-image/CanvasImage.tsx b/packages/core/src/canvas-image/CanvasImage.tsxindex b6b5c7fedd..283fb010da 100644--- a/packages/core/src/canvas-image/CanvasImage.tsx+++ b/packages/core/src/canvas-image/CanvasImage.tsx@@ -241,6 +241,7 @@ const CanvasImageContent = forwardRef<const memoizedEffects = useMemoizedEffects({effects,overrideId: controls?.overrideId ?? null,+ videoConfigValues: controls?.videoConfigValues ?? null,});const sequenceContext = useContext(SequenceContext);const pendingLoadDelayRef = useRef<PendingLoadDelay | null>(null);diff --git a/packages/core/src/effects/Solid.tsx b/packages/core/src/effects/Solid.tsxindex 6cfe332080..ecbf41a5d1 100644--- a/packages/core/src/effects/Solid.tsx+++ b/packages/core/src/effects/Solid.tsx@@ -30,6 +30,7 @@ import {Sequence} from '../Sequence.js';import {useCropStyle} from '../use-crop-style.js';import {useDelayRender} from '../use-delay-render.js';import {usePremounting} from '../use-premounting.js';+import type {VideoConfigValues} from '../video-config.js';import {withInteractivitySchema} from '../with-interactivity-schema.js';import type {EffectsProp} from './effect-types.js';import {runEffectChain} from './run-effect-chain.js';@@ -122,6 +123,7 @@ const SolidInner: React.FC<InnerSolidProps & {readonly overrideId: string | null;readonly reference: React.Ref<HTMLCanvasElement>;+ readonly videoConfigValues: VideoConfigValues | null;}> = ({color,@@ -132,6 +134,7 @@ const SolidInner: React.FC<style,pixelDensity,overrideId,+ videoConfigValues,reference,}) => {const {delayRender, continueRender, cancelRender} = useDelayRender();@@ -147,6 +150,7 @@ const SolidInner: React.FC<const memoizedEffects = useMemoizedEffects({effects,overrideId: overrideId ?? null,+ videoConfigValues,});const sourceCanvas = useMemo(() => {@@ -361,6 +365,7 @@ const SolidOuter = forwardRef<><SolidInnerreference={actualRef}+ videoConfigValues={controls?.videoConfigValues ?? null}overrideId={controls?.overrideId ?? null}color={color}height={height}diff --git a/packages/core/src/effects/use-memoized-effects.ts b/packages/core/src/effects/use-memoized-effects.tsindex 709d12fd42..89055e1c21 100644--- a/packages/core/src/effects/use-memoized-effects.ts+++ b/packages/core/src/effects/use-memoized-effects.ts@@ -1,4 +1,5 @@import {useContext, useLayoutEffect, useRef} from 'react';+import {evaluateSourcePropStatuses} from '../evaluate-source-expressions.js';import {getFrameInKeyframedStatusClock,resolveDragOverrideValue,@@ -23,6 +24,7 @@ import {type DragOverrideValue,type PropStatuses,} from '../use-schema.js';+import type {VideoConfigValues} from '../video-config.js';import type {EffectDefinitionAndStack,EffectDescriptor,@@ -191,7 +193,10 @@ export const getEffectPropStatusesCtx = ({return {type: 'cannot-update-effect', reason: effect.reason};}- return {type: 'can-update-effect', props: effect.props};+ return {+ type: 'can-update-effect',+ props: evaluateSourcePropStatuses(effect.props, nodePath.videoConfigValues),+ };};export const getPropStatusesCtx = (@@ -207,7 +212,7 @@ export const getPropStatusesCtx = (return undefined;}- return status.props;+ return evaluateSourcePropStatuses(status.props, nodePath.videoConfigValues);};export type GetPropStatusesType = typeof getPropStatusesCtx;@@ -215,9 +220,11 @@ export type GetPropStatusesType = typeof getPropStatusesCtx;export const useMemoizedEffects = ({effects,overrideId,+ videoConfigValues,}: {effects: readonly EffectDescriptor<unknown>[];readonly overrideId: string | null;+ videoConfigValues: VideoConfigValues | null;}): EffectDefinitionAndStack<unknown>[] => {const previousRef = useRef<EffectDefinitionAndStack<unknown>[] | null>(null);@@ -249,7 +256,7 @@ export const useMemoizedEffects = ({const effectStatus = getEffectPropStatusesCtx({propStatuses,- nodePath,+ nodePath: {...nodePath, videoConfigValues},effectIndex: index,});const propStatusOverrides =diff --git a/packages/core/src/evaluate-source-expressions.ts b/packages/core/src/evaluate-source-expressions.tsnew file mode 100644index 0000000000..7ffec6f339--- /dev/null+++ b/packages/core/src/evaluate-source-expressions.ts@@ -0,0 +1,137 @@+import type {+ CanUpdateSequencePropSource,+ CanUpdateSequencePropStatus,+ SourceNumericValue,+} from './use-schema.js';+import type {VideoConfigValues} from './video-config.js';++export const evaluateSourceNumericValue = (+ expression: SourceNumericValue,+ config: VideoConfigValues | null,+): number => {+ if (typeof expression === 'number') {+ return expression;+ }++ if (expression.type === 'literal') {+ return expression.value;+ }++ if (expression.type === 'binary') {+ const left = evaluateSourceNumericValue(expression.left, config);+ const right = evaluateSourceNumericValue(expression.right, config);+ switch (expression.operator) {+ case '+':+ return left + right;+ case '-':+ return left - right;+ case '*':+ return left * right;+ case '/':+ return left / right;+ default:+ throw new Error('Unknown source expression operator');+ }+ }++ const value =+ expression.binding.type === 'constant'+ ? expression.binding.value+ : (config?.[expression.binding.field] ?? NaN);+ if (expression.type === 'video-config-multiplication') {+ return value * expression.multiplier;+ }++ if (expression.type === 'video-config-subtraction') {+ return value - expression.subtrahend;+ }++ return value;+};++const evaluatedProps = new WeakMap<+ Record<string, CanUpdateSequencePropSource>,+ Map<string, Record<string, CanUpdateSequencePropStatus>>+>();++/** Resolve at the consumer, never in the shared source subscription cache. */+export const evaluateSourcePropStatuses = (+ props: Record<string, CanUpdateSequencePropSource>,+ config: VideoConfigValues | null,+): Record<string, CanUpdateSequencePropStatus> => {+ const configKey =+ config === null+ ? ''+ : `${config.durationInFrames}:${config.fps}:${config.width}:${config.height}`;+ const cached =+ evaluatedProps.get(props) ??+ new Map<string, Record<string, CanUpdateSequencePropStatus>>();+ const existing = cached.get(configKey);+ if (existing) return existing;+ const result: Record<string, CanUpdateSequencePropStatus> =+ Object.fromEntries(+ Object.entries(props).map(([key, status]) => {+ if (status.status === 'computed') {+ return [key, status];+ }++ const adjustment =+ status.keyframeDisplayOffsetAdjustment === null+ ? null+ : evaluateSourceNumericValue(+ status.keyframeDisplayOffsetAdjustment,+ config,+ );+ const rate = evaluateSourceNumericValue(+ status.keyframePlaybackRateAdjustment ?? 1,+ config,+ );+ if (+ (adjustment !== null && !Number.isFinite(adjustment)) ||+ !Number.isFinite(rate) ||+ rate <= 0+ ) {+ return [key, {status: 'computed'}];+ }++ const timing = {+ keyframeDisplayOffsetAdjustment: adjustment,+ ...(status.keyframePlaybackRateAdjustment === undefined+ ? {}+ : {keyframePlaybackRateAdjustment: rate}),+ };+ if (status.status === 'static') {+ const value =+ status.numericExpression === undefined+ ? status.codeValue+ : evaluateSourceNumericValue(status.numericExpression, config);+ return [+ key,+ status.numericExpression !== undefined && !Number.isFinite(value)+ ? {status: 'computed'}+ : {...status, ...timing, codeValue: value},+ ];+ }++ const keyframes = status.keyframes.map((keyframe) => ({+ ...keyframe,+ frame: evaluateSourceNumericValue(keyframe.frame, config),+ }));+ if (+ keyframes.some(+ (keyframe, index) =>+ !Number.isFinite(keyframe.frame) ||+ (index > 0 && keyframe.frame <= keyframes[index - 1].frame),+ )+ ) {+ return [key, {status: 'computed'}];+ }++ return [key, {...status, ...timing, keyframes}];+ }),+ );+ cached.set(configKey, result);+ if (cached.size > 8) cached.delete(cached.keys().next().value!);+ evaluatedProps.set(props, cached);+ return result;+};diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex 882ae54acb..54399be367 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -75,6 +75,10 @@ import {setComponentIdentityResolver,type OriginalSourceLocation,} from './enable-sequence-stack-traces.js';+import {+ evaluateSourceNumericValue,+ evaluateSourcePropStatuses,+} from './evaluate-source-expressions.js';import {findPropsToDelete} from './find-props-to-delete.js';import {flattenActiveSchema,@@ -324,6 +328,8 @@ const compositionSelectorRef = createRef<{// Mark them as Internals so use don't assume this is public// API and are less likely to use itexport const Internals = {+ evaluateSourceNumericValue,+ evaluateSourcePropStatuses,AbsoluteFillElement,MaxMediaCacheSizeContext,getMediabunnyInputResourceKey,@@ -579,3 +585,9 @@ export type {VisibleFieldSchema,WatchRemotionStaticFilesPayload,};++export type {+ CanUpdateSequencePropSource,+ SourceNumericValue,+ VideoConfigNumericBinding,+} from './use-schema.js';diff --git a/packages/core/src/no-react.ts b/packages/core/src/no-react.tsindex a0e96a18c1..8ce7e1b79e 100644--- a/packages/core/src/no-react.ts+++ b/packages/core/src/no-react.ts@@ -1,3 +1,7 @@+import {+ evaluateSourceNumericValue,+ evaluateSourcePropStatuses,+} from './evaluate-source-expressions.js';export type {ArtifactAsset,AudioOrVideoAsset,@@ -54,6 +58,8 @@ import {getExpectedMediaFrameUncorrected} from './video/get-current-time';import {getOffthreadVideoSource} from './video/offthread-video-source';export const NoReactInternals = {+ evaluateSourceNumericValue,+ evaluateSourcePropStatuses,processColor,truthy,validateFps,diff --git a/packages/core/src/use-schema.ts b/packages/core/src/use-schema.tsindex 572b3c4bfe..7c2f957d53 100644--- a/packages/core/src/use-schema.ts+++ b/packages/core/src/use-schema.ts@@ -18,50 +18,61 @@ import type {CanUpdateSequencePropsResponse,SequencePropsSubscriptionKey,} from './SequenceManager.js';+import type {VideoConfigValues} from './video-config.js';-export type CanUpdateSequencePropStatusStatic = {+export type CanUpdateSequencePropStatusStatic<Numeric = number> = {status: 'static';codeValue: unknown;- keyframeDisplayOffsetAdjustment: number | null;+ keyframeDisplayOffsetAdjustment: Numeric | null;/** Multiplies the element's local frame to recover the source frame clock. */- keyframePlaybackRateAdjustment?: number;+ keyframePlaybackRateAdjustment?: Numeric;/** False when the source frame clock cannot be represented by the Studio. */canKeyframe?: false;numericExpression?: VideoConfigNumericExpression;};-export type CanUpdateSequencePropStatusKeyframe = {- frame: number;+export type CanUpdateSequencePropStatusKeyframe<Numeric = number> = {+ frame: Numeric;value: unknown;frameExpression?: VideoConfigNumericExpression;};+/** Source bindings remain independent of the configuration of a mounted instance. */+export type VideoConfigNumericBinding =+ | {type: 'video-config'; field: keyof VideoConfigValues}+ | {type: 'constant'; value: number};+export type VideoConfigNumericExpression =- | {- type: 'literal';- value: number;- }+ | {type: 'literal'; value: number}| {type: 'video-config-value';identifier: string;- value: number;+ binding: VideoConfigNumericBinding;}| {type: 'video-config-multiplication';identifier: string;+ binding: VideoConfigNumericBinding;multiplier: number;- multiplicand: number;factorPosition: 'left' | 'right';- value: number;}| {type: 'video-config-subtraction';identifier: string;- minuend: number;+ binding: VideoConfigNumericBinding;subtrahend: number;- value: number;+ }+ | {+ type: 'binary';+ operator: '+' | '-' | '*' | '/';+ left: SourceNumericValue;+ right: SourceNumericValue;};+export type SourceNumericValue = number | VideoConfigNumericExpression;+export type CanUpdateSequencePropSource =+ CanUpdateSequencePropStatus<SourceNumericValue>;+export type CanUpdateSequencePropStatusLinearEasing = {type: 'linear';};@@ -131,7 +142,7 @@ export type CanUpdateSequencePropStatusComputed = {status: 'computed';};-export type CanUpdateSequencePropStatusKeyframed = {+export type CanUpdateSequencePropStatusKeyframed<Numeric = number> = {status: 'keyframed';interpolationFunction: CanUpdateSequencePropStatusInterpolationFunction;/**@@ -140,10 +151,10 @@ export type CanUpdateSequencePropStatusKeyframed = {* This is non-zero when the useCurrentFrame() call is outside a timing* element that wraps the controlled element.*/- keyframeDisplayOffsetAdjustment: number | null;+ keyframeDisplayOffsetAdjustment: Numeric | null;/** Defaults to 1 for statuses produced without a playback rate conversion. */- keyframePlaybackRateAdjustment?: number;- keyframes: CanUpdateSequencePropStatusKeyframe[];+ keyframePlaybackRateAdjustment?: Numeric;+ keyframes: CanUpdateSequencePropStatusKeyframe<Numeric>[];easing: CanUpdateSequencePropStatusEasing[];clamping: CanUpdateSequencePropStatusClamping;posterize: number | undefined;@@ -153,9 +164,9 @@ export type CanUpdateSequencePropStatusKeyframed = {export type CanUpdateSequencePropStatusFalse =CanUpdateSequencePropStatusComputed;-export type CanUpdateSequencePropStatus =- | CanUpdateSequencePropStatusStatic- | CanUpdateSequencePropStatusKeyframed+export type CanUpdateSequencePropStatus<Numeric = number> =+ | CanUpdateSequencePropStatusStatic<Numeric>+ | CanUpdateSequencePropStatusKeyframed<Numeric>| CanUpdateSequencePropStatusFalse;export type DragOverrideValue =diff --git a/packages/core/src/with-interactivity-schema.ts b/packages/core/src/with-interactivity-schema.tsindex 902c43b477..03aa599aa4 100644--- a/packages/core/src/with-interactivity-schema.ts+++ b/packages/core/src/with-interactivity-schema.ts@@ -370,7 +370,10 @@ export const withInteractivitySchema = <propStatus:nodePath === null? undefined- : getPropStatusesCtx(propStatuses, nodePath),+ : getPropStatusesCtx(propStatuses, {+ ...nodePath,+ videoConfigValues,+ }),frame,});}, [@@ -378,6 +381,7 @@ export const withInteractivitySchema = <dragOverrides,nodePath,propStatuses,+ videoConfigValues,frame,]);diff --git a/packages/example/e2e/node-path-cache.test.mts b/packages/example/e2e/node-path-cache.test.mtsindex 5627d11ea1..91a4a2dae8 100644--- a/packages/example/e2e/node-path-cache.test.mts+++ b/packages/example/e2e/node-path-cache.test.mts@@ -66,12 +66,6 @@ test.describe('node-path cache for stale source maps', () => {const videoLineIndex = lines.findIndex((l) => l.includes('<Video'));expect(videoLineIndex).toBeGreaterThan(-1);const videoLine = videoLineIndex + 1; // 1-indexed- const videoConfigValues = {- durationInFrames: 100,- fps: 30,- height: 1080,- width: 1920,- };// 1. Initial subscription → resolves line to AST nodePath and caches itconst result1 = await subscribeToSequenceProps({@@ -84,7 +78,6 @@ test.describe('node-path cache for stale source maps', () => {assetKeys: [],keys: getAllSchemaKeys(NoReactInternals.sequenceSchema),clientId: 'e2e-cache-test-1',- videoConfigValues,});expect(result1.success).toBe(true);assert(result1.success);@@ -121,7 +114,6 @@ test.describe('node-path cache for stale source maps', () => {assetKeys: [],effects: [],clientId: 'e2e-cache-test-2',- videoConfigValues,});expect(result2.success).toBe(true);assert(result2.success);@@ -152,7 +144,6 @@ test.describe('node-path cache for stale source maps', () => {assetKeys: [],effects: [],clientId: 'e2e-identity-mismatch-1',- videoConfigValues,});expect(identityResult.success).toBe(true);assert(identityResult.success);@@ -190,7 +181,6 @@ test.describe('node-path cache for stale source maps', () => {assetKeys: [],effects: [],clientId: 'e2e-identity-mismatch-2',- videoConfigValues,});expect(reconnectResult.success).toBe(true);assert(reconnectResult.success);diff --git a/packages/example/e2e/source-subscription-churn.test.mts b/packages/example/e2e/source-subscription-churn.test.mtsnew file mode 100644index 0000000000..77fb46622f--- /dev/null+++ b/packages/example/e2e/source-subscription-churn.test.mts@@ -0,0 +1,244 @@+import fs from 'node:fs';+import path from 'node:path';+import {expect, test} from '@playwright/test';+import type {SubscribeToSequencePropsBatchRequest} from '@remotion/studio-shared';+import {EXPANDED_SIDEBAR_STATE, STUDIO_URL, exampleDir} from './constants.mts';+import {startStudio, stopStudio} from './studio-server.mts';++test.use({+ storageState: EXPANDED_SIDEBAR_STATE,+ viewport: {width: 1920, height: 1200},+});++test('parent trim keeps source subscriptions stable and evaluates each mounted instance', async ({+ page,+}) => {+ test.setTimeout(120_000);+ const fixture = path.join(exampleDir, 'src', 'SourceSubscriptionChurn.tsx');+ const original = fs.readFileSync(fixture, 'utf8');+ const subscriptions: string[] = [];+ const errors: string[] = [];+ page.on('request', (request) => {+ if (/\/api\/(un)?subscribe-to-sequence-props$/.test(request.url()))+ subscriptions.push(request.postData() ?? '');+ });+ page.on('pageerror', (error) => errors.push(error.message));+ page.on('console', (message) => {+ if (message.type() === 'error') errors.push(message.text());+ });+ await startStudio();+ try {+ await page.goto(`${STUDIO_URL}/SourceSubscriptionChurn`);+ const parent = page.locator(+ '[data-timeline-marquee-item][aria-label="Trim this parent"]',+ );+ await expect(parent).toBeVisible({timeout: 30_000});+ await page.keyboard.press('g');+ await page.locator('input:focus').fill('30');+ await page.locator('input:focus').press('Enter');+ await expect(+ page.getByText('Parent scope: 300 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ page.getByText('Expression A: 150 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ page.getByText('Expression B: 200 frames', {exact: true}),+ ).toBeVisible();+ const expression = page.locator(+ '[data-timeline-marquee-item][aria-label="Expression A"]',+ );+ await expression.click();+ const opacity = page+ .getByRole('group', {name: 'Opacity', exact: true})+ .first();+ await expect(opacity).toBeVisible();+ await opacity.click();+ await expect(+ page+ .getByRole('button', {+ name: 'Select keyframe at frame 299',+ exact: true,+ })+ .last(),+ ).toBeVisible();+ await parent.click();+ const end = parent+ .getByRole('separator', {name: 'Drag to change duration', exact: true})+ .filter({visible: true})+ .first();+ const start = parent+ .getByRole('separator', {name: 'Drag to trim start', exact: true})+ .filter({visible: true})+ .first();+ await expect(end).toBeVisible();+ const endBox = await end.boundingBox();+ const startBox = await start.boundingBox();+ if (!endBox || !startBox) throw new Error('Expected parent trim handles');+ const pixelsPerFrame = (endBox.x - startBox.x) / 300;+ const x = endBox.x + endBox.width / 2;+ const y = endBox.y + endBox.height / 2;+ // The initial batched source subscriptions must finish before measuring preview traffic.+ await page.waitForTimeout(500);+ const subscribedLines = subscriptions+ .flatMap(+ (body) =>+ (JSON.parse(body) as SubscribeToSequencePropsBatchRequest).requests,+ )+ .filter((request) =>+ request.fileName.endsWith('SourceSubscriptionChurn.tsx'),+ )+ .map((request) => request.line);+ const literalChildLines = [+ ...original.matchAll(/<Sequence name="(?:Nested child|Root control) /g),+ ].map((match) => original.slice(0, match.index).split('\n').length);+ expect(literalChildLines).toHaveLength(10);+ expect(subscribedLines).toEqual(expect.arrayContaining(literalChildLines));+ const initialSubscriptions = subscriptions.length;+ await page.mouse.move(x, y);+ await page.mouse.down();+ for (const delta of [20, 40, 60]) {+ await page.mouse.move(x + pixelsPerFrame * delta, y, {steps: 3});+ await expect(+ page.getByText(`Parent scope: ${300 + delta} frames`, {exact: true}),+ ).toBeVisible();+ for (let i = 1; i <= 8; i++) {+ await expect(+ page.getByText(`Child ${String(i).padStart(2, '0')}: 180 frames`, {+ exact: true,+ }),+ ).toBeVisible();+ }+ for (const label of ['Root control 01', 'Root control 02']) {+ await expect(+ page.getByText(`${label}: 180 frames`, {exact: true}),+ ).toBeVisible();+ }+ await expect(+ page.getByText(`Expression A: ${(300 + delta) / 2} frames`, {+ exact: true,+ }),+ ).toBeVisible();+ await expect(+ page.getByText('Expression B: 200 frames', {exact: true}),+ ).toBeVisible();+ await expect+ .poll(() =>+ page+ .getByTestId('Expression A')+ .evaluate((element) =>+ Number(getComputedStyle(element.parentElement!).opacity),+ ),+ )+ .toBeCloseTo(30 / (299 + delta), 5);+ await expect+ .poll(() =>+ page+ .getByTestId('Expression B')+ .evaluate((element) =>+ Number(getComputedStyle(element.parentElement!).opacity),+ ),+ )+ .toBeCloseTo(30 / 399, 5);+ await expect(+ page+ .getByRole('button', {+ name: `Select keyframe at frame ${299 + delta}`,+ exact: true,+ })+ .last(),+ ).toBeVisible();+ expect(subscriptions).toHaveLength(initialSubscriptions);+ }+ await page.mouse.up();+ await expect+ .poll(() => fs.readFileSync(fixture, 'utf8'))+ .toMatch(/name="Trim this parent"\s+durationInFrames=\{360\}/);++ // Edit the shared JSX using the first instance's latest (360 frame) context.+ await expression.click();+ const expressionEnd = await expression+ .getByRole('separator', {name: 'Drag to change duration', exact: true})+ .boundingBox();+ if (!expressionEnd) throw new Error('Expected expression trim handle');+ await page.mouse.move(+ expressionEnd.x + expressionEnd.width / 2,+ expressionEnd.y + expressionEnd.height / 2,+ );+ await page.mouse.down();+ await page.mouse.move(+ expressionEnd.x + expressionEnd.width / 2 + pixelsPerFrame * 36,+ expressionEnd.y + expressionEnd.height / 2,+ {steps: 5},+ );+ await page.mouse.up();+ await expect+ .poll(() => fs.readFileSync(fixture, 'utf8'))+ .toMatch(/durationInFrames=\{duration \* 0\.6\}/);+ await expect(+ page.getByText('Expression A: 216 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ page.getByText('Expression B: 240 frames', {exact: true}),+ ).toBeVisible();++ const keyframe = page+ .getByRole('button', {name: 'Select keyframe at frame 359', exact: true})+ .last();+ await keyframe.scrollIntoViewIfNeeded();+ const keyframeBox = await keyframe.boundingBox();+ if (!keyframeBox) throw new Error('Expected duration-dependent keyframe');+ await page.mouse.move(+ keyframeBox.x + keyframeBox.width / 2,+ keyframeBox.y + keyframeBox.height / 2,+ );+ await page.mouse.down();+ await page.mouse.move(+ keyframeBox.x + keyframeBox.width / 2 - pixelsPerFrame * 10,+ keyframeBox.y + keyframeBox.height / 2,+ {steps: 5},+ );+ await page.mouse.up();+ await expect+ .poll(() => fs.readFileSync(fixture, 'utf8'))+ .toContain('duration - 11');+ await expect+ .poll(() =>+ page+ .getByTestId('Expression B')+ .evaluate((element) =>+ Number(getComputedStyle(element.parentElement!).opacity),+ ),+ )+ .toBeCloseTo(30 / 389, 5);++ const sourceBefore = fs.readFileSync(fixture, 'utf8');+ fs.writeFileSync(+ fixture,+ sourceBefore+ .replace('duration * 0.6', 'duration * 0.75')+ .replace('duration - 11', 'duration - 2'),+ );+ await expect(+ page.getByText('Expression A: 270 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ page.getByText('Expression B: 300 frames', {exact: true}),+ ).toBeVisible();+ await expect+ .poll(() =>+ page+ .getByTestId('Expression A')+ .evaluate((element) =>+ Number(getComputedStyle(element.parentElement!).opacity),+ ),+ )+ .toBeCloseTo(30 / 358, 5);+ expect(+ errors.filter((error) => /maximum update depth/i.test(error)),+ ).toEqual([]);+ } finally {+ await stopStudio();+ fs.writeFileSync(fixture, original);+ }+});diff --git a/packages/example/e2e/vibe-code-source-expressions.test.mts b/packages/example/e2e/vibe-code-source-expressions.test.mtsnew file mode 100644index 0000000000..8f40f436b5--- /dev/null+++ b/packages/example/e2e/vibe-code-source-expressions.test.mts@@ -0,0 +1,153 @@+import {spawn} from 'node:child_process';+import fs from 'node:fs';+import path from 'node:path';+import {expect, test} from '@playwright/test';+import {exampleDir} from './constants.mts';++test.use({viewport: {width: 1920, height: 1200}});++test('SDK Canvas and vibe-code evaluate and save source expressions per instance', async ({+ page,+}) => {+ test.setTimeout(180_000);+ const template = path.resolve(exampleDir, '../template-vibe-code');+ const rootFile = path.join(template, 'src/remotion/Root.tsx');+ const fixture = path.join(+ template,+ 'src/remotion/SourceSubscriptionChurn.tsx',+ );+ const originalRoot = fs.readFileSync(rootFile, 'utf8');+ const originalFixture = fs.existsSync(fixture)+ ? fs.readFileSync(fixture, 'utf8')+ : null;+ const errors: string[] = [];+ page.on('pageerror', (error) => errors.push(error.message));+ fs.writeFileSync(+ fixture,+ fs.readFileSync(+ path.join(exampleDir, 'src/SourceSubscriptionChurn.tsx'),+ 'utf8',+ ),+ );+ fs.writeFileSync(+ rootFile,+ `import {Composition} from 'remotion';+import {SourceSubscriptionChurn} from './SourceSubscriptionChurn';+export const RemotionRoot = () => <Composition id="SourceSubscriptionChurn" component={SourceSubscriptionChurn} durationInFrames={600} fps={30} width={1280} height={720} />;`,+ );+ const server = spawn('bun', ['run', 'dev', '--port', '3124'], {+ cwd: template,+ detached: true,+ stdio: 'pipe',+ });+ let serverLogs = '';+ server.stdout.on('data', (chunk: Buffer) => {+ serverLogs += chunk.toString();+ });+ server.stderr.on('data', (chunk: Buffer) => {+ serverLogs += chunk.toString();+ });+ try {+ await expect+ .poll(+ async () => {+ try {+ return (await fetch('http://localhost:3124')).ok;+ } catch {+ return false;+ }+ },+ {timeout: 90_000, message: 'Vibe-code dev server should start'},+ )+ .toBe(true);+ await page.goto('http://localhost:3124');+ const preview = page.frameLocator('iframe[title="Composition preview"]');+ const parent = page.getByRole('button', {+ name: /^Trim this parent: from frame/,+ });+ await expect(parent).toBeVisible({timeout: 60_000});+ await page.getByRole('textbox', {name: 'Current frame'}).fill('30');+ await page.getByRole('textbox', {name: 'Current frame'}).press('Enter');+ await expect(+ preview.getByText('Expression A: 150 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ preview.getByText('Expression B: 200 frames', {exact: true}),+ ).toBeVisible();+ const box = await parent.boundingBox();+ if (!box) throw new Error('Expected parent timeline bar');+ const pixelsPerFrame = box.width / 300;+ const x = box.x + box.width - 2;+ const y = box.y + box.height / 2;+ await page.mouse.move(x, y);+ await page.mouse.down();+ for (const delta of [20, 40, 60]) {+ await page.mouse.move(x + delta * pixelsPerFrame, y, {steps: 3});+ await expect(+ preview.getByText(`Parent scope: ${300 + delta} frames`, {exact: true}),+ ).toBeVisible();+ await expect(+ preview.getByText(`Expression A: ${(300 + delta) / 2} frames`, {+ exact: true,+ }),+ ).toBeVisible();+ await expect(+ preview.getByText('Expression B: 200 frames', {exact: true}),+ ).toBeVisible();+ await expect+ .poll(() =>+ preview+ .getByTestId('Expression A')+ .evaluate((element) =>+ Number(getComputedStyle(element.parentElement!).opacity),+ ),+ )+ .toBeCloseTo(30 / (299 + delta), 5);+ }+ await page.mouse.up();+ const expression = page.getByRole('button', {+ name: /^Expression A: from frame/,+ });+ await expression.scrollIntoViewIfNeeded();+ const edge = await expression.boundingBox();+ if (!edge) throw new Error('Expected expression timeline bar');+ await page.mouse.move(edge.x + edge.width - 2, edge.y + edge.height / 2);+ await page.mouse.down();+ await page.mouse.move(+ edge.x + edge.width - 2 + pixelsPerFrame * 36,+ edge.y + edge.height / 2,+ {steps: 5},+ );+ await page.mouse.up();+ await expect(+ preview.getByText('Expression A: 216 frames', {exact: true}),+ ).toBeVisible();+ await expect(+ preview.getByText('Expression B: 240 frames', {exact: true}),+ ).toBeVisible();+ await page+ .getByRole('button', {name: 'Save to src/remotion', exact: true})+ .click();+ await expect+ .poll(() => fs.readFileSync(fixture, 'utf8'))+ .toMatch(/durationInFrames=\{duration \* 0\.6\}/);+ expect(+ errors.filter((error) => /maximum update depth/i.test(error)),+ ).toEqual([]);+ } catch (error) {+ await test.info().attach('vibe-code-server.log', {+ body: serverLogs,+ contentType: 'text/plain',+ });+ throw error;+ } finally {+ if (server.pid) process.kill(-server.pid, 'SIGTERM');+ await new Promise<void>((resolve) => {+ server.once('exit', () => resolve());+ setTimeout(resolve, 5_000);+ });+ fs.writeFileSync(rootFile, originalRoot);+ if (originalFixture === null) fs.rmSync(fixture, {force: true});+ else fs.writeFileSync(fixture, originalFixture);+ }+});diff --git a/packages/example/src/E2eTestRoot.tsx b/packages/example/src/E2eTestRoot.tsxindex 453ac02ab7..83a29c0b47 100644--- a/packages/example/src/E2eTestRoot.tsx+++ b/packages/example/src/E2eTestRoot.tsx@@ -20,6 +20,7 @@ import {MovingPillCaptionsComposition} from './MovingPillCaptionsComposition';import {NewVideoComp} from './NewVideo';import {SchemaTest, schemaTestSchema} from './SchemaTest';import {SequencePlaybackRateE2e} from './SequencePlaybackRateE2e';+import {SourceSubscriptionChurn} from './SourceSubscriptionChurn';import {TimelineNegativeFromResize} from './TimelineNegativeFromResize';import {VisualControls} from './VisualControls';import {VisualMode3D} from './VisualMode3D';@@ -32,6 +33,14 @@ import {SequenceShiftRepro} from './VisualModeTests/SequenceShiftRepro';export const E2eTestRoot: React.FC = () => {return (<>+ <Composition+ id="SourceSubscriptionChurn"+ component={SourceSubscriptionChurn}+ durationInFrames={600}+ fps={30}+ width={1280}+ height={720}+ /><Compositionid="sequence-playback-rate"component={SequencePlaybackRateE2e}diff --git a/packages/example/src/SourceSubscriptionChurn.tsx b/packages/example/src/SourceSubscriptionChurn.tsxnew file mode 100644index 0000000000..e44fd82a8f--- /dev/null+++ b/packages/example/src/SourceSubscriptionChurn.tsx@@ -0,0 +1,80 @@+import React from 'react';+import {+ AbsoluteFill,+ Sequence,+ interpolate,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';++const DurationReadout = ({label}: {label: string}) => {+ const {durationInFrames} = useVideoConfig();+ return (+ <div>+ {label}: {durationInFrames} frames+ </div>+ );+};++const ExpressionChild = ({label}: {label: string}) => {+ const {durationInFrames: duration} = useVideoConfig();+ const frame = useCurrentFrame();+ return (+ <Sequence+ name={label}+ durationInFrames={duration * 0.5}+ style={{+ position: 'relative',+ opacity: interpolate(frame, [0, duration - 1], [0, 1]),+ }}+ >+ <DurationReadout label={label} />+ <div+ data-testid={label}+ style={{width: 20, height: 20, backgroundColor: 'red'}}+ />+ </Sequence>+ );+};++export const SourceSubscriptionChurn: React.FC = () => (+ <AbsoluteFill style={{backgroundColor: '#eee', color: '#111', fontSize: 28}}>+ <Sequence name="Trim this parent" durationInFrames={300} layout="none">+ <DurationReadout label="Parent scope" />+ <Sequence name="Nested child 01" durationInFrames={180} layout="none">+ <DurationReadout label="Child 01" />+ </Sequence>+ <Sequence name="Nested child 02" durationInFrames={180} layout="none">+ <DurationReadout label="Child 02" />+ </Sequence>+ <Sequence name="Nested child 03" durationInFrames={180} layout="none">+ <DurationReadout label="Child 03" />+ </Sequence>+ <Sequence name="Nested child 04" durationInFrames={180} layout="none">+ <DurationReadout label="Child 04" />+ </Sequence>+ <Sequence name="Nested child 05" durationInFrames={180} layout="none">+ <DurationReadout label="Child 05" />+ </Sequence>+ <Sequence name="Nested child 06" durationInFrames={180} layout="none">+ <DurationReadout label="Child 06" />+ </Sequence>+ <Sequence name="Nested child 07" durationInFrames={180} layout="none">+ <DurationReadout label="Child 07" />+ </Sequence>+ <Sequence name="Nested child 08" durationInFrames={180} layout="none">+ <DurationReadout label="Child 08" />+ </Sequence>+ <ExpressionChild label="Expression A" />+ </Sequence>+ <Sequence name="Other parent" durationInFrames={400} layout="none">+ <ExpressionChild label="Expression B" />+ </Sequence>+ <Sequence name="Root control 01" durationInFrames={180} layout="none">+ <DurationReadout label="Root control 01" />+ </Sequence>+ <Sequence name="Root control 02" durationInFrames={180} layout="none">+ <DurationReadout label="Root control 02" />+ </Sequence>+ </AbsoluteFill>+);diff --git a/packages/gif/src/Gif.tsx b/packages/gif/src/Gif.tsxindex 05ffdf311e..7aff5879b5 100644--- a/packages/gif/src/Gif.tsx+++ b/packages/gif/src/Gif.tsx@@ -119,6 +119,7 @@ const GifInner = ({const memoizedEffects = useMemoizedEffects({effects,overrideId: controls?.overrideId ?? null,+ videoConfigValues: controls?.videoConfigValues ?? null,});const gifProps: RemotionGifProps & {diff --git a/packages/media/src/video/video.tsx b/packages/media/src/video/video.tsxindex 89e67d37e9..b43f6a4e84 100644--- a/packages/media/src/video/video.tsx+++ b/packages/media/src/video/video.tsx@@ -368,6 +368,7 @@ const VideoInner: React.FC<const memoizedEffects = Internals.useMemoizedEffects({effects: effects ?? [],overrideId: controls?.overrideId ?? null,+ videoConfigValues: controls?.videoConfigValues ?? null,});const memoizedEffectDefinitions = Internals.useMemoizedEffectDefinitions(effects ?? [],diff --git a/packages/rive/src/RemotionRiveCanvas.tsx b/packages/rive/src/RemotionRiveCanvas.tsxindex 684ba200e9..ee8e5b7cf4 100644--- a/packages/rive/src/RemotionRiveCanvas.tsx+++ b/packages/rive/src/RemotionRiveCanvas.tsx@@ -177,6 +177,7 @@ const RemotionRiveCanvasContentForwardRefFunction: React.ForwardRefRenderFunctioconst memoizedEffects = useMemoizedEffects({effects,overrideId: controls?.overrideId ?? null,+ videoConfigValues: controls?.videoConfigValues ?? null,});if (err) {diff --git a/packages/sdk/src/calculate-timeline.ts b/packages/sdk/src/calculate-timeline.tsindex b47fa1e023..36e819e4b6 100644--- a/packages/sdk/src/calculate-timeline.ts+++ b/packages/sdk/src/calculate-timeline.ts@@ -292,7 +292,10 @@ export const calculateTimeline = ({keyframePlaybackRate: parentPlaybackRate,nodePathInfo: nodePath? {- sequenceSubscriptionKey: nodePath,+ sequenceSubscriptionKey: {+ ...nodePath,+ videoConfigValues: sequence.controls?.videoConfigValues ?? null,+ },auxiliaryKeys: [],index: 0,numberOfSequencesWithThisNodePath: 0,diff --git a/packages/sdk/src/canvas-controller.ts b/packages/sdk/src/canvas-controller.tsindex fddebd49e9..7b73d2c625 100644--- a/packages/sdk/src/canvas-controller.ts+++ b/packages/sdk/src/canvas-controller.ts@@ -102,9 +102,7 @@ const nodePathsAreEqual = (return (nextNodePath !== undefined &&Internals.makeSequencePropsSubscriptionKey(previousNodePath) ===- Internals.makeSequencePropsSubscriptionKey(nextNodePath) &&- JSON.stringify(previousNodePath.videoConfigValues) ===- JSON.stringify(nextNodePath.videoConfigValues)+ Internals.makeSequencePropsSubscriptionKey(nextNodePath));});};diff --git a/packages/sdk/src/sequence-node-path.ts b/packages/sdk/src/sequence-node-path.tsindex 5fd5acd956..45083a13b8 100644--- a/packages/sdk/src/sequence-node-path.ts+++ b/packages/sdk/src/sequence-node-path.ts@@ -51,7 +51,7 @@ export const getCanvasSequenceNodePathInfo = (nodePath: ['sequence', track.sequence.id],sequenceKeys: [],effectKeys: [],- videoConfigValues: null,+ videoConfigValues: track.sequence.controls?.videoConfigValues ?? null,},auxiliaryKeys: [],index: 0,diff --git a/packages/studio-server/src/helpers/video-config-numeric-expression.ts b/packages/studio-server/src/helpers/video-config-numeric-expression.tsindex 78d7aa87d3..7a3fbc69c8 100644--- a/packages/studio-server/src/helpers/video-config-numeric-expression.ts+++ b/packages/studio-server/src/helpers/video-config-numeric-expression.ts@@ -1,7 +1,11 @@import type {Expression} from '@babel/types';import type {ExpressionKind} from 'ast-types/lib/gen/kinds';import * as recast from 'recast';-import type {VideoConfigNumericExpression} from 'remotion';+import type {+ VideoConfigNumericBinding,+ VideoConfigNumericExpression,+} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';import type {VideoConfigIdentifierValues} from './video-config-values';const b = recast.types.builders;@@ -34,7 +38,7 @@ const getVideoConfigValue = ({}: {node: Expression;videoConfigValues: VideoConfigIdentifierValues;-}): {identifier: string; value: number} | null => {+}): {identifier: string; binding: VideoConfigNumericBinding} | null => {if (node.type === 'TSAsExpression') {return getVideoConfigValue({node: node.expression as Expression,@@ -46,12 +50,12 @@ const getVideoConfigValue = ({return null;}- const value = videoConfigValues[node.name];- if (value === undefined || !Number.isFinite(value)) {+ const binding = videoConfigValues[node.name];+ if (binding === undefined) {return null;}- return {identifier: node.name, value};+ return {identifier: node.name, binding};};export const parseVideoConfigNumericExpression = ({@@ -94,17 +98,11 @@ export const parseVideoConfigNumericExpression = ({return null;}- const resolvedValue = minuend.value - subtrahend;- if (!Number.isFinite(resolvedValue)) {- return null;- }-return {type: 'video-config-subtraction',identifier: minuend.identifier,- minuend: minuend.value,+ binding: minuend.binding,subtrahend,- value: resolvedValue,};}@@ -136,18 +134,12 @@ export const parseVideoConfigNumericExpression = ({const multiplier = factorPosition === 'left' ? leftNumber! : rightNumber!;const configValue =factorPosition === 'left' ? rightVideoConfig! : leftVideoConfig!;- const value = multiplier * configValue.value;- if (!Number.isFinite(value)) {- return null;- }-return {type: 'video-config-multiplication',identifier: configValue.identifier,multiplier,- multiplicand: configValue.value,+ binding: configValue.binding,factorPosition,- value,};};@@ -171,14 +163,25 @@ export const updateVideoConfigNumericExpression = ({}if (expression.type === 'video-config-value') {- return value === expression.value+ return value ===+ NoReactInternals.evaluateSourceNumericValue(expression, null)? b.identifier(expression.identifier): numericExpression(value);}if (expression.type === 'video-config-subtraction') {- const subtrahend = expression.minuend - value;- if (!Number.isFinite(subtrahend)) {+ const subtrahend =+ (expression.binding.type === 'constant'+ ? expression.binding.value+ : NaN) - value;+ if (+ !Number.isFinite(subtrahend) ||+ (expression.binding.type === 'constant'+ ? expression.binding.value+ : NaN) -+ subtrahend !==+ value+ ) {return numericExpression(value);}@@ -193,8 +196,19 @@ export const updateVideoConfigNumericExpression = ({return numericExpression(value);}- const multiplier = value / expression.multiplicand;- if (!Number.isFinite(multiplier) || multiplier === 0) {+ const multiplier =+ value /+ (expression.binding.type === 'constant' ? expression.binding.value : NaN);+ // Preserve the expression only if evaluating it reproduces the requested value.+ if (+ !Number.isFinite(multiplier) ||+ multiplier === 0 ||+ multiplier *+ (expression.binding.type === 'constant'+ ? expression.binding.value+ : NaN) !==+ value+ ) {return numericExpression(value);}diff --git a/packages/studio-server/src/helpers/video-config-values.ts b/packages/studio-server/src/helpers/video-config-values.tsindex acce8cbbe2..797a225365 100644--- a/packages/studio-server/src/helpers/video-config-values.ts+++ b/packages/studio-server/src/helpers/video-config-values.ts@@ -1,19 +1,23 @@import type {File} from '@babel/types';import * as recast from 'recast';-import type {VideoConfigValues} from 'remotion';+import type {VideoConfigNumericBinding, VideoConfigValues} from 'remotion';-export type VideoConfigIdentifierValues = Record<string, number>;+export type VideoConfigIdentifierValues = Record<+ string,+ VideoConfigNumericBinding+>;-export const getVideoConfigIdentifierValues = ({+export const getVideoConfigIdentifiers = ({ast,- videoConfigValues,}: {ast: File;- videoConfigValues: VideoConfigValues | null;}): VideoConfigIdentifierValues => {- const candidates = new Map<string, number>();+ const candidates = new Map<string, VideoConfigNumericBinding>();const otherDeclarations = new Set<string>();- const addCandidate = (identifier: string, value: number) => {+ const addCandidate = (+ identifier: string,+ value: VideoConfigNumericBinding,+ ) => {if (candidates.has(identifier) || otherDeclarations.has(identifier)) {candidates.delete(identifier);otherDeclarations.add(identifier);@@ -27,7 +31,6 @@ export const getVideoConfigIdentifierValues = ({visitVariableDeclarator(path) {const {id, init} = path.node;const isVideoConfigDeclaration =- videoConfigValues !== null &&id.type === 'ObjectPattern' &&init?.type === 'CallExpression' &&init.callee.type === 'Identifier' &&@@ -50,14 +53,19 @@ export const getVideoConfigIdentifierValues = ({: property.key.type === 'StringLiteral'? property.key.value: null;- if (configKey === null || !(configKey in videoConfigValues)) {+ if (+ configKey !== 'durationInFrames' &&+ configKey !== 'fps' &&+ configKey !== 'width' &&+ configKey !== 'height'+ ) {continue;}- const value = videoConfigValues[configKey as keyof VideoConfigValues];- if (Number.isFinite(value)) {- addCandidate(property.value.name, value);- }+ addCandidate(property.value.name, {+ type: 'video-config',+ field: configKey,+ });}} else if (id.type === 'Identifier') {const declaration = path.parentPath.node;@@ -70,7 +78,7 @@ export const getVideoConfigIdentifierValues = ({: null;if (numericConstant !== null) {- addCandidate(id.name, numericConstant);+ addCandidate(id.name, {type: 'constant', value: numericConstant});} else {candidates.delete(id.name);otherDeclarations.add(id.name);@@ -87,3 +95,23 @@ export const getVideoConfigIdentifierValues = ({return Object.fromEntries(candidates);};++// Editing uses the current instance's configuration supplied with the mutation.+export const getVideoConfigIdentifierValues = ({+ ast,+ videoConfigValues,+}: {+ ast: File;+ videoConfigValues: VideoConfigValues | null;+}): VideoConfigIdentifierValues =>+ Object.fromEntries(+ Object.entries(getVideoConfigIdentifiers({ast})).flatMap(+ ([identifier, binding]) => {+ if (binding.type === 'constant') return [[identifier, binding]];+ const value = videoConfigValues?.[binding.field];+ return value === undefined || !Number.isFinite(value)+ ? []+ : [[identifier, {type: 'constant', value}]];+ },+ ),+ );diff --git a/packages/studio-server/src/preview-server/routes/add-sequence-keyframe.ts b/packages/studio-server/src/preview-server/routes/add-sequence-keyframe.tsindex 1edb139479..3f68da33f3 100644--- a/packages/studio-server/src/preview-server/routes/add-sequence-keyframe.ts+++ b/packages/studio-server/src/preview-server/routes/add-sequence-keyframe.ts@@ -116,7 +116,6 @@ export const addSequenceKeyframeHandler: ApiHandler<nodePath: updatedNodePath,componentIdentity: null,effects: [],- videoConfigValues: nodePath.videoConfigValues,});const updatedSubscriptionKey = {...nodePath, nodePath: updatedNodePath};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.tsindex 0a3cc4f5bb..9f1b871923 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@@ -8,27 +8,23 @@ import type {ObjectExpression,ObjectProperty,} from '@babel/types';+import {CodemodsInternals} from '@remotion/codemods';import type {CanUpdateEffectPropsResponse,CanUpdateSequencePropStatus,SequenceNodePath,InteractivitySchema,- VideoConfigValues,} from 'remotion';-import {parseAst} from '../../codemods/parse-ast';+import {NoReactInternals} from 'remotion/no-react';import {enumerateEffectArrayElements,type EffectArrayElement,} from '../../codemods/update-effect-props/update-effect-props';import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';import {parseVideoConfigNumericExpression} from '../../helpers/video-config-numeric-expression';-import {- getVideoConfigIdentifierValues,- type VideoConfigIdentifierValues,-} from '../../helpers/video-config-values';+import {type VideoConfigIdentifierValues} from '../../helpers/video-config-values';import {extractStaticValue,- findJsxElementAtNodePath,getComputedStatus,isStaticValue,} from './can-update-sequence-props';@@ -188,7 +184,10 @@ const getPropsFromObjectExpression = ({? {status: 'static',keyframeDisplayOffsetAdjustment: null,- codeValue: numericExpression.value,+ codeValue: NoReactInternals.evaluateSourceNumericValue(+ numericExpression,+ null,+ ),...(numericExpression.type === 'literal'? {}: {numericExpression}),@@ -294,43 +293,7 @@ export const computeEffectPropStatus = ({};};-export const computeEffectPropsStatusesFromContent = ({- fileContents,- sequenceNodePath,- effects,- keysFor,- videoConfigValues,-}: {- fileContents: string;- sequenceNodePath: SequenceNodePath;- effects: InteractivitySchema[];- keysFor: (effect: InteractivitySchema) => string[];- videoConfigValues: VideoConfigValues | null;-}): CanUpdateEffectPropsResponse[] => {- const ast = parseAst(fileContents);- const videoConfigIdentifierValues = getVideoConfigIdentifierValues({- ast,- videoConfigValues,- });- const jsx = findJsxElementAtNodePath(ast, sequenceNodePath);- if (!jsx) {- return effects.map((_effect, effectIndex) => ({- canUpdate: false as const,- effectIndex,- reason: 'not-found' as const,- }));- }-- return effects.map((effect, effectIndex) =>- computeEffectPropStatus({- ast,- jsx,- effectIndex,- keys: keysFor(effect),- videoConfigValues: videoConfigIdentifierValues,- }),- );-};+export const {computeEffectPropsStatusesFromContent} = CodemodsInternals;export const computeEffectPropsStatusesFromFile = ({fileName,@@ -338,14 +301,12 @@ export const computeEffectPropsStatusesFromFile = ({effects,keysFor,remotionRoot,- videoConfigValues,}: {fileName: string;sequenceNodePath: SequenceNodePath;effects: InteractivitySchema[];keysFor: (effect: InteractivitySchema) => string[];remotionRoot: string;- videoConfigValues: VideoConfigValues | null;}): CanUpdateEffectPropsResponse[] => {const {absolutePath} = resolveFileInsideProject({remotionRoot,@@ -359,6 +320,5 @@ export const computeEffectPropsStatusesFromFile = ({sequenceNodePath,effects,keysFor,- videoConfigValues,});};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.tsindex 95058cb618..52c496e247 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@@ -27,7 +27,6 @@ import type {JsxComponentIdentity,LogLevel,SequenceNodePath,- VideoConfigValues,} from 'remotion';import {NoReactInternals} from 'remotion/no-react';import {getAstNodePath} from '../../helpers/get-ast-node-path';@@ -619,7 +618,7 @@ const getInterpolationKeyframes = (}keyframes.push({- frame: frameExpression.value,+ frame: NoReactInternals.evaluateSourceNumericValue(frameExpression, null),value: extractStaticValue(outputElement),...(frameExpression.type === 'literal' ? {} : {frameExpression}),});@@ -767,12 +766,13 @@ const getJsxNumericAttribute = ({return null;}- return (- parseVideoConfigNumericExpression({- node: attribute.value.expression,- videoConfigValues,- })?.value ?? null- );+ const numericExpression = parseVideoConfigNumericExpression({+ node: attribute.value.expression,+ videoConfigValues,+ });+ return numericExpression === null+ ? null+ : NoReactInternals.evaluateSourceNumericValue(numericExpression, null);}return defaultValue;@@ -1376,7 +1376,6 @@ export const computeSequencePropsStatusFromContent = ({keys,assetKeys = [],effects,- videoConfigValues,}: {fileContents: string;nodePath: SequenceNodePath;@@ -1384,7 +1383,6 @@ export const computeSequencePropsStatusFromContent = ({keys: string[];assetKeys?: string[];effects: string[][];- videoConfigValues: VideoConfigValues | null;}): CanUpdateSequencePropsResponseTrue => {try {return getNodeProps({@@ -1394,7 +1392,6 @@ export const computeSequencePropsStatusFromContent = ({keys,assetKeys,effectKeys: effects,- videoConfig: videoConfigValues ?? undefined,});} catch (error) {if (error instanceof CodemodsInternals.JsxElementIdentityMismatchError) {@@ -1417,7 +1414,6 @@ export const computeSequencePropsStatus = ({assetKeys = [],effects,remotionRoot,- videoConfigValues,}: {fileName: string;nodePath: SequenceNodePath;@@ -1426,7 +1422,6 @@ export const computeSequencePropsStatus = ({assetKeys?: string[];effects: string[][];remotionRoot: string;- videoConfigValues: VideoConfigValues | null;}): CanUpdateSequencePropsResponseTrue => {const {absolutePath} = resolveFileInsideProject({remotionRoot,@@ -1442,7 +1437,6 @@ export const computeSequencePropsStatus = ({keys,assetKeys,effects,- videoConfigValues,});};@@ -1456,7 +1450,6 @@ export const computeSequencePropsStatusFromFilenameByLocation = ({effects,remotionRoot,logLevel,- videoConfigValues,}: {fileName: string;line: number;@@ -1467,7 +1460,6 @@ export const computeSequencePropsStatusFromFilenameByLocation = ({effects: string[][];remotionRoot: string;logLevel: LogLevel;- videoConfigValues: VideoConfigValues;}): SubscribeToSequencePropsResponse => {try {const {absolutePath} = resolveFileInsideProject({@@ -1500,14 +1492,13 @@ export const computeSequencePropsStatusFromFilenameByLocation = ({assetKeys,effects,remotionRoot,- videoConfigValues,}),nodePath: {absolutePath,nodePath: resolvedNodePath,sequenceKeys: keys,effectKeys: effects,- videoConfigValues,+ videoConfigValues: null,},success: true,};diff --git a/packages/studio-server/src/preview-server/routes/delete-keyframes.ts b/packages/studio-server/src/preview-server/routes/delete-keyframes.tsindex 5db3fb8097..f11b361d8c 100644--- a/packages/studio-server/src/preview-server/routes/delete-keyframes.ts+++ b/packages/studio-server/src/preview-server/routes/delete-keyframes.ts@@ -349,7 +349,6 @@ export const deleteKeyframes = async ({nodePath: keyframe.nodePath.nodePath,componentIdentity: null,effects: [],- videoConfigValues: keyframe.nodePath.videoConfigValues,});return {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.tsindex 54e91ef1cd..9df42350a8 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@@ -721,7 +721,6 @@ export const saveSequencePropsHandler: ApiHandler<) ?? target.nodePath.nodePath,componentIdentity: null,effects: [],- videoConfigValues: target.nodePath.videoConfigValues,};const newStatus = computeSequencePropsStatusFromContent({...statusInput,diff --git a/packages/studio-server/src/preview-server/routes/subscribe-to-sequence-props.ts b/packages/studio-server/src/preview-server/routes/subscribe-to-sequence-props.tsindex edb0e5d8ad..7fd787ca25 100644--- a/packages/studio-server/src/preview-server/routes/subscribe-to-sequence-props.ts+++ b/packages/studio-server/src/preview-server/routes/subscribe-to-sequence-props.ts@@ -55,7 +55,6 @@ export const subscribeToSequenceProps: ApiHandler<assetKeys,effects,clientId,- videoConfigValues,},index,) =>@@ -71,7 +70,7 @@ export const subscribeToSequenceProps: ApiHandler<effects,remotionRoot,clientId,- videoConfigValues,+logLevel,}),);diff --git a/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts b/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.tsindex edb5c10bc5..ddacf37926 100644--- a/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts+++ b/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts@@ -24,7 +24,6 @@ export const unsubscribeFromSequenceProps: ApiHandler<sequenceKeys,assetKeys,effectKeys,- videoConfigValues: nodePath.videoConfigValues,});return Promise.resolve(undefined);};diff --git a/packages/studio-server/src/preview-server/routes/update-sequence-keyframe-settings.ts b/packages/studio-server/src/preview-server/routes/update-sequence-keyframe-settings.tsindex 9cd2a1763c..9d1ff66589 100644--- a/packages/studio-server/src/preview-server/routes/update-sequence-keyframe-settings.ts+++ b/packages/studio-server/src/preview-server/routes/update-sequence-keyframe-settings.ts@@ -119,7 +119,6 @@ export const updateSequenceKeyframeSettingsHandler: ApiHandler<nodePath: updatedNodePath,componentIdentity: null,effects: [],- videoConfigValues: nodePath.videoConfigValues,});const updatedSubscriptionKey = {...nodePath, nodePath: updatedNodePath};diff --git a/packages/studio-server/src/preview-server/sequence-props-watchers.ts b/packages/studio-server/src/preview-server/sequence-props-watchers.tsindex a3ee65cad7..bf8bcafb6c 100644--- a/packages/studio-server/src/preview-server/sequence-props-watchers.ts+++ b/packages/studio-server/src/preview-server/sequence-props-watchers.ts@@ -5,11 +5,7 @@ import {stringifySequenceSubscriptionKey,type SubscribeToSequencePropsResponse,} from '@remotion/studio-shared';-import type {- JsxComponentIdentity,- SequenceNodePath,- VideoConfigValues,-} from 'remotion';+import type {JsxComponentIdentity, SequenceNodePath} from 'remotion';import {installFileWatcher} from '../file-watcher';import {JsxElementIdentityMismatchError} from './jsx-component-identity';import {JsxElementNotFoundAtLocationError} from './jsx-element-not-found-at-location-error';@@ -38,11 +34,9 @@ const getWatcherKey = (nodePath: SequenceNodePath;sequenceKeys: string[];effectKeys: string[][];- videoConfigValues: VideoConfigValues | null;},assetKeys: string[],-) =>- `${stringifySequenceSubscriptionKey(nodePath)}:${assetKeys.join('\0')}:${JSON.stringify(nodePath.videoConfigValues)}`;+) => `${stringifySequenceSubscriptionKey(nodePath)}:${assetKeys.join('\0')}`;const getSequencePropsStatus = ({fileName,@@ -56,7 +50,6 @@ const getSequencePropsStatus = ({effects,remotionRoot,logLevel,- videoConfigValues,}: {fileName: string;line: number;@@ -69,7 +62,6 @@ const getSequencePropsStatus = ({effects: string[][];remotionRoot: string;logLevel: LogLevel;- videoConfigValues: VideoConfigValues;}): SubscribeToSequencePropsResponse => {if (preferredNodePath) {try {@@ -81,7 +73,6 @@ const getSequencePropsStatus = ({assetKeys,effects,remotionRoot,- videoConfigValues,});return {status: fromNodePath,@@ -90,7 +81,7 @@ const getSequencePropsStatus = ({nodePath: preferredNodePath,sequenceKeys: keys,effectKeys: effects,- videoConfigValues,+ videoConfigValues: null,},success: true,};@@ -120,7 +111,6 @@ const getSequencePropsStatus = ({assetKeys,effects,remotionRoot,- videoConfigValues,});} catch (error) {if (@@ -142,7 +132,7 @@ const getSequencePropsStatus = ({nodePath: cachedNodePath,sequenceKeys: keys,effectKeys: effects,- videoConfigValues,+ videoConfigValues: null,},success: true,};@@ -160,14 +150,13 @@ const getSequencePropsStatus = ({assetKeys,effects,remotionRoot,- videoConfigValues,}),nodePath: {absolutePath: path.resolve(remotionRoot, fileName),nodePath: resolvedNodePath,sequenceKeys: keys,effectKeys: effects,- videoConfigValues,+ videoConfigValues: null,},success: true,};@@ -193,7 +182,6 @@ const getSequencePropsStatus = ({effects,remotionRoot,logLevel,- videoConfigValues,});return status;@@ -212,7 +200,6 @@ export const subscribeToSequencePropsWatchers = ({remotionRoot,clientId,logLevel,- videoConfigValues,}: {fileName: string;line: number;@@ -226,7 +213,6 @@ export const subscribeToSequencePropsWatchers = ({remotionRoot: string;clientId: string;logLevel: LogLevel;- videoConfigValues: VideoConfigValues;}): SubscribeToSequencePropsResponse => {const initialResult = getSequencePropsStatus({fileName,@@ -240,7 +226,6 @@ export const subscribeToSequencePropsWatchers = ({effects,remotionRoot,logLevel,- videoConfigValues,});if (!initialResult.success) {@@ -274,9 +259,8 @@ export const subscribeToSequencePropsWatchers = ({return;}- if (event.originatorClientId === clientId) {- return;- }+ // Even the editing client needs the saved expression: its optimistic+ // numeric value only describes the instance that initiated the edit.if (event.type === 'changed' && event.skipSequencePropsUpdate) {return;@@ -290,7 +274,6 @@ export const subscribeToSequencePropsWatchers = ({keys,assetKeys,effects,- videoConfigValues,});const previousEffectChain = result.effects.map((effect) => effect.canUpdate && effect.callee,@@ -355,7 +338,6 @@ export const unsubscribeFromSequencePropsWatchers = ({sequenceKeys,assetKeys,effectKeys,- videoConfigValues,}: {fileName: string;nodePath: SequenceNodePath;@@ -364,7 +346,6 @@ export const unsubscribeFromSequencePropsWatchers = ({sequenceKeys: string[];assetKeys: string[];effectKeys: string[][];- videoConfigValues: VideoConfigValues | null;}) => {const absolutePath = path.resolve(remotionRoot, fileName);const watcherKey = getWatcherKey(@@ -373,7 +354,6 @@ export const unsubscribeFromSequencePropsWatchers = ({nodePath,sequenceKeys,effectKeys,- videoConfigValues,},assetKeys,);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.tsindex b3525382e4..b9d18bedd7 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@@ -83,7 +83,6 @@ export const Fallback = () => <><Sequence name="First" /><Sequence name="Fallbaceffects: [],remotionRoot,logLevel: 'info',- videoConfigValues,});};@@ -183,7 +182,6 @@ test('computeSequencePropsStatus should ignore source locations outside the projeffects: [],remotionRoot,logLevel: 'info',- videoConfigValues,}),).toEqual({success: false,@@ -208,7 +206,6 @@ export const Example = () => {keys: ['src'],assetKeys: ['src'],effects: [],- videoConfigValues: null,});expect(result.props.src).toEqual({@@ -242,7 +239,6 @@ export const Example = ({timing}: {timing: {from: number; durationInFrames: numbcomponentIdentity: null,keys: ['from', 'durationInFrames', 'name', 'style.opacity'],effects: [],- videoConfigValues: null,});expect(spreadMayOverride.props).toEqual({@@ -269,7 +265,6 @@ export const Example = ({timing}: {timing: {from: number; durationInFrames: numbcomponentIdentity: null,keys: ['from', 'children'],effects: [],- videoConfigValues: null,});// With an empty element body, the spread may provide both props@@ -303,26 +298,24 @@ export const Example: React.FC = () => {componentIdentity: null,keys: ['premountFor', 'postmountFor', 'offset', 'from', 'style.scale'],effects: [],- videoConfigValues,});expect(result.props.premountFor).toEqual({status: 'static',keyframeDisplayOffsetAdjustment: null,- codeValue: 60,+ codeValue: undefined,numericExpression: {type: 'video-config-multiplication',identifier: 'fps',multiplier: 2,- multiplicand: 30,+ binding: {type: 'video-config', field: 'fps'},factorPosition: 'left',- value: 60,},});expect(result.props.postmountFor).toMatchObject({status: 'static',keyframeDisplayOffsetAdjustment: null,- codeValue: 75,+ codeValue: undefined,numericExpression: {type: 'video-config-multiplication',factorPosition: 'right',@@ -332,7 +325,7 @@ export const Example: React.FC = () => {expect(result.props.offset).toMatchObject({status: 'static',keyframeDisplayOffsetAdjustment: null,- codeValue: -30,+ codeValue: undefined,numericExpression: {multiplier: -1},});expect(result.props['style.scale']).toMatchObject({@@ -341,7 +334,11 @@ export const Example: React.FC = () => {keyframes: [{frame: 0, value: 2},{- frame: 99.9,+ frame: {+ type: 'video-config-multiplication',+ identifier: 'fps',+ binding: {type: 'video-config', field: 'fps'},+ },value: 3,frameExpression: {type: 'video-config-multiplication',@@ -349,7 +346,11 @@ export const Example: React.FC = () => {},},{- frame: 120,+ frame: {+ type: 'video-config-value',+ identifier: 'durationInFrames',+ binding: {type: 'video-config', field: 'durationInFrames'},+ },value: 4,frameExpression: {type: 'video-config-value',@@ -358,6 +359,18 @@ export const Example: React.FC = () => {},],});+ for (const durationInFrames of [120, 240]) {+ const evaluated = NoReactInternals.evaluateSourcePropStatuses(+ result.props,+ {...videoConfigValues, durationInFrames},+ );+ expect(evaluated.premountFor).toMatchObject({codeValue: 60});+ expect(evaluated.postmountFor).toMatchObject({codeValue: 75});+ expect(evaluated.offset).toMatchObject({codeValue: -30});+ expect(evaluated['style.scale']).toMatchObject({+ keyframes: [{frame: 0}, {frame: 99.9}, {frame: durationInFrames}],+ });+ }});test('computeSequencePropsStatus should parse multiplication by a numeric constant', () => {@@ -375,20 +388,18 @@ export const ShortAudioLoop = () => {componentIdentity: null,keys: ['from'],effects: [],- videoConfigValues: null,});expect(result.props.from).toEqual({status: 'static',keyframeDisplayOffsetAdjustment: null,- codeValue: -240,+ codeValue: undefined,numericExpression: {type: 'video-config-multiplication',identifier: 'fps',multiplier: -8,- multiplicand: 30,+ binding: {type: 'constant', value: 30},factorPosition: 'left',- value: -240,},});});@@ -406,7 +417,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.borderWidth', 'style.borderStyle', 'style.borderColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.borderWidth']).toEqual({@@ -450,7 +460,6 @@ export const Example = () => {componentIdentity: null,keys,effects: [],- videoConfigValues: null,});const pixelValues = computeSequencePropsStatusFromContent({fileContents: input,@@ -458,7 +467,6 @@ export const Example = () => {componentIdentity: null,keys,effects: [],- videoConfigValues: null,});expect(numeric.props).toMatchObject({@@ -534,7 +542,6 @@ export const Example = () => {'style.borderBottomLeftRadius',],effects: [],- videoConfigValues: null,});expect(getStatus(6).props['style.borderRadius']).toEqual({@@ -576,7 +583,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.borderRadius'],effects: [],- videoConfigValues: null,});expect(result.props['style.borderRadius']).toMatchObject({@@ -604,7 +610,6 @@ export const Example = ({radius}: {radius: string}) => {componentIdentity: null,keys: ['style.borderTopLeftRadius'],effects: [],- videoConfigValues: null,});expect(result.props['style.borderTopLeftRadius']).toEqual({@@ -638,7 +643,6 @@ export const Example = () => {'style.borderBottomLeftRadius',],effects: [],- videoConfigValues: null,});for (const line of [6, 7]) {@@ -661,7 +665,6 @@ export const Example = ({border}: {border: string}) => {componentIdentity: null,keys: ['style.borderWidth', 'style.borderStyle', 'style.borderColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.borderWidth']).toEqual({status: 'computed'});@@ -690,7 +693,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.borderWidth', 'style.borderStyle', 'style.borderColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.borderWidth']).toEqual({status: 'computed'});@@ -717,7 +719,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.borderWidth'],effects: [],- videoConfigValues: null,});const afterShorthand = computeSequencePropsStatusFromContent({fileContents: input,@@ -725,7 +726,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.borderWidth'],effects: [],- videoConfigValues: null,});expect(beforeShorthand.props['style.borderWidth']).toEqual({@@ -753,7 +753,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.borderWidth', 'style.borderStyle', 'style.borderColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.borderWidth']).toEqual({@@ -786,7 +785,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.backgroundColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.backgroundColor']).toEqual({@@ -819,7 +817,6 @@ export const Example = ({background}: {background: string}) => {componentIdentity: null,keys: ['style.backgroundColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.backgroundColor']).toEqual({@@ -846,7 +843,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.backgroundColor'],effects: [],- videoConfigValues: null,});const afterShorthand = computeSequencePropsStatusFromContent({fileContents: input,@@ -854,7 +850,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.backgroundColor'],effects: [],- videoConfigValues: null,});expect(beforeShorthand.props['style.backgroundColor']).toEqual({@@ -889,7 +884,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.backgroundColor'],effects: [],- videoConfigValues: null,});expect(result.props['style.backgroundColor']).toEqual({@@ -902,7 +896,6 @@ export const Example = () => {test('canUpdateSequenceProps should flag computed props', () => {const filePath = path.join(__dirname, 'snapshots', 'light-leak-computed.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 8),componentIdentity: null,@@ -946,7 +939,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -988,7 +980,6 @@ export const Example: React.FC = () => {expect(() =>computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: 'dev.remotion.shapes.Star',@@ -1011,7 +1002,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 6),componentIdentity: 'dev.remotion.roughNotation.Highlight',@@ -1045,7 +1035,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 6),componentIdentity: 'dev.remotion.remotion.Sequence',@@ -1075,7 +1064,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1114,7 +1102,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1162,7 +1149,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1205,7 +1191,6 @@ export const Example: React.FC = () => {`;const getProps = (line: number) => {const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, line),componentIdentity: null,@@ -1247,7 +1232,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 9),componentIdentity: null,@@ -1288,7 +1272,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 9),componentIdentity: null,@@ -1332,7 +1315,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 10),componentIdentity: null,@@ -1384,7 +1366,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 10),componentIdentity: null,@@ -1419,7 +1400,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 8),componentIdentity: null,@@ -1454,7 +1434,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 8),componentIdentity: null,@@ -1490,7 +1469,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1533,7 +1511,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 8),componentIdentity: null,@@ -1561,7 +1538,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1594,7 +1570,6 @@ test('computeSequencePropsStatus should explain why outside-project file reads wexpect(() =>computeSequencePropsStatus({- videoConfigValues: null,fileName,nodePath: [],componentIdentity: null,@@ -1610,7 +1585,6 @@ test('computeSequencePropsStatus should explain why outside-project file reads wtest('computeSequencePropsStatus should detect static nested props', () => {const filePath = path.join(__dirname, 'snapshots', 'nested-props.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 7),componentIdentity: null,@@ -1637,7 +1611,6 @@ test('computeSequencePropsStatus should detect static nested props', () => {test('computeSequencePropsStatus should flag computed nested props', () => {const filePath = path.join(__dirname, 'snapshots', 'nested-props.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 8),componentIdentity: null,@@ -1683,7 +1656,6 @@ export const Example = () => {componentIdentity: null,keys: ['style.color'],effects: [],- videoConfigValues: null,}).props['style.color'];};@@ -1699,7 +1671,6 @@ export const Example = () => {test('computeSequencePropsStatus should flag computed when parent is not an object', () => {const filePath = path.join(__dirname, 'snapshots', 'nested-props.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 9),componentIdentity: null,@@ -1720,7 +1691,6 @@ test('computeSequencePropsStatus should flag computed when parent is not an objetest('computeSequencePropsStatus should report unset nested props as undefined', () => {const filePath = path.join(__dirname, 'snapshots', 'nested-props.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 7),componentIdentity: null,@@ -1742,7 +1712,6 @@ test('computeSequencePropsStatus should report unset nested props as undefined',test('computeSequencePropsStatus should report unset when parent attribute missing', () => {const filePath = path.join(__dirname, 'snapshots', 'nested-props.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 10),componentIdentity: null,@@ -1764,7 +1733,6 @@ test('computeSequencePropsStatus should report unset when parent attribute missitest('computeSequencePropsStatus should return keyframes for interpolated style props', () => {const filePath = path.join(__dirname, 'snapshots', 'keyframed-props.tsx');const result = computeSequencePropsStatus({- videoConfigValues: null,fileName: filePath,nodePath: getNodePath(filePath, 8),componentIdentity: null,@@ -1818,7 +1786,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1865,7 +1832,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1911,7 +1877,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1950,7 +1915,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -1989,7 +1953,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -2028,7 +1991,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -2058,7 +2020,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 8),componentIdentity: null,@@ -2087,7 +2048,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -2117,7 +2077,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 8),componentIdentity: null,@@ -2148,7 +2107,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -2189,7 +2147,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -2237,7 +2194,6 @@ export const Example: React.FC = () => {`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 7),componentIdentity: null,@@ -2262,7 +2218,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 5),componentIdentity: null,@@ -2286,7 +2241,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 5),componentIdentity: null,@@ -2310,7 +2264,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 5),componentIdentity: null,@@ -2334,7 +2287,6 @@ export const Example: React.FC = () => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 5),componentIdentity: null,@@ -2358,7 +2310,6 @@ export const Example: React.FC<{text: string}> = ({text}) => {};`;const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: getNodePathFromContent(input, 5),componentIdentity: null,diff --git a/packages/studio-server/src/test/subscribe-to-sequence-props.test.ts b/packages/studio-server/src/test/subscribe-to-sequence-props.test.tsindex cf08e56213..edeb9b6221 100644--- a/packages/studio-server/src/test/subscribe-to-sequence-props.test.ts+++ b/packages/studio-server/src/test/subscribe-to-sequence-props.test.ts@@ -39,12 +39,6 @@ export const Second = () => {const clientId = `subscription-test-${uniqueSuffix}`;writeFileSync(join(remotionRoot, firstFileName), firstInput);writeFileSync(join(remotionRoot, secondFileName), secondInput);- const videoConfigValues = {- durationInFrames: 100,- fps: 30,- height: 1080,- width: 1920,- };const requestBase = {column: 0,componentIdentity: 'dev.remotion.remotion.Interactive.Div',@@ -52,7 +46,6 @@ export const Second = () => {assetKeys: [],effects: [],clientId,- videoConfigValues,} satisfies Omit<SubscribeToSequencePropsRequest,'fileName' | 'line' | 'nodePath'@@ -209,12 +202,6 @@ export default InteractiveDivStressTest;assetKeys: [],effects: [],clientId,- videoConfigValues: {- durationInFrames: 120,- fps: 30,- height: 1080,- width: 1080,- },}),);diff --git a/packages/studio-server/src/test/unsupported-translate.test.ts b/packages/studio-server/src/test/unsupported-translate.test.tsindex 9374e433b8..759e44a230 100644--- a/packages/studio-server/src/test/unsupported-translate.test.ts+++ b/packages/studio-server/src/test/unsupported-translate.test.ts@@ -27,7 +27,6 @@ export const Component = () => {const getTranslateStatus = (translateValue: string) => {const input = makeComponent(translateValue);const result = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: input,nodePath: lineColumnToNodePath(input, 7),componentIdentity: null,diff --git a/packages/studio-server/src/test/update-keyframes.test.ts b/packages/studio-server/src/test/update-keyframes.test.tsindex 87a19099e3..e0adfb0132 100644--- a/packages/studio-server/src/test/update-keyframes.test.ts+++ b/packages/studio-server/src/test/update-keyframes.test.ts@@ -64,7 +64,6 @@ export const Example: React.FC = () => {componentIdentity: null,keys: ['style.rotate'],effects: [],- videoConfigValues,});expect(status.props['style.rotate']).toMatchObject({status: 'keyframed',@@ -126,9 +125,13 @@ export const Example: React.FC = () => {componentIdentity: null,keys: ['style.scale'],effects: [],- videoConfigValues,});- expect(status.props['style.scale']).toMatchObject({+ expect(+ NoReactInternals.evaluateSourcePropStatuses(+ status.props,+ videoConfigValues,+ )['style.scale'],+ ).toMatchObject({status: 'keyframed',keyframeDisplayOffsetAdjustment: null,keyframes: [@@ -177,9 +180,13 @@ export const Example: React.FC = () => {componentIdentity: null,keys: ['style.opacity'],effects: [],- videoConfigValues,});- expect(status.props['style.opacity']).toMatchObject({+ expect(+ NoReactInternals.evaluateSourcePropStatuses(+ status.props,+ videoConfigValues,+ )['style.opacity'],+ ).toMatchObject({status: 'keyframed',keyframeDisplayOffsetAdjustment: null,keyframes: [@@ -223,9 +230,13 @@ export const Example: React.FC = () => {componentIdentity: null,keys: ['style.opacity'],effects: [],- videoConfigValues,});- expect(status.props['style.opacity']).toMatchObject({+ expect(+ NoReactInternals.evaluateSourcePropStatuses(+ status.props,+ videoConfigValues,+ )['style.opacity'],+ ).toMatchObject({status: 'keyframed',keyframeDisplayOffsetAdjustment: null,keyframes: [@@ -236,7 +247,7 @@ export const Example: React.FC = () => {frameExpression: {type: 'video-config-subtraction',identifier: 'durationInFrames',- minuend: 120,+ binding: {type: 'video-config', field: 'durationInFrames'},subtrahend: 2,},},@@ -711,7 +722,6 @@ export const Example: React.FC = () => {componentIdentity: null,keys: ['style.scale'],effects: [],- videoConfigValues: null,});expect(status.props['style.scale']).toMatchObject({status: 'keyframed',@@ -1310,7 +1320,6 @@ export const Example: React.FC = () => {expect(output).toContain('useCurrentFrame');expect(output).toContain('interpolate');const status = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: output,nodePath: updatedNodePath,componentIdentity: null,@@ -1487,7 +1496,6 @@ export default CenteredSolid;expect(output).toContain("extrapolateLeft: 'clamp'");expect(output).toContain("extrapolateRight: 'clamp'");const status = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: output,nodePath: updatedNodePath,componentIdentity: null,@@ -1757,7 +1765,6 @@ test('updateSequenceKeyframes converts the last keyframe to a static value', asyexpect(newValueStrings).toEqual(['320']);expect(output).toContain('scale: 320');const status = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: output,nodePath: updatedNodePath,componentIdentity: null,@@ -1999,7 +2006,6 @@ test('updateSequenceKeyframes converts the last color keyframe to a static valueexpect(newValueStrings).toEqual(["'blue'"]);expect(output).toContain("color={'blue'}");const status = computeSequencePropsStatusFromContent({- videoConfigValues: null,fileContents: output,nodePath: updatedNodePath,componentIdentity: null,diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.tsindex b4c0b0ac17..a8589c14ef 100644--- a/packages/studio-shared/src/api-requests.ts+++ b/packages/studio-shared/src/api-requests.ts@@ -19,6 +19,7 @@ import type {CanUpdateSequencePropsResponseFalse,CanUpdateSequencePropsResponseTrue,CanUpdateSequencePropStatus,+ CanUpdateSequencePropSource,ExtrapolateType,InteractivitySchema,InterpolateOutputOption,@@ -456,7 +457,6 @@ export type SubscribeToSequencePropsRequest = {assetKeys: string[];effects: string[][];clientId: string;- videoConfigValues: VideoConfigValues;};export type SubscribeToSequencePropsResponse =@@ -574,7 +574,7 @@ export type SaveSequencePropsRequest = {export type SaveSequencePropsResult = {fileName: string;nodePath: SequencePropsSubscriptionKey;- props: Record<string, CanUpdateSequencePropStatus>;+ props: Record<string, CanUpdateSequencePropSource>;};export type SaveSequencePropsResponse =diff --git a/packages/studio-shared/src/optimistic-add-keyframe.ts b/packages/studio-shared/src/optimistic-add-keyframe.tsindex c55a09fca6..dc3259a6c5 100644--- a/packages/studio-shared/src/optimistic-add-keyframe.ts+++ b/packages/studio-shared/src/optimistic-add-keyframe.ts@@ -1,3 +1,4 @@+import type {VideoConfigValues} from 'remotion';import {type CanUpdateSequencePropStatus,type CanUpdateSequencePropsResponse,@@ -13,6 +14,7 @@ import {isSchemaFieldHoldOnly,isSchemaFieldKeyframable,} from './keyframe-interpolation-function';+import {updateSourcePropStatus} from './update-source-prop-status';const getEasingIndexToDuplicate = ({insertedKeyframeIndex,@@ -177,12 +179,14 @@ const getMissingPropStatus = ({export const optimisticAddSequenceKeyframe = ({previous,+ videoConfigValues,fieldKey,frame,value,schema,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;fieldKey: string;frame: number;value: unknown;@@ -204,12 +208,17 @@ export const optimisticAddSequenceKeyframe = ({...previous,props: {...previous.props,- [fieldKey]: addKeyframeToPropStatus({- status,- fieldKey,- frame,- value,- schema: schema ?? null,+ [fieldKey]: updateSourcePropStatus({+ source: status,+ videoConfigValues,+ update: (evaluatedStatus) =>+ addKeyframeToPropStatus({+ status: evaluatedStatus,+ fieldKey,+ frame,+ value,+ schema: schema ?? null,+ }),}),},};@@ -217,6 +226,7 @@ export const optimisticAddSequenceKeyframe = ({export const optimisticAddEffectKeyframe = ({previous,+ videoConfigValues,effectIndex,fieldKey,frame,@@ -224,6 +234,7 @@ export const optimisticAddEffectKeyframe = ({schema,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;effectIndex: number;fieldKey: string;frame: number;@@ -258,12 +269,17 @@ export const optimisticAddEffectKeyframe = ({...target,props: {...target.props,- [fieldKey]: addKeyframeToPropStatus({- status,- fieldKey,- frame,- value,- schema: schema ?? null,+ [fieldKey]: updateSourcePropStatus({+ source: status,+ videoConfigValues,+ update: (evaluatedStatus) =>+ addKeyframeToPropStatus({+ status: evaluatedStatus,+ fieldKey,+ frame,+ value,+ schema: schema ?? null,+ }),}),},};diff --git a/packages/studio-shared/src/optimistic-delete-keyframe.ts b/packages/studio-shared/src/optimistic-delete-keyframe.tsindex 84856e8e21..696987567a 100644--- a/packages/studio-shared/src/optimistic-delete-keyframe.ts+++ b/packages/studio-shared/src/optimistic-delete-keyframe.ts@@ -1,7 +1,9 @@+import type {VideoConfigValues} from 'remotion';import {type CanUpdateSequencePropsResponse,type CanUpdateSequencePropStatus,} from 'remotion';+import {updateSourcePropStatus} from './update-source-prop-status';const getEasingIndexToRemove = ({removedKeyframeIndex,@@ -82,11 +84,13 @@ export const removeKeyframeFromPropStatus = ({export const optimisticDeleteSequenceKeyframe = ({previous,+ videoConfigValues,fieldKey,frame,valueWhenLastKeyframeDeleted,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;fieldKey: string;frame: number;valueWhenLastKeyframeDeleted?: unknown;@@ -104,10 +108,15 @@ export const optimisticDeleteSequenceKeyframe = ({...previous,props: {...previous.props,- [fieldKey]: removeKeyframeFromPropStatus({- status,- frame,- valueWhenLastKeyframeDeleted: valueWhenLastKeyframeDeleted ?? null,+ [fieldKey]: updateSourcePropStatus({+ source: status,+ videoConfigValues,+ update: (evaluatedStatus) =>+ removeKeyframeFromPropStatus({+ status: evaluatedStatus,+ frame,+ valueWhenLastKeyframeDeleted: valueWhenLastKeyframeDeleted ?? null,+ }),}),},};@@ -115,9 +124,11 @@ export const optimisticDeleteSequenceKeyframe = ({export const optimisticDeleteSequenceKeyframes = ({previous,+ videoConfigValues,keyframes,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;keyframes: {fieldKey: string;frame: number;@@ -128,6 +139,7 @@ export const optimisticDeleteSequenceKeyframes = ({(current, keyframe) =>optimisticDeleteSequenceKeyframe({previous: current,+ videoConfigValues,fieldKey: keyframe.fieldKey,frame: keyframe.frame,valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,@@ -138,12 +150,14 @@ export const optimisticDeleteSequenceKeyframes = ({export const optimisticDeleteEffectKeyframe = ({previous,+ videoConfigValues,effectIndex,fieldKey,frame,valueWhenLastKeyframeDeleted,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;effectIndex: number;fieldKey: string;frame: number;@@ -174,10 +188,15 @@ export const optimisticDeleteEffectKeyframe = ({...target,props: {...target.props,- [fieldKey]: removeKeyframeFromPropStatus({- status,- frame,- valueWhenLastKeyframeDeleted: valueWhenLastKeyframeDeleted ?? null,+ [fieldKey]: updateSourcePropStatus({+ source: status,+ videoConfigValues,+ update: (evaluatedStatus) =>+ removeKeyframeFromPropStatus({+ status: evaluatedStatus,+ frame,+ valueWhenLastKeyframeDeleted: valueWhenLastKeyframeDeleted ?? null,+ }),}),},};@@ -193,9 +212,11 @@ export const optimisticDeleteEffectKeyframe = ({export const optimisticDeleteEffectKeyframes = ({previous,+ videoConfigValues,keyframes,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;keyframes: {effectIndex: number;fieldKey: string;@@ -207,6 +228,7 @@ export const optimisticDeleteEffectKeyframes = ({(current, keyframe) =>optimisticDeleteEffectKeyframe({previous: current,+ videoConfigValues,effectIndex: keyframe.effectIndex,fieldKey: keyframe.fieldKey,frame: keyframe.frame,diff --git a/packages/studio-shared/src/optimistic-move-keyframe.ts b/packages/studio-shared/src/optimistic-move-keyframe.tsindex 68db71f812..77f8a60e8f 100644--- a/packages/studio-shared/src/optimistic-move-keyframe.ts+++ b/packages/studio-shared/src/optimistic-move-keyframe.ts@@ -1,7 +1,9 @@+import type {VideoConfigValues} from 'remotion';import type {CanUpdateSequencePropsResponse,CanUpdateSequencePropStatus,} from 'remotion';+import {updateSourcePropStatus} from './update-source-prop-status';export type OptimisticKeyframeMove = {readonly fieldKey: string;@@ -163,9 +165,11 @@ export const moveKeyframesInPropStatus = ({export const optimisticMoveSequenceKeyframes = ({previous,+ videoConfigValues,keyframes,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;keyframes: readonly OptimisticKeyframeMove[];}): CanUpdateSequencePropsResponse => {if (!previous.canUpdate) {@@ -186,7 +190,12 @@ export const optimisticMoveSequenceKeyframes = ({continue;}- props[fieldKey] = moveKeyframesInPropStatus({status, moves});+ props[fieldKey] = updateSourcePropStatus({+ source: status,+ videoConfigValues,+ update: (evaluatedStatus) =>+ moveKeyframesInPropStatus({status: evaluatedStatus, moves}),+ });}return {@@ -197,9 +206,11 @@ export const optimisticMoveSequenceKeyframes = ({export const optimisticMoveEffectKeyframes = ({previous,+ videoConfigValues,keyframes,}: {previous: CanUpdateSequencePropsResponse;+ videoConfigValues: VideoConfigValues | null;keyframes: readonly (OptimisticKeyframeMove & {effectIndex: number})[];}): CanUpdateSequencePropsResponse => {if (!previous.canUpdate) {@@ -237,7 +248,12 @@ export const optimisticMoveEffectKeyframes = ({continue;}- props[fieldKey] = moveKeyframesInPropStatus({status, moves});+ props[fieldKey] = updateSourcePropStatus({+ source: status,+ videoConfigValues,+ update: (evaluatedStatus) =>+ moveKeyframesInPropStatus({status: evaluatedStatus, moves}),+ });}return {diff --git a/packages/studio-shared/src/optimistic-update-for-effect-prop-statuses.ts b/packages/studio-shared/src/optimistic-update-for-effect-prop-statuses.tsindex ab23e87dd3..c7bf85afff 100644--- a/packages/studio-shared/src/optimistic-update-for-effect-prop-statuses.ts+++ b/packages/studio-shared/src/optimistic-update-for-effect-prop-statuses.ts@@ -1,7 +1,7 @@import {type CanUpdateEffectPropsResponse,type CanUpdateSequencePropsResponse,- type CanUpdateSequencePropStatus,+ type CanUpdateSequencePropSource,type InteractivitySchema,} from 'remotion';import {NoReactInternals} from 'remotion/no-react';@@ -35,7 +35,7 @@ export const optimisticUpdateForEffectPropStatuses = ({return previous;}- const props: Record<string, CanUpdateSequencePropStatus> = {+ const props: Record<string, CanUpdateSequencePropSource> = {...target.props,[fieldKey]: {status: 'static',diff --git a/packages/studio-shared/src/optimistic-update-for-prop-statuses.ts b/packages/studio-shared/src/optimistic-update-for-prop-statuses.tsindex 5b18d0862a..60ac30889a 100644--- a/packages/studio-shared/src/optimistic-update-for-prop-statuses.ts+++ b/packages/studio-shared/src/optimistic-update-for-prop-statuses.ts@@ -1,6 +1,6 @@import {type CanUpdateSequencePropsResponse,- type CanUpdateSequencePropStatus,+ type CanUpdateSequencePropSource,type InteractivitySchema,} from 'remotion';import {NoReactInternals} from 'remotion/no-react';@@ -28,7 +28,7 @@ export const optimisticUpdateForPropStatuses = ({? undefined: value;- const props: Record<string, CanUpdateSequencePropStatus> = {+ const props: Record<string, CanUpdateSequencePropSource> = {...previous.props,[fieldKey]: {status: 'static',diff --git a/packages/studio-shared/src/optimistic-update-keyframe-settings.ts b/packages/studio-shared/src/optimistic-update-keyframe-settings.tsindex 9d6a4b784c..dc5244c089 100644--- a/packages/studio-shared/src/optimistic-update-keyframe-settings.ts+++ b/packages/studio-shared/src/optimistic-update-keyframe-settings.ts@@ -35,10 +35,10 @@ const updateEasing = ({};/** The keyframed status of a prop after an easing or settings update. */-export const applyKeyframeSettingsToStatus = (- status: CanUpdateSequencePropStatusKeyframed,+export const applyKeyframeSettingsToStatus = <Numeric>(+ status: CanUpdateSequencePropStatusKeyframed<Numeric>,settings: KeyframeSettings,-): CanUpdateSequencePropStatusKeyframed => {+): CanUpdateSequencePropStatusKeyframed<Numeric> => {return {...status,...(settings.type === 'settings' && settings.clampingdiff --git a/packages/studio-shared/src/stringify-sequence-subscription-key.ts b/packages/studio-shared/src/stringify-sequence-subscription-key.tsindex e113e7e5bf..dcdc0e0f08 100644--- a/packages/studio-shared/src/stringify-sequence-subscription-key.ts+++ b/packages/studio-shared/src/stringify-sequence-subscription-key.ts@@ -1,14 +1,14 @@import type {SequencePropsSubscriptionKey} from 'remotion';export const stringifySequenceSubscriptionKey = (- key: SequencePropsSubscriptionKey,+ key: Omit<SequencePropsSubscriptionKey, 'videoConfigValues'>,): string => {return `${key.absolutePath}:${JSON.stringify(key.nodePath)}:${key.sequenceKeys.join('\0')}:${key.effectKeys.map((keys) => keys.join('\0')).join('\0\0')}`;};// deliberately not including effect keys, keeping expanded if changing effectsexport const stringifySequenceExpandedRowKey = (- key: SequencePropsSubscriptionKey,+ key: Omit<SequencePropsSubscriptionKey, 'videoConfigValues'>,): string => {return `${key.absolutePath}:${JSON.stringify(key.nodePath)}:${key.sequenceKeys.join('\0')}`;};diff --git a/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-add-keyframe.test.tsindex 914326f11d..c23b97163b 100644--- a/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts+++ b/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts@@ -22,6 +22,7 @@ test('optimisticAddSequenceKeyframe converts a static prop to a single keyframe'};const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'opacity',frame: 25,@@ -58,6 +59,7 @@ test('optimisticAddSequenceKeyframe adds a missing prop before keyframing it', (} satisfies InteractivitySchema;const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'opacity',frame: 25,@@ -98,6 +100,7 @@ test('optimisticAddSequenceKeyframe uses interpolate for translate fields', () =} satisfies InteractivitySchema;const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'style.translate',frame: 44,@@ -139,6 +142,7 @@ test('optimisticAddSequenceKeyframe uses interpolate for rotation-css fields', (} satisfies InteractivitySchema;const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'style.rotate',frame: 44,@@ -182,6 +186,7 @@ test('optimisticAddSequenceKeyframe ignores non-keyframable fields', () => {} satisfies InteractivitySchema;const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'playbackRate',frame: 25,@@ -216,6 +221,7 @@ test('optimisticAddSequenceKeyframe ignores enum fields', () => {} satisfies InteractivitySchema;const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'layout',frame: 25,@@ -250,6 +256,7 @@ test('optimisticAddSequenceKeyframe uses hold easing for enabled enum fields', (effects: [],};const withFirstKeyframe = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous: initial,fieldKey: 'cursor',frame: 0,@@ -257,6 +264,7 @@ test('optimisticAddSequenceKeyframe uses hold easing for enabled enum fields', (schema,});const withSecondKeyframe = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous: withFirstKeyframe,fieldKey: 'cursor',frame: 100,@@ -303,6 +311,7 @@ test('optimisticAddSequenceKeyframe appends a keyframe to an existing interpolat};const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'scale',frame: 30,@@ -352,6 +361,7 @@ test('optimisticAddSequenceKeyframe duplicates the easing for the split segment'};const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'scale',frame: 38,@@ -396,6 +406,7 @@ test('optimisticAddSequenceKeyframe uses linear easing outside the keyframe rang};const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'scale',frame: 90,@@ -439,6 +450,7 @@ test('optimisticAddSequenceKeyframe updates an existing keyframe at the same fra};const updated = optimisticAddSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'scale',frame: 60,@@ -488,6 +500,7 @@ test('optimisticAddEffectKeyframe appends a keyframe on the target effect', () =};const updated = optimisticAddEffectKeyframe({+ videoConfigValues: null,previous,effectIndex: 0,fieldKey: 'amount',@@ -537,6 +550,7 @@ test('optimisticAddEffectKeyframe converts a static prop to a single keyframe',};const updated = optimisticAddEffectKeyframe({+ videoConfigValues: null,previous,effectIndex: 0,fieldKey: 'amount',@@ -586,6 +600,7 @@ test('optimisticAddEffectKeyframe adds a missing prop before keyframing it', ()} satisfies InteractivitySchema;const updated = optimisticAddEffectKeyframe({+ videoConfigValues: null,previous,effectIndex: 0,fieldKey: 'startBlur',diff --git a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.tsindex 814f571998..aa9a960936 100644--- a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts+++ b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts@@ -30,6 +30,7 @@ test('optimisticDeleteSequenceKeyframe removes the matching keyframe and an easi};const updated = optimisticDeleteSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'style.opacity',frame: 30,@@ -79,6 +80,7 @@ test('optimisticDeleteSequenceKeyframe preserves the left segment easing when re};const updated = optimisticDeleteSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'style.opacity',frame: 38,@@ -118,6 +120,7 @@ test('optimisticDeleteSequenceKeyframe converts the last keyframe to a static va};const updated = optimisticDeleteSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'width',frame: 12,@@ -153,6 +156,7 @@ test('optimisticDeleteSequenceKeyframe is a no-op when no keyframe matches', ()};const updated = optimisticDeleteSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'style.opacity',frame: 99,@@ -170,6 +174,7 @@ test('optimisticDeleteSequenceKeyframe is a no-op when sequence is not updateabl};const result = optimisticDeleteSequenceKeyframe({+ videoConfigValues: null,previous,fieldKey: 'style.opacity',frame: 0,@@ -201,6 +206,7 @@ test('optimisticDeleteSequenceKeyframes deletes multiple keyframes in one pass',};const updated = optimisticDeleteSequenceKeyframes({+ videoConfigValues: null,previous,keyframes: [{fieldKey: 'width', frame: 0},@@ -243,6 +249,7 @@ test('optimisticDeleteSequenceKeyframes uses the playhead value when deleting al};const updated = optimisticDeleteSequenceKeyframes({+ videoConfigValues: null,previous,keyframes: [{@@ -295,6 +302,7 @@ test('optimisticDeleteEffectKeyframe removes the matching keyframe on the target};const updated = optimisticDeleteEffectKeyframe({+ videoConfigValues: null,previous,effectIndex: 0,fieldKey: 'amount',@@ -346,6 +354,7 @@ test('optimisticDeleteEffectKeyframe converts the last keyframe on the target ef};const updated = optimisticDeleteEffectKeyframe({+ videoConfigValues: null,previous,effectIndex: 0,fieldKey: 'amount',@@ -376,6 +385,7 @@ test('optimisticDeleteEffectKeyframe is a no-op when effect index not found', ()};const result = optimisticDeleteEffectKeyframe({+ videoConfigValues: null,previous,effectIndex: 0,fieldKey: 'amount',@@ -416,6 +426,7 @@ test('optimisticDeleteEffectKeyframes deletes multiple keyframes in one pass', (};const updated = optimisticDeleteEffectKeyframes({+ videoConfigValues: null,previous,keyframes: [{effectIndex: 0, fieldKey: 'amount', frame: 0},@@ -471,6 +482,7 @@ test('optimisticDeleteEffectKeyframes uses the playhead value when deleting all};const updated = optimisticDeleteEffectKeyframes({+ videoConfigValues: null,previous,keyframes: [{diff --git a/packages/studio-shared/src/test/optimistic-move-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-move-keyframe.test.tsindex ffa17ddefb..153b8cf98b 100644--- a/packages/studio-shared/src/test/optimistic-move-keyframe.test.ts+++ b/packages/studio-shared/src/test/optimistic-move-keyframe.test.ts@@ -6,7 +6,7 @@ import {optimisticMoveSequenceKeyframes,} from '../optimistic-move-keyframe';-const previous: CanUpdateSequencePropsResponse = {+const previous: CanUpdateSequencePropsResponse<number> = {canUpdate: true,props: {scale: {@@ -51,6 +51,7 @@ const previous: CanUpdateSequencePropsResponse = {test('optimisticMoveSequenceKeyframes moves multiple keyframes in one field', () => {const updated = optimisticMoveSequenceKeyframes({+ videoConfigValues: null,previous,keyframes: [{fieldKey: 'scale', fromFrame: 0, toFrame: 10},@@ -77,6 +78,7 @@ test('optimisticMoveSequenceKeyframes moves multiple keyframes in one field', ()test('optimisticMoveSequenceKeyframes resorts when moving past an adjacent keyframe', () => {const updated = optimisticMoveSequenceKeyframes({+ videoConfigValues: null,previous,keyframes: [{fieldKey: 'scale', fromFrame: 0, toFrame: 30}],});@@ -100,6 +102,7 @@ test('optimisticMoveSequenceKeyframes resorts when moving past an adjacent keyfrtest('optimisticMoveSequenceKeyframes replaces an existing keyframe', () => {const updated = optimisticMoveSequenceKeyframes({+ videoConfigValues: null,previous,keyframes: [{fieldKey: 'scale', fromFrame: 0, toFrame: 20}],});@@ -139,6 +142,7 @@ test('canMoveKeyframesWithoutCollisions allows moving onto a frame vacated by antest('optimisticMoveSequenceKeyframes allows moving keyframes before frame 0', () => {const updated = optimisticMoveSequenceKeyframes({+ videoConfigValues: null,previous,keyframes: [{fieldKey: 'scale', fromFrame: 0, toFrame: -12}],});@@ -161,6 +165,7 @@ test('optimisticMoveSequenceKeyframes allows moving keyframes before frame 0', (test('optimisticMoveEffectKeyframes moves effect keyframes', () => {const updated = optimisticMoveEffectKeyframes({+ videoConfigValues: null,previous,keyframes: [{effectIndex: 0, fieldKey: 'amount', fromFrame: 0, toFrame: 12},@@ -189,6 +194,7 @@ test('optimisticMoveEffectKeyframes moves effect keyframes', () => {test('optimisticMoveEffectKeyframes replaces an existing keyframe', () => {const updated = optimisticMoveEffectKeyframes({+ videoConfigValues: null,previous,keyframes: [{effectIndex: 0, fieldKey: 'amount', fromFrame: 0, toFrame: 20},@@ -215,6 +221,7 @@ test('optimisticMoveEffectKeyframes replaces an existing keyframe', () => {test('optimisticMoveEffectKeyframes allows moving keyframes beyond the sequence range', () => {const updated = optimisticMoveEffectKeyframes({+ videoConfigValues: null,previous,keyframes: [{effectIndex: 0, fieldKey: 'amount', fromFrame: 20, toFrame: 140},diff --git a/packages/studio-shared/src/update-source-prop-status.ts b/packages/studio-shared/src/update-source-prop-status.tsnew file mode 100644index 0000000000..e268aad5fd--- /dev/null+++ b/packages/studio-shared/src/update-source-prop-status.ts@@ -0,0 +1,56 @@+import type {+ CanUpdateSequencePropSource,+ CanUpdateSequencePropStatus,+ VideoConfigValues,+} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';++// Optimistic edits change only the edited values. Keep the other expressions so+// another mounted instance can still evaluate them in its own configuration.+export const updateSourcePropStatus = ({+ source,+ videoConfigValues,+ update,+}: {+ source: CanUpdateSequencePropSource;+ videoConfigValues: VideoConfigValues | null;+ update: (status: CanUpdateSequencePropStatus) => CanUpdateSequencePropStatus;+}): CanUpdateSequencePropSource => {+ const evaluated = NoReactInternals.evaluateSourcePropStatuses(+ {value: source},+ videoConfigValues,+ ).value;+ const next = update(evaluated);+ if (next === evaluated) return source;+ if (next.status === 'computed' || source.status === 'computed') return next;+ const timing = {+ keyframeDisplayOffsetAdjustment: source.keyframeDisplayOffsetAdjustment,+ ...(source.keyframePlaybackRateAdjustment === undefined+ ? {}+ : {+ keyframePlaybackRateAdjustment: source.keyframePlaybackRateAdjustment,+ }),+ };+ if (+ next.status !== 'keyframed' ||+ source.status !== 'keyframed' ||+ evaluated.status !== 'keyframed'+ ) {+ return {...next, ...timing};+ }++ return {+ ...next,+ ...timing,+ keyframes: next.keyframes.map((keyframe) => {+ const index = evaluated.keyframes.findIndex(+ (original) =>+ original.frame === keyframe.frame &&+ original.frameExpression === keyframe.frameExpression,+ );+ return index === -1+ ? keyframe+ : {...keyframe, frame: source.keyframes[index].frame};+ }),+ };+};diff --git a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsxindex 24ee1dc32d..9a380a6539 100644--- a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx+++ b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx@@ -185,7 +185,10 @@ export const KeyframeInspector: React.FC<{return null;}- const nodePath = selection.nodePathInfo.sequenceSubscriptionKey;+ const nodePath = {+ ...selection.nodePathInfo.sequenceSubscriptionKey,+ videoConfigValues: track.sequence.controls.videoConfigValues,+ };const {keyframeDisplayOffset, keyframePlaybackRate} = track;if (keyframeField.type === 'sequence') {diff --git a/packages/studio/src/components/Timeline/SubscribeToNodePaths.tsx b/packages/studio/src/components/Timeline/SubscribeToNodePaths.tsxindex 665d201ea9..c600ead67c 100644--- a/packages/studio/src/components/Timeline/SubscribeToNodePaths.tsx+++ b/packages/studio/src/components/Timeline/SubscribeToNodePaths.tsx@@ -3,7 +3,6 @@ import type {EffectDefinition,JsxComponentIdentity,InteractivitySchema,- VideoConfigValues,} from 'remotion';import {NoReactInternals} from 'remotion/no-react';import {useResolveStackAndReactToChange} from './use-resolved-stack-react-to-change';@@ -15,15 +14,7 @@ export const SubscribeToNodePaths: FC<{readonly schema: InteractivitySchema;readonly getStack: () => string | null;readonly effects: readonly EffectDefinition<unknown>[];- readonly videoConfigValues: VideoConfigValues | null;-}> = ({- overrideId,- componentIdentity,- schema,- getStack,- effects,- videoConfigValues,-}) => {+}> = ({overrideId, componentIdentity, schema, getStack, effects}) => {const {resolvedLocation, stack, preferMappedNodePath} =useResolveStackAndReactToChange(getStack, overrideId);@@ -43,7 +34,6 @@ export const SubscribeToNodePaths: FC<{originalLocation: resolvedLocation,preferMappedNodePath,stack,- videoConfigValues,});return null;diff --git a/packages/studio/src/components/Timeline/Timeline.tsx b/packages/studio/src/components/Timeline/Timeline.tsxindex bf1f3b9941..fbfbe638ef 100644--- a/packages/studio/src/components/Timeline/Timeline.tsx+++ b/packages/studio/src/components/Timeline/Timeline.tsx@@ -548,7 +548,6 @@ const TimelineInner: React.FC = () => {schema={sequence.controls.schema}getStack={sequence.getStack}effects={sequence.effects}- videoConfigValues={sequence.controls.videoConfigValues}/>);})}diff --git a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsxindex 66e136d79d..490c8786c0 100644--- a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx+++ b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx@@ -15,6 +15,7 @@ import {} from '@remotion/studio-shared';import type React from 'react';import {useContext, useEffect} from 'react';+import type {VideoConfigValues} from 'remotion';import {Internals,type OverrideIdToNodePaths,@@ -221,13 +222,16 @@ type CopyableEffectStatus = React.ContextType<const effectStatusToSnapshot = (effect: CopyableEffectStatus,+ videoConfigValues: VideoConfigValues | null,): EffectClipboardSnapshot | null => {if (effect.importPath === null) {return null;}const params: Record<string, EffectClipboardParam> = {};- for (const [key, prop] of Object.entries(effect.props)) {+ for (const [key, prop] of Object.entries(+ Internals.evaluateSourcePropStatuses(effect.props, videoConfigValues),+ )) {if (prop.status === 'static' && prop.codeValue === undefined) {continue;}@@ -289,7 +293,10 @@ export const getSnapshotsFromSelection = ({return null;}- const snapshot = effectStatusToSnapshot(effect);+ const snapshot = effectStatusToSnapshot(+ effect,+ selection.nodePathInfo.sequenceSubscriptionKey.videoConfigValues,+ );if (snapshot === null) {return null;}@@ -451,7 +458,10 @@ export const getEffectPropClipboardDataFromSelection = ({return null;}- const prop = effect.props[selection.key];+ const prop = Internals.evaluateSourcePropStatuses(+ effect.props,+ selection.nodePathInfo.sequenceSubscriptionKey.videoConfigValues,+ )[selection.key];if (!prop) {return null;}@@ -593,7 +603,10 @@ const getPasteEffectPropTargetForSelection = ({type: 'valid',target: {fileName: selection.nodePathInfo.sequenceSubscriptionKey.absolutePath,- nodePath: selection.nodePathInfo.sequenceSubscriptionKey,+ nodePath: {+ ...selection.nodePathInfo.sequenceSubscriptionKey,+ videoConfigValues: sequence.controls?.videoConfigValues ?? null,+ },effectIndex: target.effectIndex,fieldKey: target.fieldKey,defaultValue: getDefaultValue(fieldSchema),@@ -674,9 +687,29 @@ export const TimelineClipboardKeybindings: React.FC = () => {event: 'keydown',action: 'copyEffectsAndValues',callback: (e) => {- const {selectedItems} = currentSelection.current;const propStatuses = propStatusesRef.current;const sequences = sequencesRef.current;+ const selectedItems = currentSelection.current.selectedItems.map(+ (selection) => {+ if (selection.type === 'guide') return selection;++ const track = findTrackForNodePathInfo({+ sequences,+ overrideIdsToNodePaths: overrideIdToNodePathMappings,+ nodePathInfo: selection.nodePathInfo,+ });+ return track?.nodePathInfo+ ? {+ ...selection,+ nodePathInfo: {+ ...selection.nodePathInfo,+ sequenceSubscriptionKey:+ track.nodePathInfo.sequenceSubscriptionKey,+ },+ }+ : selection;+ },+ );if (selectedItems.length === 0) {return;}diff --git a/packages/studio/src/components/Timeline/call-add-keyframe.ts b/packages/studio/src/components/Timeline/call-add-keyframe.tsindex 32006b0ab5..6fa24100c9 100644--- a/packages/studio/src/components/Timeline/call-add-keyframe.ts+++ b/packages/studio/src/components/Timeline/call-add-keyframe.ts@@ -96,6 +96,7 @@ export const callAddSequenceKeyframe = ({setPropStatuses,applyOptimistic: (prev) =>optimisticAddSequenceKeyframe({+ videoConfigValues: nodePath.videoConfigValues,previous: prev,fieldKey,frame: sourceFrame,@@ -141,6 +142,7 @@ export const callAddKeyframes = ({keyframes.reduce((current, keyframe) =>optimisticAddSequenceKeyframe({+ videoConfigValues: keyframe.nodePath.videoConfigValues,previous: current,fieldKey: keyframe.fieldKey,frame: keyframe.sourceFrame,@@ -162,6 +164,7 @@ export const callAddKeyframes = ({keyframes.reduce((current, keyframe) =>optimisticAddEffectKeyframe({+ videoConfigValues: keyframe.nodePath.videoConfigValues,previous: current,effectIndex: keyframe.effectIndex,fieldKey: keyframe.fieldKey,@@ -222,6 +225,7 @@ export const callAddEffectKeyframe = ({setPropStatuses,applyOptimistic: (prev) =>optimisticAddEffectKeyframe({+ videoConfigValues: nodePath.videoConfigValues,previous: prev,effectIndex,fieldKey,diff --git a/packages/studio/src/components/Timeline/call-delete-keyframe.ts b/packages/studio/src/components/Timeline/call-delete-keyframe.tsindex 407bd80762..c0d001d0fe 100644--- a/packages/studio/src/components/Timeline/call-delete-keyframe.ts+++ b/packages/studio/src/components/Timeline/call-delete-keyframe.ts@@ -71,6 +71,7 @@ export const callDeleteSequenceKeyframe = ({setPropStatuses,applyOptimistic: (prev) =>optimisticDeleteSequenceKeyframe({+ videoConfigValues: nodePath.videoConfigValues,previous: prev,fieldKey,frame: sourceFrame,@@ -117,6 +118,7 @@ export const callDeleteEffectKeyframe = ({setPropStatuses,applyOptimistic: (prev) =>optimisticDeleteEffectKeyframe({+ videoConfigValues: nodePath.videoConfigValues,previous: prev,effectIndex,fieldKey,@@ -164,6 +166,7 @@ export const callDeleteKeyframes = ({setPropStatuses(firstKeyframe.nodePath, (prev) =>optimisticDeleteSequenceKeyframes({+ videoConfigValues: firstKeyframe.nodePath.videoConfigValues,previous: prev,keyframes: keyframes.map((keyframe) => ({fieldKey: keyframe.fieldKey,@@ -182,6 +185,7 @@ export const callDeleteKeyframes = ({setPropStatuses(firstKeyframe.nodePath, (prev) =>optimisticDeleteEffectKeyframes({+ videoConfigValues: firstKeyframe.nodePath.videoConfigValues,previous: prev,keyframes: keyframes.map((keyframe) => ({effectIndex: keyframe.effectIndex,diff --git a/packages/studio/src/components/Timeline/call-move-keyframe.ts b/packages/studio/src/components/Timeline/call-move-keyframe.tsindex d29724bb8e..4cbfb4ff7d 100644--- a/packages/studio/src/components/Timeline/call-move-keyframe.ts+++ b/packages/studio/src/components/Timeline/call-move-keyframe.ts@@ -4,7 +4,7 @@ import {type MoveKeyframesRequest,} from '@remotion/studio-shared';import type {- CanUpdateSequencePropStatus,+ CanUpdateSequencePropSource,InteractivitySchema,SequencePropsSubscriptionKey,} from 'remotion';@@ -55,7 +55,7 @@ const applyKeyframeDisplayOffsetAdjustmentDeltas = ({props,keyframes,}: {- readonly props: Record<string, CanUpdateSequencePropStatus>;+ readonly props: Record<string, CanUpdateSequencePropSource>;readonly keyframes: readonly MoveSequenceKeyframeChange[];}) => {const nextProps = {...props};@@ -81,7 +81,14 @@ const applyKeyframeDisplayOffsetAdjustmentDeltas = ({nextProps[fieldKey] = {...status,keyframeDisplayOffsetAdjustment:- status.keyframeDisplayOffsetAdjustment + delta,+ typeof status.keyframeDisplayOffsetAdjustment === 'number'+ ? status.keyframeDisplayOffsetAdjustment + delta+ : {+ type: 'binary',+ operator: '+',+ left: status.keyframeDisplayOffsetAdjustment,+ right: delta,+ },};}@@ -109,6 +116,7 @@ export const applyOptimisticKeyframeMoves = ({setPropStatuses(firstKeyframe.nodePath, (prev) => {const moved = optimisticMoveSequenceKeyframes({+ videoConfigValues: firstKeyframe.nodePath.videoConfigValues,previous: prev,keyframes: keyframes.map((keyframe) => ({fieldKey: keyframe.fieldKey,@@ -138,6 +146,7 @@ export const applyOptimisticKeyframeMoves = ({setPropStatuses(firstKeyframe.nodePath, (prev) => {const moved = optimisticMoveEffectKeyframes({+ videoConfigValues: firstKeyframe.nodePath.videoConfigValues,previous: prev,keyframes: keyframes.map((keyframe) => ({effectIndex: keyframe.effectIndex,diff --git a/packages/studio/src/components/Timeline/get-keyframed-sequence-drag-targets.ts b/packages/studio/src/components/Timeline/get-keyframed-sequence-drag-targets.tsindex e2a5ab88a8..b34fe6a8b2 100644--- a/packages/studio/src/components/Timeline/get-keyframed-sequence-drag-targets.ts+++ b/packages/studio/src/components/Timeline/get-keyframed-sequence-drag-targets.ts@@ -26,7 +26,7 @@ export type TimelineSequenceEffectKeyframeDragTarget =};export const getKeyframedSequenceDragTargets = ({- nodePath,+ nodePath: sourceNodePath,sequence,sequences,propStatuses,@@ -41,6 +41,10 @@ export const getKeyframedSequenceDragTargets = ({readonly effectKeyframes: TimelineSequenceEffectKeyframeDragTarget[];readonly sequenceKeyframes: TimelineSequenceKeyframeDragTarget[];} => {+ const nodePath = {+ ...sourceNodePath,+ videoConfigValues: sequence.controls?.videoConfigValues ?? null,+ };const status =propStatuses[Internals.makeSequencePropsSubscriptionKey(nodePath)];if (status === null || status === undefined || !status.canUpdate) {@@ -51,7 +55,12 @@ export const getKeyframedSequenceDragTargets = ({const sequenceKeyframes =sequenceSchema === undefined? []- : Object.entries(status.props).flatMap(([fieldKey, propStatus]) =>+ : Object.entries(+ Internals.evaluateSourcePropStatuses(+ status.props,+ sequence.controls?.videoConfigValues ?? null,+ ),+ ).flatMap(([fieldKey, propStatus]) =>propStatus.status === 'keyframed' &&(!isDescendant || propStatus.keyframeDisplayOffsetAdjustment !== null)? [@@ -80,25 +89,29 @@ export const getKeyframedSequenceDragTargets = ({return [];}- return Object.entries(effectStatus.props).flatMap(- ([fieldKey, propStatus]) =>- propStatus.status === 'keyframed' &&- (!isDescendant || propStatus.keyframeDisplayOffsetAdjustment !== null)- ? [- {- effectIndex: effectStatus.effectIndex,- parentPlaybackRate:- (propStatus.keyframePlaybackRateAdjustment ?? 1) *- getParentSequencePlaybackRate(sequence, sequences),- fileName: nodePath.absolutePath,- fieldKey,- isDescendant,- nodePath,- schema: effectSchema,- status: propStatus,- },- ]- : [],+ return Object.entries(+ Internals.evaluateSourcePropStatuses(+ effectStatus.props,+ sequence.controls?.videoConfigValues ?? null,+ ),+ ).flatMap(([fieldKey, propStatus]) =>+ propStatus.status === 'keyframed' &&+ (!isDescendant || propStatus.keyframeDisplayOffsetAdjustment !== null)+ ? [+ {+ effectIndex: effectStatus.effectIndex,+ parentPlaybackRate:+ (propStatus.keyframePlaybackRateAdjustment ?? 1) *+ getParentSequencePlaybackRate(sequence, sequences),+ fileName: nodePath.absolutePath,+ fieldKey,+ isDescendant,+ nodePath,+ schema: effectSchema,+ status: propStatus,+ },+ ]+ : [],);});diff --git a/packages/studio/src/components/Timeline/save-sequence-prop.ts b/packages/studio/src/components/Timeline/save-sequence-prop.tsindex 8cd844e3ce..ef4fb6da93 100644--- a/packages/studio/src/components/Timeline/save-sequence-prop.ts+++ b/packages/studio/src/components/Timeline/save-sequence-prop.ts@@ -181,6 +181,7 @@ export const saveSequenceProps = ({for (const keyframe of keyframesToAdd) {setPropStatuses(keyframe.nodePath, (prev) =>optimisticAddSequenceKeyframe({+ videoConfigValues: keyframe.nodePath.videoConfigValues,previous: prev,fieldKey: keyframe.fieldKey,frame: keyframe.sourceFrame,diff --git a/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts b/packages/studio/src/components/Timeline/sequence-props-subscription-store.tsindex 37e4177718..e168a29664 100644--- a/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts+++ b/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts@@ -3,7 +3,6 @@ import type {JsxComponentIdentity,SequenceNodePath,InteractivitySchema,- VideoConfigValues,} from 'remotion';import {Internals} from 'remotion';import {@@ -23,7 +22,7 @@ const makeKey = ({sequenceKeys,assetKeys,effectKeys,- videoConfigValues,+stack,}: {fileName: string;@@ -33,10 +32,10 @@ const makeKey = ({sequenceKeys: string[];assetKeys: string[];effectKeys: string[][];- videoConfigValues: VideoConfigValues;+stack: string | null;}): Key =>- `${fileName}\0${line}\0${column}\0${componentIdentity ?? ''}\0${sequenceKeys.join('\0')}\0${assetKeys.join('\0')}\0${effectKeys.map((keys) => keys.join('\0')).join('\0\0')}\0${JSON.stringify(videoConfigValues)}\0${stack ?? ''}`;+ `${fileName}\0${line}\0${column}\0${componentIdentity ?? ''}\0${sequenceKeys.join('\0')}\0${assetKeys.join('\0')}\0${effectKeys.map((keys) => keys.join('\0')).join('\0\0')}\0${stack ?? ''}`;type SubscribeResult = Awaited<ReturnType<typeof subscribeToSequenceProps>>;@@ -86,7 +85,7 @@ export const acquireSequencePropsSubscription = ({clientId,applyOnce,applyEach,- videoConfigValues,+stack,}: {fileName: string;@@ -99,7 +98,7 @@ export const acquireSequencePropsSubscription = ({clientId: string;applyOnce: ApplyResult;applyEach: ApplyResult;- videoConfigValues: VideoConfigValues;+stack: string | null;}): {release: () => void} => {const sequenceKeys = getAllSchemaKeys(schema);@@ -113,7 +112,7 @@ export const acquireSequencePropsSubscription = ({sequenceKeys,assetKeys,effectKeys,- videoConfigValues,+stack,});let entry = entries.get(key);@@ -129,7 +128,6 @@ export const acquireSequencePropsSubscription = ({assetKeys,effects: effectKeys,clientId,- videoConfigValues,});const created: Entry = {refCount: 0,diff --git a/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts b/packages/studio/src/components/Timeline/use-sequence-props-subscription.tsindex b250ecb50e..86250c2264 100644--- a/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts+++ b/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts@@ -7,7 +7,6 @@ import type {JsxComponentIdentity,SequencePropsSubscriptionKey,InteractivitySchema,- VideoConfigValues,} from 'remotion';import {Internals} from 'remotion';import type {OriginalPosition} from '../../error-overlay/react-overlay/utils/get-source-map';@@ -27,7 +26,6 @@ export const useSequencePropsSubscription = ({effects,preferMappedNodePath,stack,- videoConfigValues,}: {overrideId: string;componentIdentity: JsxComponentIdentity | null;@@ -36,7 +34,6 @@ export const useSequencePropsSubscription = ({originalLocation: OriginalPosition | null;preferMappedNodePath: boolean;stack: string | null;- videoConfigValues: VideoConfigValues | null;}) => {const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);const {setOverrideIdToNodePath} = useContext(@@ -94,8 +91,7 @@ export const useSequencePropsSubscription = ({!shouldSubscribeToSourceFile(locationSource) ||!locationLine ||locationColumn === null ||- !schema ||- videoConfigValues === null+ !schema) {return;}@@ -115,7 +111,7 @@ export const useSequencePropsSubscription = ({: null,clientId,stack,- videoConfigValues,+applyOnce: (result) => {if (!result.success) {return;@@ -171,6 +167,5 @@ export const useSequencePropsSubscription = ({setPropStatuses,setOverrideIdToNodePath,stack,- videoConfigValues,]);};diff --git a/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts b/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.tsindex e477876556..2974f8d632 100644--- a/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts+++ b/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts@@ -241,7 +241,10 @@ const getTimelineKeyframeDragTarget = ({return null;}- const nodePath = nodePathInfo.sequenceSubscriptionKey;+ const nodePath = {+ ...nodePathInfo.sequenceSubscriptionKey,+ videoConfigValues: sequence.controls.videoConfigValues,+ };const fileName = nodePath.absolutePath;const sequenceStatus = getCodeValueForTarget({propStatuses, nodePath});if (!sequenceStatus?.canUpdate) {@@ -257,7 +260,10 @@ const getTimelineKeyframeDragTarget = ({return null;}- const effectPropStatus = effectStatus.props[field.fieldKey];+ const effectPropStatus = Internals.evaluateSourcePropStatuses(+ effectStatus.props,+ nodePath.videoConfigValues,+ )[field.fieldKey];if (effectPropStatus?.status !== 'keyframed') {return null;}@@ -296,7 +302,10 @@ const getTimelineKeyframeDragTarget = ({};}- const sequencePropStatus = sequenceStatus.props[field.fieldKey];+ const sequencePropStatus = Internals.evaluateSourcePropStatuses(+ sequenceStatus.props,+ nodePath.videoConfigValues,+ )[field.fieldKey];if (sequencePropStatus?.status !== 'keyframed') {return null;}diff --git a/packages/studio/src/test/browser-studio-sequence-props.test.ts b/packages/studio/src/test/browser-studio-sequence-props.test.tsindex d283985d03..475505c069 100644--- a/packages/studio/src/test/browser-studio-sequence-props.test.ts+++ b/packages/studio/src/test/browser-studio-sequence-props.test.ts@@ -93,7 +93,6 @@ test('routes sequence prop operations through Browser Studio', async () => {assetKeys: [],effects: [],clientId: 'browser-studio',- videoConfigValues: nodePath.videoConfigValues,});expect(subscription.success).toBe(true);await saveSequenceProps({@@ -189,12 +188,6 @@ test('batches server sequence prop subscriptions into one request', async () =>assetKeys: [],effects: [],clientId: 'studio',- videoConfigValues: {- durationInFrames: 60,- fps: 30,- height: 720,- width: 1280,- },});try {diff --git a/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx b/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsxindex 9a6c0871cb..59442d4a93 100644--- a/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx+++ b/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx@@ -1,5 +1,7 @@"use client";+import { Internals } from "remotion";+import {getCanvasKeyframeSourceFrame,getCanvasKeyframeToggle,@@ -52,7 +54,7 @@ import {} from "./fields";type VisibleField = ReturnType<typeof getVisibleFields>[number];-type PropStatus = ReturnType<typeof getNodeProps>["props"][string];+type PropStatus = CanUpdateSequencePropStatus;const keyframeNavButtonClass ="text-muted-foreground-dim hover:text-foreground disabled:hover:text-muted-foreground-dim flex h-5 w-2 items-center justify-center disabled:opacity-30";@@ -580,21 +582,13 @@ export const LayerInspector: React.FC<{ readonly layer: Layer }> = ({let visible = getVisibleFields(schema);const keys = visible.map(({ key }) => key);- let props: ReturnType<typeof getNodeProps>["props"] | null = null;+ let props: Record<string, CanUpdateSequencePropStatus> | null = null;try {- props = getNodeProps({+ props = Internals.evaluateSourcePropStatuses(getNodeProps({project,node,keys,- videoConfig: composition- ? {- width: composition.width,- height: composition.height,- fps: composition.fps,- durationInFrames: composition.durationInFrames,- }- : undefined,- }).props;+ }).props, layer.track.sequence.controls?.videoConfigValues ?? composition ?? null);} catch {return { fields: visible, statuses: null };}@@ -611,11 +605,11 @@ export const LayerInspector: React.FC<{ readonly layer: Layer }> = ({if (variantFields.length > 0) {visible = [...visible, ...variantFields];try {- const extra = getNodeProps({+ const extra = Internals.evaluateSourcePropStatuses(getNodeProps({project,node,keys: variantFields.map((item) => item.key),- }).props;+ }).props, layer.track.sequence.controls?.videoConfigValues ?? composition ?? null);props = { ...props, ...extra };} catch {// Leave the variant fields without status.@@ -624,7 +618,7 @@ export const LayerInspector: React.FC<{ readonly layer: Layer }> = ({}return { fields: visible, statuses: props };- }, [composition, node, project, schema]);+ }, [composition, node, project, schema, layer.track.sequence.controls?.videoConfigValues]);const grouped = useMemo(() => {const groups = new Map<FieldGroup, VisibleField[]>();diff --git a/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx b/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsxindex a0dbe7d912..fa6cdb447a 100644--- a/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx+++ b/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx@@ -1,5 +1,7 @@"use client";+import { Internals } from "remotion";+import {canvasKeyframeEasingPresets,getCanvasSelectionItemKey,@@ -901,11 +903,11 @@ export const Timeline: React.FC = () => {let blocked: string | null = null;if (node) {try {- const { props } = getNodeProps({+ const props = Internals.evaluateSourcePropStatuses(getNodeProps({project,node,keys: ["from", "durationInFrames", "trimBefore"],- });+ }).props, sequence.controls?.videoConfigValues ?? null);const fromStatus = props.from;const durationStatus = props.durationInFrames;const trimBeforeStatus = props.trimBefore;diff --git a/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts b/packages/template-vibe-code/src/editor/hooks/use-editor-actions.tsindex a4637bccc9..5ea5f07e07 100644--- a/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts+++ b/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts@@ -355,18 +355,18 @@ export const useEditorActions = ({updateMultipleNodeProps({project: current,changes: staticChanges.map(- ({ node, schema, updates }): NodePropChange => ({+ ({ node, schema, updates, nodePathInfo }): NodePropChange => ({node,schema,updates,- videoConfig,+ videoConfig: nodePathInfo.sequenceSubscriptionKey.videoConfigValues ?? videoConfig,}),),}),);}- for (const { node, schema, keyframes } of nodeChanges.values()) {+ for (const { node, schema, keyframes, nodePathInfo } of nodeChanges.values()) {if (keyframes.length > 0) {collect(await updateNodeKeyframes({@@ -374,7 +374,7 @@ export const useEditorActions = ({node,updates: keyframes,schema,- videoConfig,+ videoConfig: nodePathInfo.sequenceSubscriptionKey.videoConfigValues ?? videoConfig,}),);}@@ -770,7 +770,7 @@ export const ${componentName}: React.FC = () => {node,updates,schema: schema ?? undefined,- videoConfig: {+ videoConfig: layer.track.sequence.controls?.videoConfigValues ?? {width: ref.current.compositionWidth,height: ref.current.compositionHeight,fps: ref.current.compositionFps,diff --git a/packages/template-vibe-code/src/editor/model/keyframes.ts b/packages/template-vibe-code/src/editor/model/keyframes.tsindex ae39cf9f19..0cb7a7bb1b 100644--- a/packages/template-vibe-code/src/editor/model/keyframes.ts+++ b/packages/template-vibe-code/src/editor/model/keyframes.ts@@ -1,3 +1,4 @@+import { Internals, type CanUpdateSequencePropStatus } from "remotion";import {getCanvasKeyframeEasingChange,getCanvasKeyframeEasingSegments,@@ -106,14 +107,13 @@ export const getKeyframedProps = ({}const fields = getVisibleFields(schema);- let props: ReturnType<typeof getNodeProps>["props"];+ let props: Record<string, CanUpdateSequencePropStatus>;try {- props = getNodeProps({+ props = Internals.evaluateSourcePropStatuses(getNodeProps({project,node,keys: fields.map(({ key }) => key),- videoConfig,- }).props;+ }).props, layer.track.sequence.controls?.videoConfigValues ?? videoConfig);} catch {return [];}diff --git a/packages/template-vibe-code/src/editor/model/layers.ts b/packages/template-vibe-code/src/editor/model/layers.tsindex 20f3a33a75..00c57d6bdd 100644--- a/packages/template-vibe-code/src/editor/model/layers.ts+++ b/packages/template-vibe-code/src/editor/model/layers.ts@@ -1,3 +1,4 @@+import { Internals } from "remotion";import {getCanvasSequenceNodePathInfo,getCanvasSequenceSourceLocation,@@ -94,7 +95,7 @@ export const resolveSequenceNodePaths = (nodePath: node.nodePath,sequenceKeys: [],effectKeys: [],- videoConfigValues: track.sequence.controls?.videoConfigValues ?? null,+ videoConfigValues: null,};}@@ -198,7 +199,7 @@ export const getSequencePropStatuses = ({}try {- return getNodeProps({ project, node, keys: [...keys], videoConfig }).props;+ return Internals.evaluateSourcePropStatuses(getNodeProps({ project, node, keys: [...keys] }).props, nodePathInfo.sequenceSubscriptionKey.videoConfigValues ?? videoConfig);} catch {return null;}diff --git a/packages/transitions/src/html-in-canvas-presentation.tsx b/packages/transitions/src/html-in-canvas-presentation.tsxindex 5f9b53e070..2bb9c0b1f4 100644--- a/packages/transitions/src/html-in-canvas-presentation.tsx+++ b/packages/transitions/src/html-in-canvas-presentation.tsx@@ -71,6 +71,7 @@ export const HtmlInCanvasPresentation = <const memoizedEffects = Internals.useMemoizedEffects({effects: effects ?? [],overrideId: null,+ videoConfigValues: null,});const effectsRef = useRef(memoizedEffects);