🎥 Make videos programmatically with React
`@remotion/codemods`: Use public editing APIs in Studio
Jonny Burger825f595d403e
diff --git a/packages/browser-studio/src/browser-studio-operations.ts b/packages/browser-studio/src/browser-studio-operations.tsindex efc53d23fc..6df84ad97f 100644--- a/packages/browser-studio/src/browser-studio-operations.ts+++ b/packages/browser-studio/src/browser-studio-operations.ts@@ -1,5 +1,33 @@import {CodemodsInternals,+ addComposition,+ addEffect as addEffectCodemod,+ addFolder,+ addSolid,+ deleteComposition,+ deleteEffects as deleteEffectsCodemod,+ deleteJsxNodes as deleteJsxNodesCodemod,+ detachAudio,+ duplicateComposition as duplicateCompositionCodemod,+ duplicateEffects as duplicateEffectsCodemod,+ duplicateJsxNodes as duplicateJsxNodesCodemod,+ getJsxNodeProps,+ moveComposition,+ moveFolder,+ renameComposition,+ renameFolder,+ reorderEffect as reorderEffectCodemod,+ reorderJsxNode,+ resolveCompositionComponent,+ setCompositionDefaultProps,+ splitSequences,+ unwrapFolder,+ updateCompositionMetadata,+ updateEffectKeyframes,+ updateEffectProps as updateEffectPropsCodemod,+ updateJsxNodeKeyframes,+ type CodemodNodeResult,+ type CompositionDestination,type EffectKeyframeUpdate,type SequenceKeyframeUpdate,} from '@remotion/codemods';@@ -39,15 +67,8 @@ import {saveSequencePropsInProject} from './save-sequence-props';import type {VirtualProject} from './types';const {- addEffect: addEffectCodemod,basicCaptionsElementSource,- computeSequencePropsStatusFromContent,computeSequencePropsSubscriptionFromContent,- deleteEffects: deleteEffectsCodemod,- deleteJsxNodes: deleteJsxNodesCodemod,- duplicateCompositionInSource,- duplicateEffects: duplicateEffectsCodemod,- duplicateJsxNodes: duplicateJsxNodesCodemod,findProjectFile,getBasicCaptionsElementFile,getCanUpdateDefaultPropsForProject,@@ -60,20 +81,10 @@ const {insertVideoLayers: insertVideoLayersCodemod,JsxElementIdentityMismatchError,JsxElementNotFoundAtLocationError,- makeInMemoryInsertJsxElementCodemodEnvironment,makeNewCompositionComponentSource,parseAndApplyCodemod,pasteEffects: pasteEffectsCodemod,- reorderEffect: reorderEffectCodemod,- reorderSequence: reorderSequenceCodemod,- resolveCompositionComponentWithFile,simpleDiff,- splitJsxSequences: splitJsxSequencesCodemod,- splitVideoFromAudio: splitVideoFromAudioCodemod,- updateDefaultProps: updateDefaultPropsCodemod,- updateEffectKeyframes,- updateEffectProps: updateEffectPropsCodemod,- updateSequenceKeyframes,} = CodemodsInternals;/*@@ -96,6 +107,19 @@ const formatCodemodFile = async ({contents}: {contents: string}) => ({}),});+const getNodePathMutationFiles = (result: CodemodNodeResult<VirtualProject>) =>+ [+ ...new Set([+ ...result.changes.map(({filePath}) => filePath),+ ...result.nodePathRemappings.map(({filePath}) => filePath),+ ]),+ ].map((absolutePath) => ({+ absolutePath,+ remappings: result.nodePathRemappings+ .filter(({filePath}) => filePath === absolutePath)+ .map(({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath})),+ }));+const getStructuredError = (error: unknown) => ({success: false as const,reason: error instanceof Error ? error.message : String(error),@@ -289,6 +313,163 @@ const resolveCodemodTargetFile = ({return findProjectFile({filePath: rootFile, project});};+const applyCompositionCodemod = ({+ project,+ compositionFile,+ codemod,+}: {+ project: VirtualProject;+ compositionFile: string;+ codemod: RecastCodemod;+}): VirtualProject => {+ const target = {project, compositionFile};+ switch (codemod.type) {+ case 'new-composition':+ if (codemod.canvasCapture !== null) {+ const {newContents} = parseAndApplyCodemod({+ input: project.files[compositionFile],+ codeMod: codemod,+ });+ return {+ ...project,+ files: {...project.files, [compositionFile]: newContents},+ };+ }++ return addComposition({+ ...target,+ compositionId: codemod.newId,+ component: {+ importName: codemod.componentName,+ importPath: codemod.componentImportPath,+ },+ metadata: {+ width: codemod.newWidth,+ height: codemod.newHeight,+ fps: codemod.newFps,+ durationInFrames: codemod.newDurationInFrames,+ },+ folder:+ codemod.folderName === null+ ? undefined+ : {name: codemod.folderName, parentName: codemod.parentName},+ }).project;+ case 'duplicate-composition':+ return duplicateCompositionCodemod({+ ...target,+ compositionId: codemod.idToDuplicate,+ newId: codemod.newId,+ tag: codemod.tag,+ metadata: {+ width: codemod.newWidth ?? undefined,+ height: codemod.newHeight ?? undefined,+ fps:+ codemod.tag === 'Still' ? undefined : (codemod.newFps ?? undefined),+ durationInFrames:+ codemod.tag === 'Still'+ ? undefined+ : (codemod.newDurationInFrames ?? undefined),+ },+ }).project;+ case 'rename-composition':+ return renameComposition({+ ...target,+ compositionId: codemod.idToRename,+ newId: codemod.newId,+ }).project;+ case 'delete-composition':+ return deleteComposition({...target, compositionId: codemod.idToDelete})+ .project;+ case 'update-composition-metadata':+ return updateCompositionMetadata({+ ...target,+ compositionId: codemod.idToUpdate,+ metadata: {+ width: codemod.newWidth ?? undefined,+ height: codemod.newHeight ?? undefined,+ fps: codemod.newFps ?? undefined,+ durationInFrames: codemod.newDurationInFrames ?? undefined,+ },+ }).project;+ case 'new-folder':+ return addFolder({+ ...target,+ folder: {name: codemod.folderName, parentName: codemod.parentName},+ }).project;+ case 'rename-folder':+ return renameFolder({+ ...target,+ folder: {name: codemod.folderName, parentName: codemod.parentName},+ newName: codemod.newName,+ }).project;+ case 'delete-folder':+ return unwrapFolder({+ ...target,+ folder: {name: codemod.folderName, parentName: codemod.parentName},+ }).project;+ case 'move-composition-to-folder':+ return moveComposition({+ ...target,+ compositionId: codemod.idToMove,+ destination:+ codemod.folderName === null+ ? {type: 'root'}+ : {+ type: 'folder',+ folder: {+ name: codemod.folderName,+ parentName: codemod.parentName,+ },+ },+ }).project;+ case 'move-composition-or-folder': {+ const destination: CompositionDestination =+ codemod.destination.type === 'folder'+ ? {+ type: 'folder',+ folder: {+ name: codemod.destination.folderName,+ parentName: codemod.destination.parentName,+ },+ }+ : codemod.destination.type === 'root'+ ? codemod.destination+ : {+ type: codemod.destination.type,+ target:+ codemod.destination.target.type === 'composition'+ ? codemod.destination.target+ : {+ type: 'folder',+ name: codemod.destination.target.folderName,+ parentName: codemod.destination.target.parentName,+ },+ };+ return codemod.source.type === 'composition'+ ? moveComposition({+ ...target,+ compositionId: codemod.source.compositionId,+ destination,+ }).project+ : moveFolder({+ ...target,+ folder: {+ name: codemod.source.folderName,+ parentName: codemod.source.parentName,+ },+ destination,+ }).project;+ }++ case 'apply-visual-control':+ throw new Error(+ 'Applying visual controls is not supported in Browser Studio',+ );+ default:+ throw new Error('Unsupported codemod');+ }+};+const getElementInstallPlanForProject = async ({destination,element,@@ -320,16 +501,13 @@ const getElementInstallPlanForProject = async ({const target =destination.type === 'current-composition'- ? await resolveCompositionComponentWithFile({+ ? resolveCompositionComponent({compositionFile: destination.compositionFile,compositionId: destination.compositionId,- environment: makeInMemoryInsertJsxElementCodemodEnvironment({- project,- svgMarkupToJsx,- }),+ project,}): null;- if (target !== null && !target.canAddSequence) {+ if (target !== null && !target.canAddContent) {throw new Error('Cannot insert Element into this composition component');}@@ -355,7 +533,7 @@ const getElementInstallPlanForProject = async ({project,});const elementSiblingFilePath =- target?.fileName ?? destinationCompositionFilePath;+ target?.filePath ?? destinationCompositionFilePath;const elementFilePath = `${dirname(elementSiblingFilePath)}/${elementFileName}`;if (elementFilePath === elementSiblingFilePath) {throw new Error('Element source file conflicts with the composition file');@@ -547,7 +725,7 @@ export const createBrowserStudioOperations = ({updates: mergeUpdates(mutation.updates),}));- const files = {...project.files};+ let nextProject = project;const appliedSequenceMutations: AppliedSequenceKeyframeMutation[] = [];const appliedEffectMutations: AppliedEffectKeyframeMutation[] = [];@@ -556,18 +734,18 @@ export const createBrowserStudioOperations = ({filePath: mutation.fileName,project,});- const result = await updateSequenceKeyframes({- input: files[absolutePath],- nodePath: mutation.nodePath.nodePath,+ const result = await updateJsxNodeKeyframes({+ project: nextProject,+ node: {filePath: absolutePath, nodePath: mutation.nodePath.nodePath},updates: mutation.updates,schema: mutation.schema,- videoConfigValues: mutation.nodePath.videoConfigValues,+ videoConfig: mutation.nodePath.videoConfigValues ?? undefined,});- files[absolutePath] = result.output;+ nextProject = result.project;appliedSequenceMutations.push({...mutation,absolutePath,- updatedNodePath: result.updatedNodePath,+ updatedNodePath: result.updatedNode.nodePath,});}@@ -577,23 +755,26 @@ export const createBrowserStudioOperations = ({project,});const result = await updateEffectKeyframes({- input: files[absolutePath],- sequenceNodePath: mutation.sequenceNodePath.nodePath,- effectIndex: mutation.effectIndex,+ project: nextProject,+ effect: {+ filePath: absolutePath,+ nodePath: mutation.sequenceNodePath.nodePath,+ effectIndex: mutation.effectIndex,+ },updates: mutation.updates,schema: mutation.schema,- videoConfigValues: mutation.sequenceNodePath.videoConfigValues,+ videoConfig: mutation.sequenceNodePath.videoConfigValues ?? undefined,});- files[absolutePath] = result.output;+ nextProject = result.project;appliedEffectMutations.push({...mutation,absolutePath,- updatedSequenceNodePath: result.updatedSequenceNodePath,+ updatedSequenceNodePath: result.updatedEffect.nodePath,});}return {- project: {...project, files},+ project: nextProject,appliedSequenceMutations,appliedEffectMutations,};@@ -631,13 +812,16 @@ export const createBrowserStudioOperations = ({mutation: AppliedSequenceKeyframeMutation;project: VirtualProject;}) => {- const status = computeSequencePropsStatusFromContent({- fileContents: project.files[mutation.absolutePath],- nodePath: mutation.updatedNodePath,+ const status = getJsxNodeProps({+ project,+ node: {+ filePath: mutation.absolutePath,+ nodePath: mutation.updatedNodePath,+ },componentIdentity: null,keys: getAllSchemaKeys(mutation.schema),- effects: [],- videoConfigValues: mutation.nodePath.videoConfigValues,+ effectKeys: [],+ videoConfig: mutation.nodePath.videoConfigValues ?? undefined,});const nodePath = {...mutation.nodePath,@@ -662,13 +846,16 @@ export const createBrowserStudioOperations = ({const effects = Array.from({length: mutation.effectIndex + 1}, (_, index) =>index === mutation.effectIndex ? getAllSchemaKeys(mutation.schema) : [],);- const status = computeSequencePropsStatusFromContent({- fileContents: project.files[mutation.absolutePath],- nodePath: mutation.updatedSequenceNodePath,+ const status = getJsxNodeProps({+ project,+ node: {+ filePath: mutation.absolutePath,+ nodePath: mutation.updatedSequenceNodePath,+ },componentIdentity: null,keys: [],- effects,- videoConfigValues: mutation.sequenceNodePath.videoConfigValues,+ effectKeys: effects,+ videoConfig: mutation.sequenceNodePath.videoConfigValues ?? undefined,});return (@@ -740,14 +927,14 @@ export const createBrowserStudioOperations = ({filePath: request.fileName,project,});- const nextStatus = computeSequencePropsStatusFromContent({- fileContents: project.files[absolutePath],- nodePath: result.nodePath.nodePath,+ const nextStatus = getJsxNodeProps({+ project,+ node: {filePath: absolutePath, nodePath: result.nodePath.nodePath},componentIdentity: request.componentIdentity,keys: request.keys,assetKeys: request.assetKeys,- effects: request.effects,- videoConfigValues: request.videoConfigValues,+ effectKeys: request.effects,+ videoConfig: request.videoConfigValues ?? undefined,});const nextEffectChain = nextStatus.effects.map((effect) => (effect.canUpdate ? effect.callee : false))@@ -823,15 +1010,15 @@ export const createBrowserStudioOperations = ({sequenceNodePath: SequencePropsSubscriptionKey;}) => {const absolutePath = findProjectFile({filePath: fileName, project});- const status = computeSequencePropsStatusFromContent({- fileContents: project.files[absolutePath],- nodePath: sequenceNodePath.nodePath,+ const status = getJsxNodeProps({+ project,+ node: {filePath: absolutePath, nodePath: sequenceNodePath.nodePath},componentIdentity: null,keys: [],- effects: Array.from({length: effectIndex + 1}, (_, index) =>+ effectKeys: Array.from({length: effectIndex + 1}, (_, index) =>index === effectIndex ? getAllSchemaKeys(schema) : [],),- videoConfigValues: sequenceNodePath.videoConfigValues,+ videoConfig: sequenceNodePath.videoConfigValues ?? undefined,});return (status.effects[effectIndex] ?? {@@ -863,21 +1050,21 @@ export const createBrowserStudioOperations = ({project,});const result = await addEffectCodemod({- effectConfig: request.effectConfig,- effectImportPath: request.effectImportPath,- effectName: request.effectName,- input: project.files[absolutePath],- sequenceNodePath: request.sequenceNodePath.nodePath,+ project,+ props: request.effectConfig,+ importPath: request.effectImportPath,+ importName: request.effectName,+ node: {+ filePath: absolutePath,+ nodePath: request.sequenceNodePath.nodePath,+ },});controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,fileName: absolutePath,nodePathMutationFiles: null,- mutate: () => ({- ...project,- files: {...project.files, [absolutePath]: result.output},- }),+ mutate: () => result.project,});return {success: true};} catch (error) {@@ -891,64 +1078,21 @@ export const createBrowserStudioOperations = ({}const project = getProject();- const groups = new Map<- string,- Array<- | {- type: 'single-effect';- effectIndex: number;- sequenceNodePath: SequenceNodePath;- }- | {type: 'all-effects'; sequenceNodePath: SequenceNodePath}- >- >();- for (const item of request) {- const absolutePath = findProjectFile({+ const result = await deleteEffectsCodemod({+ project,+ effects: request.map((item) => ({filePath: item.fileName,- project,- });- const group = groups.get(absolutePath) ?? [];- group.push(- item.type === 'single-effect'- ? {- type: 'single-effect',- effectIndex: item.effectIndex,- sequenceNodePath: item.sequenceNodePath.nodePath,- }- : {- type: 'all-effects',- sequenceNodePath: item.sequenceNodePath.nodePath,- },- );- groups.set(absolutePath, group);- }-- const updates = await Promise.all(- [...groups].map(async ([absolutePath, targets]) => ({- absolutePath,- result: await deleteEffectsCodemod({- effects: targets,- input: project.files[absolutePath],- }),+ nodePath: item.sequenceNodePath.nodePath,+ effectIndex:+ item.type === 'single-effect' ? item.effectIndex : null,})),- );+ });controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,- fileName: updates.map((update) => update.absolutePath).join(', '),+ fileName: result.changes.map(({filePath}) => filePath).join(', '),nodePathMutationFiles: null,- mutate: () => ({- ...project,- files: {- ...project.files,- ...Object.fromEntries(- updates.map((update) => [- update.absolutePath,- update.result.output,- ]),- ),- },- }),+ mutate: () => result.project,});return {success: true};} catch (error) {@@ -962,52 +1106,20 @@ export const createBrowserStudioOperations = ({}const project = getProject();- const groups = new Map<- string,- Array<{- effectIndex: number;- sequenceNodePath: SequenceNodePath;- }>- >();- for (const item of request) {- const absolutePath = findProjectFile({+ const result = await duplicateEffectsCodemod({+ project,+ effects: request.map((item) => ({filePath: item.fileName,- project,- });- const group = groups.get(absolutePath) ?? [];- group.push({+ nodePath: item.sequenceNodePath.nodePath,effectIndex: item.effectIndex,- sequenceNodePath: item.sequenceNodePath.nodePath,- });- groups.set(absolutePath, group);- }-- const updates = await Promise.all(- [...groups].map(async ([absolutePath, targets]) => ({- absolutePath,- result: await duplicateEffectsCodemod({- effects: targets,- input: project.files[absolutePath],- }),})),- );+ });controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,- fileName: updates.map((update) => update.absolutePath).join(', '),+ fileName: result.changes.map(({filePath}) => filePath).join(', '),nodePathMutationFiles: null,- mutate: () => ({- ...project,- files: {- ...project.files,- ...Object.fromEntries(- updates.map((update) => [- update.absolutePath,- update.result.output,- ]),- ),- },- }),+ mutate: () => result.project,});return {success: true};} catch (error) {@@ -1065,9 +1177,12 @@ export const createBrowserStudioOperations = ({project,});const result = await reorderEffectCodemod({- fromIndex: request.fromIndex,- input: project.files[absolutePath],- sequenceNodePath: request.sequenceNodePath.nodePath,+ project,+ effect: {+ filePath: absolutePath,+ nodePath: request.sequenceNodePath.nodePath,+ effectIndex: request.fromIndex,+ },toIndex: request.toIndex,});controller.applyMutation({@@ -1075,10 +1190,7 @@ export const createBrowserStudioOperations = ({timelineSelection: null,fileName: absolutePath,nodePathMutationFiles: null,- mutate: () => ({- ...project,- files: {...project.files, [absolutePath]: result.output},- }),+ mutate: () => result.project,});return {success: true};} catch (error) {@@ -1092,11 +1204,14 @@ export const createBrowserStudioOperations = ({project,});const result = await updateEffectPropsCodemod({- effectIndex: request.effectIndex,- input: project.files[absolutePath],+ project,+ effect: {+ filePath: absolutePath,+ nodePath: request.sequenceNodePath.nodePath,+ effectIndex: request.effectIndex,+ },schema: request.schema,- sequenceNodePath: request.sequenceNodePath.nodePath,- update:+ updates: [request.type === 'effect-param'? {defaultValue:@@ -1114,11 +1229,9 @@ export const createBrowserStudioOperations = ({key: request.key,value: JSON.parse(request.value),},+ ],});- const nextProject = {- ...project,- files: {...project.files, [absolutePath]: result.output},- };+ const nextProject = result.project;controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,@@ -1140,18 +1253,21 @@ export const createBrowserStudioOperations = ({}const project = getProject();- const outputByPath = new Map<string, string>();+ let nextProject = project;for (const edit of request.edits) {const absolutePath = findProjectFile({filePath: edit.fileName,project,});const result = await updateEffectPropsCodemod({- effectIndex: edit.effectIndex,- input: outputByPath.get(absolutePath) ?? project.files[absolutePath],+ project: nextProject,+ effect: {+ filePath: absolutePath,+ nodePath: edit.sequenceNodePath.nodePath,+ effectIndex: edit.effectIndex,+ },schema: edit.schema,- sequenceNodePath: edit.sequenceNodePath.nodePath,- update:+ updates: [edit.type === 'effect-param'? {defaultValue:@@ -1169,14 +1285,11 @@ export const createBrowserStudioOperations = ({key: edit.key,value: JSON.parse(edit.value),},+ ],});- outputByPath.set(absolutePath, result.output);+ nextProject = result.project;}- const nextProject = {- ...project,- files: {...project.files, ...Object.fromEntries(outputByPath)},- };controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,@@ -1250,47 +1363,19 @@ export const createBrowserStudioOperations = ({}const project = getProject();- const nodesByFile = new Map<- string,- (typeof nodes)[number]['nodePath'][]- >();- for (const node of nodes) {- const fileName = findProjectFile({+ const result = await deleteJsxNodesCodemod({+ project,+ nodes: nodes.map((node) => ({filePath: node.fileName,- project,- });- const fileNodes = nodesByFile.get(fileName) ?? [];- fileNodes.push(node.nodePath);- nodesByFile.set(fileName, fileNodes);- }-- const updates = await Promise.all(- [...nodesByFile].map(async ([fileName, nodePaths]) => ({- fileName,- result: await deleteJsxNodesCodemod({- input: project.files[fileName],- nodePaths,- }),+ nodePath: node.nodePath,})),- );- const nextProject = {- ...project,- files: {- ...project.files,- ...Object.fromEntries(- updates.map(({fileName, result}) => [fileName, result.output]),- ),- },- };+ });const nodePathMutation = controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,- fileName: updates.map(({fileName}) => fileName).join(', '),- mutate: () => nextProject,- nodePathMutationFiles: updates.map(({fileName, result}) => ({- absolutePath: fileName,- remappings: result.nodePathRemappings,- })),+ fileName: result.changes.map(({filePath}) => filePath).join(', '),+ mutate: () => result.project,+ nodePathMutationFiles: getNodePathMutationFiles(result),});if (nodePathMutation === null) {throw new Error('Could not delete JSX nodes');@@ -1315,47 +1400,19 @@ export const createBrowserStudioOperations = ({}const project = getProject();- const nodesByFile = new Map<- string,- (typeof nodes)[number]['nodePath'][]- >();- for (const node of nodes) {- const fileName = findProjectFile({+ const result = await duplicateJsxNodesCodemod({+ project,+ nodes: nodes.map((node) => ({filePath: node.fileName,- project,- });- const fileNodes = nodesByFile.get(fileName) ?? [];- fileNodes.push(node.nodePath);- nodesByFile.set(fileName, fileNodes);- }-- const updates = await Promise.all(- [...nodesByFile].map(async ([fileName, nodePaths]) => ({- fileName,- result: await duplicateJsxNodesCodemod({- input: project.files[fileName],- nodePaths,- }),+ nodePath: node.nodePath,})),- );- const nextProject = {- ...project,- files: {- ...project.files,- ...Object.fromEntries(- updates.map(({fileName, result}) => [fileName, result.output]),- ),- },- };+ });const nodePathMutation = controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,- fileName: updates.map(({fileName}) => fileName).join(', '),- mutate: () => nextProject,- nodePathMutationFiles: updates.map(({fileName, result}) => ({- absolutePath: fileName,- remappings: result.nodePathRemappings,- })),+ fileName: result.changes.map(({filePath}) => filePath).join(', '),+ mutate: () => result.project,+ nodePathMutationFiles: getNodePathMutationFiles(result),});if (nodePathMutation === null) {throw new Error('Could not duplicate JSX node');@@ -1376,55 +1433,20 @@ export const createBrowserStudioOperations = ({}const project = getProject();- const sequencesByFile = new Map<- string,- Array<{- nodePath: (typeof sequences)[number]['nodePath'];- sequenceKeys: string[];- splitFrame: number;- }>- >();- for (const sequence of sequences) {- const fileName = findProjectFile({- filePath: sequence.fileName,- project,- });- const fileSequences = sequencesByFile.get(fileName) ?? [];- fileSequences.push({- nodePath: sequence.nodePath,+ const result = await splitSequences({+ project,+ splits: sequences.map((sequence) => ({+ node: {filePath: sequence.fileName, nodePath: sequence.nodePath},+ frame: sequence.splitFrame,sequenceKeys: sequence.sequenceKeys,- splitFrame: sequence.splitFrame,- });- sequencesByFile.set(fileName, fileSequences);- }-- const updates = await Promise.all(- [...sequencesByFile].map(async ([fileName, splits]) => ({- fileName,- result: await splitJsxSequencesCodemod({- input: project.files[fileName],- splits,- }),})),- );- const nextProject = {- ...project,- files: {- ...project.files,- ...Object.fromEntries(- updates.map(({fileName, result}) => [fileName, result.output]),- ),- },- };+ });const nodePathMutation = controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,- fileName: updates.map(({fileName}) => fileName).join(', '),- mutate: () => nextProject,- nodePathMutationFiles: updates.map(({fileName, result}) => ({- absolutePath: fileName,- remappings: result.nodePathRemappings,- })),+ fileName: result.changes.map(({filePath}) => filePath).join(', '),+ mutate: () => result.project,+ nodePathMutationFiles: getNodePathMutationFiles(result),});if (nodePathMutation === null) {throw new Error('Could not split JSX sequence');@@ -1460,7 +1482,12 @@ export const createBrowserStudioOperations = ({symbolicatedStack,});const input = project.files[absolutePath];- const {newContents} = parseAndApplyCodemod({input, codeMod: codemod});+ const nextProject = applyCompositionCodemod({+ project,+ compositionFile: absolutePath,+ codemod,+ });+ const newContents = nextProject.files[absolutePath];const output =codemod.type === 'new-composition' ||codemod.type === 'duplicate-composition' ||@@ -1520,26 +1547,18 @@ export const createBrowserStudioOperations = ({filePath: fileName,project,});- const result = await reorderSequenceCodemod({- input: project.files[absolutePath],- sourceNodePath: sourceNodePath.nodePath,- targetNodePath: targetNodePath.nodePath,+ const result = await reorderJsxNode({+ project,+ node: {filePath: absolutePath, nodePath: sourceNodePath.nodePath},+ target: {filePath: absolutePath, nodePath: targetNodePath.nodePath},position,});const nodePathMutation = controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,fileName: absolutePath,- mutate: () => ({- ...project,- files: {...project.files, [absolutePath]: result.output},- }),- nodePathMutationFiles: [- {- absolutePath,- remappings: result.nodePathRemappings,- },- ],+ mutate: () => result.project,+ nodePathMutationFiles: getNodePathMutationFiles(result),});if (nodePathMutation === null) {throw new Error('Could not reorder sequence');@@ -1820,10 +1839,12 @@ export const createBrowserStudioOperations = ({project,});const input = project.files[absolutePath];- const {newContents} = duplicateCompositionInSource({- input,+ const nextProject = applyCompositionCodemod({+ project,+ compositionFile: absolutePath,codemod,});+ const newContents = nextProject.files[absolutePath];const {output} = await formatCodemodFile({contents: newContents});const diff = simpleDiff({oldLines: input.split('\n'),@@ -1866,10 +1887,11 @@ export const createBrowserStudioOperations = ({filePath: compositionFile,project,});- const {output} = await updateDefaultPropsCodemod({- input: project.files[absolutePath],+ const result = await setCompositionDefaultProps({+ project,+ compositionFile: absolutePath,compositionId,- newDefaultProps: JSON.parse(defaultProps),+ defaultProps: JSON.parse(defaultProps),enumPaths,});controller.applyMutation({@@ -1877,10 +1899,7 @@ export const createBrowserStudioOperations = ({timelineSelection: null,fileName: absolutePath,nodePathMutationFiles: null,- mutate: () => ({- ...project,- files: {...project.files, [absolutePath]: output},- }),+ mutate: () => result.project,});return {success: true};@@ -1898,24 +1917,16 @@ export const createBrowserStudioOperations = ({try {const project = getProject();const absolutePath = findProjectFile({filePath: fileName, project});- const result = await splitVideoFromAudioCodemod({- input: project.files[absolutePath],- nodePath,+ const result = await detachAudio({+ project,+ node: {filePath: absolutePath, nodePath},});const nodePathMutation = controller.applyMutation({undoRedoNavigation: null,timelineSelection: null,fileName: absolutePath,- mutate: () => ({- ...project,- files: {...project.files, [absolutePath]: result.output},- }),- nodePathMutationFiles: [- {- absolutePath,- remappings: result.nodePathRemappings,- },- ],+ mutate: () => result.project,+ nodePathMutationFiles: getNodePathMutationFiles(result),});if (nodePathMutation === null) {throw new Error('Could not split video from audio');@@ -2047,12 +2058,33 @@ export const createBrowserStudioOperations = ({dependencies: installedDependencies,project: getProject(),});- const result = await insertJsxElementIntoProjectWithNodePathRemappings({- project,- request,- svgMarkupToJsx,- wrapInSequence: null,- });+ const insertion =+ request.element.type === 'solid'+ ? addSolid({+ project,+ compositionId: request.compositionId,+ compositionFile: request.compositionFile,+ width: request.element.width,+ height: request.element.height,+ position: request.element.position ?? undefined,+ from: request.from ?? undefined,+ })+ : null;+ const result = insertion+ ? {+ project: insertion.project,+ filePath: insertion.insertedNode.filePath,+ insertedNodePath: insertion.insertedNode.nodePath,+ nodePathRemappings: insertion.nodePathRemappings.map(+ ({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath}),+ ),+ }+ : await insertJsxElementIntoProjectWithNodePathRemappings({+ project,+ request,+ svgMarkupToJsx,+ wrapInSequence: null,+ });const nodePathMutation = controller.applyMutation({undoRedoNavigation: null,timelineSelection:@@ -2186,11 +2218,12 @@ export const createBrowserStudioOperations = ({);}- const input = project.files[absolutePath];- const {newContents} = parseAndApplyCodemod({- input,- codeMod: request.newComposition.codemod,+ const compositionProject = applyCompositionCodemod({+ project,+ compositionFile: absolutePath,+ codemod: request.newComposition.codemod,});+ const newContents = compositionProject.files[absolutePath];const componentFilePath = `${dirname(absolutePath)}/${request.newComposition.codemod.componentName}.tsx`;if (project.files[componentFilePath] !== undefined) {throw new Error(diff --git a/packages/browser-studio/src/save-sequence-props.ts b/packages/browser-studio/src/save-sequence-props.tsindex 77b2fd9602..4a6a9a08e4 100644--- a/packages/browser-studio/src/save-sequence-props.ts+++ b/packages/browser-studio/src/save-sequence-props.ts@@ -1,6 +1,7 @@import {CodemodsInternals,- type SequencePropsNodeUpdate,+ getJsxNodeProps,+ updateMultipleJsxNodeProps,} from '@remotion/codemods';import type {SaveSequencePropEdit,@@ -12,12 +13,7 @@ import {getAllSchemaKeys, getAssetSchemaKeys} from '@remotion/studio-shared';import type {SequenceNodePath} from 'remotion';import type {VirtualProject} from './types';-const {- computeSequencePropsStatusFromContent,- findProjectFile,- updateInlineCaptionPatches,- updateMultipleSequenceProps,-} = CodemodsInternals;+const {findProjectFile, updateInlineCaptionPatches} = CodemodsInternals;const parseSequencePropEditValue = (value: SaveSequencePropEdit['value'],@@ -29,25 +25,6 @@ const parseSequencePropEditValue = (return JSON.parse(value.serialized);};-type FileMutation = {- edits: SaveSequencePropEdit[];- captionPatches: NonNullable<SaveSequencePropsRequest['captionPatches']>;-};--const getFileMutation = (- mutations: Map<string, FileMutation>,- absolutePath: string,-) => {- const existing = mutations.get(absolutePath);- if (existing) {- return existing;- }-- const created: FileMutation = {edits: [], captionPatches: []};- mutations.set(absolutePath, created);- return created;-};-const getStatusTargets = (request: SaveSequencePropsRequest) => {return [...new Map(@@ -76,13 +53,42 @@ export const saveSequencePropsInProject = ({throw new Error('No sequence prop edits to save');}- const mutations = new Map<string, FileMutation>();- for (const edit of request.edits) {- const absolutePath = findProjectFile({- filePath: edit.fileName,- project,- });- getFileMutation(mutations, absolutePath).edits.push(edit);+ const updateResult =+ request.edits.length > 0+ ? updateMultipleJsxNodeProps({+ project,+ changes: request.edits.map((edit) => ({+ node: {filePath: edit.fileName, nodePath: edit.nodePath.nodePath},+ updates: [+ {+ key: edit.key,+ value: parseSequencePropEditValue(edit.value),+ defaultValue:+ edit.defaultValue === null+ ? null+ : JSON.parse(edit.defaultValue),+ googleFont:+ edit.sourceEdit?.type === 'google-font'+ ? edit.sourceEdit.font+ : null,+ clipboardParam:+ edit.sourceEdit?.type === 'clipboard-param'+ ? edit.sourceEdit.param+ : null,+ },+ ],+ schema: edit.schema,+ videoConfig: edit.nodePath.videoConfigValues ?? undefined,+ })),+ })+ : null;+ const nextFiles = {...(updateResult?.project.files ?? project.files)};+ const updatedNodePaths = new Map<string, SequenceNodePath>();+ for (const [index, node] of (updateResult?.updatedNodes ?? []).entries()) {+ updatedNodePaths.set(+ `${node.filePath}:${JSON.stringify(request.edits[index].nodePath.nodePath)}`,+ node.nodePath,+ );}for (const captionPatch of request.captionPatches ?? []) {@@ -90,62 +96,11 @@ export const saveSequencePropsInProject = ({filePath: captionPatch.fileName,project,});- getFileMutation(mutations, absolutePath).captionPatches.push(captionPatch);- }-- const nextFiles = {...project.files};- const updatedNodePaths = new Map<string, SequenceNodePath>();- for (const [absolutePath, mutation] of mutations) {- let output = project.files[absolutePath];- if (output === undefined) {- throw new Error(`Could not find ${absolutePath}`);- }-- if (mutation.edits.length > 0) {- const changes: SequencePropsNodeUpdate[] = mutation.edits.map((edit) => ({- nodePath: edit.nodePath.nodePath,- updates: [- {- key: edit.key,- value: parseSequencePropEditValue(edit.value),- defaultValue:- edit.defaultValue === null ? null : JSON.parse(edit.defaultValue),- googleFont:- edit.sourceEdit?.type === 'google-font'- ? edit.sourceEdit.font- : null,- clipboardParam:- edit.sourceEdit?.type === 'clipboard-param'- ? edit.sourceEdit.param- : null,- },- ],- schema: edit.schema,- videoConfigValues: edit.nodePath.videoConfigValues,- }));- const updateResult = updateMultipleSequenceProps({- input: output,- changes,- });- output = updateResult.output;- for (const [index, result] of updateResult.results.entries()) {- const edit = mutation.edits[index];- updatedNodePaths.set(- `${absolutePath}:${JSON.stringify(edit.nodePath.nodePath)}`,- result.newNodePath,- );- }- }-- for (const captionPatch of mutation.captionPatches) {- output = updateInlineCaptionPatches({- input: output,- nodePath: captionPatch.nodePath.nodePath,- patches: captionPatch.patches,- }).output;- }-- nextFiles[absolutePath] = output;+ nextFiles[absolutePath] = updateInlineCaptionPatches({+ input: nextFiles[absolutePath],+ nodePath: captionPatch.nodePath.nodePath,+ patches: captionPatch.patches,+ }).output;}const nextProject = {...project, files: nextFiles};@@ -155,17 +110,20 @@ export const saveSequencePropsInProject = ({filePath: target.fileName,project: nextProject,});- const status = computeSequencePropsStatusFromContent({- fileContents: nextFiles[absolutePath],+ const status = getJsxNodeProps({+ project: nextProject,keys: getAllSchemaKeys(target.schema),assetKeys: getAssetSchemaKeys(target.schema),- nodePath:- updatedNodePaths.get(- `${absolutePath}:${JSON.stringify(target.nodePath.nodePath)}`,- ) ?? target.nodePath.nodePath,+ node: {+ filePath: absolutePath,+ nodePath:+ updatedNodePaths.get(+ `${absolutePath}:${JSON.stringify(target.nodePath.nodePath)}`,+ ) ?? target.nodePath.nodePath,+ },componentIdentity: null,- effects: [],- videoConfigValues: target.nodePath.videoConfigValues,+ 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 9129620b4a..b87a45a6e9 100644--- a/packages/browser-studio/src/test/browser-studio-operations.test.ts+++ b/packages/browser-studio/src/test/browser-studio-operations.test.ts@@ -1,5 +1,5 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';+import {addSolid, CodemodsInternals} from '@remotion/codemods';import {createElementPayload} from '@remotion/studio-protocol';import type {EventSourceEvent} from '@remotion/studio-shared';import type {InteractivitySchema} from 'remotion';@@ -8,30 +8,19 @@ import {createBrowserStudioOperations} from '../browser-studio-operations';import {createBlankTemplateProject} from '../templates/blank';import type {VirtualProject} from '../types';-const {- basicCaptionsElementSource,- insertSolidIntoProject,- insertSolidIntoProjectWithNodePathRemappings,-} = CodemodsInternals;+const {basicCaptionsElementSource} = CodemodsInternals;const insertSolid = (project: VirtualProject,compositionFile = '/project/src/Composition.tsx',) => {- return insertSolidIntoProject({+ return addSolid({project,- request: {- compositionFile,- compositionId: 'MyComp',- element: {- type: 'solid',- width: 1280,- height: 720,- position: null,- },- from: null,- },- });+ compositionFile,+ compositionId: 'MyComp',+ width: 1280,+ height: 720,+ }).project;};test('consumes an initial Element payload only once', () => {@@ -91,20 +80,15 @@ test('adds multiple Solids without duplicating the import', () => {test('adds a Solid at a timeline frame', () => {const project = createBlankTemplateProject();- const updated = insertSolidIntoProject({+ const updated = addSolid({project,- request: {- compositionFile: '/project/src/Composition.tsx',- compositionId: 'MyComp',- from: 42,- element: {- type: 'solid',- width: 1280,- height: 720,- position: {x: 100, y: 50},- },- },- });+ compositionFile: '/project/src/Composition.tsx',+ compositionId: 'MyComp',+ from: 42,+ width: 1280,+ height: 720,+ position: {x: 100, y: 50},+ }).project;const composition = updated.files['/project/src/Composition.tsx'];expect(composition).toContain('<Sequence from={42}');@@ -201,21 +185,13 @@ registerRoot(Root);`,},};- const {project: updated, nodePathRemappings} =- insertSolidIntoProjectWithNodePathRemappings({- project,- request: {- compositionFile: '/project/src/index.tsx',- compositionId: 'MyComp',- from: null,- element: {- type: 'solid',- width: 1280,- height: 720,- position: null,- },- },- });+ const {project: updated, nodePathRemappings} = addSolid({+ project,+ compositionFile: '/project/src/index.tsx',+ compositionId: 'MyComp',+ width: 1280,+ height: 720,+ });const output = updated.files['/project/src/index.tsx'];expect(output).toContain(@@ -2081,7 +2057,7 @@ export const Comp = () => (]),).toEqual({success: false,- reason: 'Cannot duplicate effect: not-found',+ reason: 'Effect index is out of range',stack: expect.any(String),});expect(diff --git a/packages/browser-studio/src/test/browser-studio-project-operations.test.ts b/packages/browser-studio/src/test/browser-studio-project-operations.test.tsindex e6246c91db..85325885e6 100644--- a/packages/browser-studio/src/test/browser-studio-project-operations.test.ts+++ b/packages/browser-studio/src/test/browser-studio-project-operations.test.ts@@ -393,6 +393,21 @@ test('previews and duplicates compositions as an undoable project mutation', asyexpect(project.files['/project/src/Composition.tsx']).toBe(initialProject.files['/project/src/Composition.tsx'],);++ const stillResult = await operations.duplicateComposition({+ ...request,+ codemod: {...request.codemod, newId: 'MyStill', tag: 'Still'},+ dryRun: false,+ });+ expect(stillResult.success).toBe(true);+ const stillSource =+ project.files['/project/src/Composition.tsx'].match(+ /<Still[\s\S]*?\/>/,+ )?.[0];+ expect(stillSource).toContain('id="MyStill"');+ expect(stillSource).toContain('width={1920}');+ expect(stillSource).not.toContain('fps=');+ expect(stillSource).not.toContain('durationInFrames=');});test('imports an Element with pinned Remotion dependencies as one undoable mutation', async () => {diff --git a/packages/codemods/src/add-effect.ts b/packages/codemods/src/add-effect.tsindex 8392d35407..2431a6d8b8 100644--- a/packages/codemods/src/add-effect.ts+++ b/packages/codemods/src/add-effect.ts@@ -25,13 +25,14 @@ export const addEffect = async <Project extends CodemodProject>({props = {},}: AddEffectOptions<Project>) => {const {filePath, input, length} = getEffectSource({project, node});- const {output} = await addEffectInSource({- input,- sequenceNodePath: node.nodePath,- effectName: importName,- effectImportPath: importPath,- effectConfig: props,- });+ const {output, formatted, effectLabel, nodeLabel, logLine} =+ await addEffectInSource({+ input,+ sequenceNodePath: node.nodePath,+ effectName: importName,+ effectImportPath: importPath,+ effectConfig: props,+ });const result = getNodeEditResult({project,edits: [@@ -44,6 +45,7 @@ export const addEffect = async <Project extends CodemodProject>({});return {...result,+ editDetails: [{filePath, formatted, effectLabel, nodeLabel, logLine}],insertedEffect: {...getUpdatedNodeReference({...result, node}),effectIndex: length,diff --git a/packages/codemods/src/codemod-value.ts b/packages/codemods/src/codemod-value.tsindex 5d7b1c742f..a474a75aa5 100644--- a/packages/codemods/src/codemod-value.ts+++ b/packages/codemods/src/codemod-value.ts@@ -3,5 +3,5 @@ export type CodemodValue =| number| boolean| null- | CodemodValue[]+ | readonly CodemodValue[]| {[key: string]: CodemodValue};diff --git a/packages/codemods/src/composition-editing.ts b/packages/codemods/src/composition-editing.tsindex c351fdfb64..9002b3be5a 100644--- a/packages/codemods/src/composition-editing.ts+++ b/packages/codemods/src/composition-editing.ts@@ -1,5 +1,4 @@import type {RecastCodemod} from '@remotion/studio-shared';-import * as recast from 'recast';import type {CodemodProject, CodemodResult} from './codemod-project';import {getCodemodResult} from './codemod-project';import {getJsxNodeProps} from './get-jsx-node-props';@@ -112,38 +111,6 @@ export const editCompositionProject = <Project extends CodemodProject>({codemod: RecastCodemod;}): CodemodResult<Project> => {const filePath = findProjectFile({project, filePath: compositionFile});- if (codemod.type === 'new-composition' || codemod.type === 'new-folder') {- const functions = new Set<object>();- recast.visit(parseAst(project.files[filePath]), {- visitNode(path) {- if (- !recast.types.namedTypes.JSXElement.check(path.node) &&- !recast.types.namedTypes.JSXFragment.check(path.node)- ) {- this.traverse(path);- return false;- }-- let parent = path.parentPath;- while (parent) {- if (recast.types.namedTypes.Function.check(parent.node)) {- functions.add(parent.node);- break;- }-- parent = parent.parentPath;- }-- this.traverse(path);- return false;- },- });- if (functions.size > 1) {- throw new Error(- 'Adding registrations requires a file with a single JSX component',- );- }- }const {newContents} = parseAndApplyCodemod({input: project.files[filePath],diff --git a/packages/codemods/src/delete-effects.ts b/packages/codemods/src/delete-effects.tsindex 1c28d395b5..fe3a76ccc0 100644--- a/packages/codemods/src/delete-effects.ts+++ b/packages/codemods/src/delete-effects.ts@@ -8,7 +8,10 @@ import {export type DeleteEffectsOptions<Project extends CodemodProject> = {project: Project;- effects: EffectReference[];+ effects: (+ | EffectReference+ | (Omit<EffectReference, 'effectIndex'> & {effectIndex: null})+ )[];};export const deleteEffects = async <Project extends CodemodProject>({@@ -19,20 +22,39 @@ export const deleteEffects = async <Project extends CodemodProject>({const edits = await Promise.all([...groups].map(async ([filePath, group]) => {const input = project.files[filePath];- const {output} = await deleteEffectsInSource({- input,- effects: group.map((effect) => ({- type: 'single-effect',- sequenceNodePath: effect.nodePath,- effectIndex: effect.effectIndex,- })),- });+ const {output, formatted, effectLabels, logLines} =+ await deleteEffectsInSource({+ input,+ effects: group.map((effect) =>+ effect.effectIndex === null+ ? {+ type: 'all-effects',+ sequenceNodePath: effect.nodePath,+ }+ : {+ type: 'single-effect',+ sequenceNodePath: effect.nodePath,+ effectIndex: effect.effectIndex,+ },+ ),+ });return {filePath,output,+ formatted,+ effectLabels,+ logLines,nodePathRemappings: getUnchangedStructureRemappings({input, output}),};}),);- return getNodeEditResult({project, edits});+ return {+ ...getNodeEditResult({project, edits}),+ editDetails: edits.map(({filePath, formatted, effectLabels, logLines}) => ({+ filePath,+ formatted,+ effectLabels,+ logLines,+ })),+ };};diff --git a/packages/codemods/src/delete-jsx-nodes.ts b/packages/codemods/src/delete-jsx-nodes.tsindex 8f6896e049..14038a2d8e 100644--- a/packages/codemods/src/delete-jsx-nodes.ts+++ b/packages/codemods/src/delete-jsx-nodes.ts@@ -15,7 +15,16 @@ export type DeleteJsxNodesOptions<Project extends CodemodProject> = {export const deleteJsxNodes = async <Project extends CodemodProject>({project,nodes,-}: DeleteJsxNodesOptions<Project>): Promise<CodemodNodeResult<Project>> => {+}: DeleteJsxNodesOptions<Project>): Promise<+ CodemodNodeResult<Project> & {+ editDetails: {+ filePath: string;+ formatted: boolean;+ nodeLabels: string[];+ logLines: number[];+ }[];+ }+> => {const groups = groupNodeReferencesByFile({project, nodes});const edits = await Promise.all([...groups].map(async ([filePath, nodePaths]) => ({@@ -26,5 +35,13 @@ export const deleteJsxNodes = async <Project extends CodemodProject>({})),})),);- return getNodeEditResult({project, edits});+ return {+ ...getNodeEditResult({project, edits}),+ editDetails: edits.map(({filePath, formatted, nodeLabels, logLines}) => ({+ filePath,+ formatted,+ nodeLabels,+ logLines,+ })),+ };};diff --git a/packages/codemods/src/detach-audio.ts b/packages/codemods/src/detach-audio.tsindex bda589d1ee..4e52c1962e 100644--- a/packages/codemods/src/detach-audio.ts+++ b/packages/codemods/src/detach-audio.ts@@ -44,6 +44,14 @@ export const detachAudio = async <Project extends CodemodProject>({return {...result,+ editDetails: [+ {+ filePath,+ formatted: edit.formatted,+ nodeLabel: edit.nodeLabel,+ logLine: edit.logLine,+ },+ ],insertedNode: {filePath, nodePath},updatedNode: getUpdatedNodeReference({...result, node}),};diff --git a/packages/codemods/src/duplicate-composition.ts b/packages/codemods/src/duplicate-composition.tsindex d92ba8c242..8a0e71f66c 100644--- a/packages/codemods/src/duplicate-composition.ts+++ b/packages/codemods/src/duplicate-composition.ts@@ -12,6 +12,7 @@ export type DuplicateCompositionOptions<Project extends CodemodProject> =CompositionTarget & {project: Project;newId: string;+ tag?: 'Composition' | 'Still';metadata?: Partial<CompositionMetadata>;};@@ -20,13 +21,15 @@ export const duplicateComposition = <Project extends CodemodProject>({compositionFile,compositionId,newId,+ tag,metadata = {},}: DuplicateCompositionOptions<Project>): CodemodResult<Project> => {const node = requireComposition({project, compositionFile, compositionId});assertNewCompositionId({project, compositionFile, compositionId: newId});validateMetadata(metadata);+ const newTag = tag ?? (node.tagName === 'Still' ? 'Still' : 'Composition');if (- node.tagName === 'Still' &&+ newTag === 'Still' &&(metadata.fps !== undefined || metadata.durationInFrames !== undefined)) {throw new Error('Still registrations do not have fps or durationInFrames');@@ -39,7 +42,7 @@ export const duplicateComposition = <Project extends CodemodProject>({type: 'duplicate-composition',idToDuplicate: compositionId,newId,- tag: node.tagName === 'Still' ? 'Still' : 'Composition',+ tag: newTag,newWidth: metadata.width ?? null,newHeight: metadata.height ?? null,newFps: metadata.fps ?? null,diff --git a/packages/codemods/src/duplicate-effects.ts b/packages/codemods/src/duplicate-effects.tsindex e850b950a4..38d22617b0 100644--- a/packages/codemods/src/duplicate-effects.ts+++ b/packages/codemods/src/duplicate-effects.ts@@ -1,6 +1,6 @@import type {CodemodProject} from './codemod-project';-import type {DeleteEffectsOptions} from './delete-effects';import {duplicateEffects as duplicateEffectsInSource} from './effect-operations';+import type {EffectReference} from './effect-references';import {groupEffects} from './effect-references';import {getNodeEditResult,@@ -8,8 +8,10 @@ import {getUpdatedNodeReference,} from './node-references';-export type DuplicateEffectsOptions<Project extends CodemodProject> =- DeleteEffectsOptions<Project>;+export type DuplicateEffectsOptions<Project extends CodemodProject> = {+ project: Project;+ effects: EffectReference[];+};export const duplicateEffects = async <Project extends CodemodProject>({project,@@ -19,16 +21,20 @@ export const duplicateEffects = async <Project extends CodemodProject>({const edits = await Promise.all([...groups].map(async ([filePath, group]) => {const input = project.files[filePath];- const {output} = await duplicateEffectsInSource({- input,- effects: group.map((effect) => ({- sequenceNodePath: effect.nodePath,- effectIndex: effect.effectIndex,- })),- });+ const {output, formatted, effectLabels, logLines} =+ await duplicateEffectsInSource({+ input,+ effects: group.map((effect) => ({+ sequenceNodePath: effect.nodePath,+ effectIndex: effect.effectIndex,+ })),+ });return {filePath,output,+ formatted,+ effectLabels,+ logLines,nodePathRemappings: getUnchangedStructureRemappings({input, output}),};}),@@ -36,6 +42,12 @@ export const duplicateEffects = async <Project extends CodemodProject>({const result = getNodeEditResult({project, edits});return {...result,+ editDetails: edits.map(({filePath, formatted, effectLabels, logLines}) => ({+ filePath,+ formatted,+ effectLabels,+ logLines,+ })),insertedEffects: [...groups.values()].flatMap((group) =>group.map((effect) => ({...getUpdatedNodeReference({...result, node: effect}),diff --git a/packages/codemods/src/duplicate-jsx-nodes.ts b/packages/codemods/src/duplicate-jsx-nodes.tsindex 01d2148e0c..539ed62de6 100644--- a/packages/codemods/src/duplicate-jsx-nodes.ts+++ b/packages/codemods/src/duplicate-jsx-nodes.ts@@ -16,6 +16,7 @@ export type DuplicateJsxNodesOptions<Project extends CodemodProject> = {export type DuplicateJsxNodesResult<Project extends CodemodProject> =CodemodNodeResult<Project> & {insertedNodes: JsxNodeReference[];+ editDetails: {filePath: string; nodeLabels: string[]; logLines: number[]}[];};export const duplicateJsxNodes = async <Project extends CodemodProject>({@@ -37,6 +38,11 @@ export const duplicateJsxNodes = async <Project extends CodemodProject>({const result = getNodeEditResult({project, edits});return {...result,+ editDetails: edits.map(({filePath, nodeLabels, logLines}) => ({+ filePath,+ nodeLabels,+ logLines,+ })),insertedNodes: getInsertedNodeReferences(result.nodePathRemappings),};};diff --git a/packages/codemods/src/effect-references.ts b/packages/codemods/src/effect-references.tsindex 8446fde9ac..163c0e1c2c 100644--- a/packages/codemods/src/effect-references.ts+++ b/packages/codemods/src/effect-references.ts@@ -28,7 +28,8 @@ export const getEffectSource = ({);if (lastSpread !== -1 &&- (attr === null || jsx.attributes.indexOf(attr) < lastSpread)+ attr !== null &&+ jsx.attributes.indexOf(attr) < lastSpread) {throw new Error('Cannot edit effects that may be overridden by a JSX spread',@@ -52,24 +53,27 @@ export const getEffectSource = ({return {filePath, input, length};};-export const groupEffects = ({+export const groupEffects = <+ Effect extends JsxNodeReference & {effectIndex: number | null},+>({project,effects,}: {project: CodemodProject;- effects: EffectReference[];+ effects: Effect[];}) => {if (effects.length === 0) {throw new Error('Expected at least one effect');}- const groups = new Map<string, EffectReference[]>();+ const groups = new Map<string, Effect[]>();for (const effect of effects) {const {filePath, length} = getEffectSource({project, node: effect});if (- !Number.isInteger(effect.effectIndex) ||- effect.effectIndex < 0 ||- effect.effectIndex >= length+ effect.effectIndex !== null &&+ (!Number.isInteger(effect.effectIndex) ||+ effect.effectIndex < 0 ||+ effect.effectIndex >= length)) {throw new Error('Effect index is out of range');}diff --git a/packages/codemods/src/get-jsx-elements-with-node-paths.ts b/packages/codemods/src/get-jsx-elements-with-node-paths.tsdeleted file mode 100644index 5449af2426..0000000000--- a/packages/codemods/src/get-jsx-elements-with-node-paths.ts+++ /dev/null@@ -1,40 +0,0 @@-import * as recast from 'recast';-import type {SequenceNodePath} from 'remotion';-import {getNodePathForRecastPath} from './sequence-props';-import {parseAst} from './sequence-props/parse-ast';--type JsxName =- | {type: 'JSXIdentifier'; name: string}- | {- type: 'JSXMemberExpression';- object: JsxName;- property: {name: string};- };--const jsxNameToString = (name: JsxName): string => {- if (name.type === 'JSXIdentifier') {- return name.name;- }-- return `${jsxNameToString(name.object)}.${name.property.name}`;-};--export const getJsxElementsWithNodePaths = ({source}: {source: string}) => {- const ast = parseAst(source);- const elements: {tagName: string; nodePath: SequenceNodePath}[] = [];- recast.visit(ast, {- visitJSXOpeningElement(path) {- const {name} = path.node;- if (name.type !== 'JSXNamespacedName') {- elements.push({- tagName: jsxNameToString(name as JsxName),- nodePath: getNodePathForRecastPath(path, ast),- });- }-- return this.traverse(path);- },- });-- return elements;-};diff --git a/packages/codemods/src/get-jsx-node-props.ts b/packages/codemods/src/get-jsx-node-props.tsindex b760f64c7d..66ccbec76c 100644--- a/packages/codemods/src/get-jsx-node-props.ts+++ b/packages/codemods/src/get-jsx-node-props.ts@@ -1,5 +1,6 @@import type {CanUpdateSequencePropsResponseTrue,+ JsxComponentIdentity,VideoConfigValues,} from 'remotion';import type {CodemodProject} from './codemod-project';@@ -17,12 +18,14 @@ export type GetJsxNodePropsOptions = {node: JsxNodeReference;keys: string[];effectKeys?: string[][];+ assetKeys?: string[];+ componentIdentity?: JsxComponentIdentity | null;videoConfig?: VideoConfigValues;};export type JsxNodeProps = Pick<CanUpdateSequencePropsResponseTrue,- 'props' | 'effects'+ 'canUpdate' | 'props' | 'effects'>;export const getJsxNodeProps = ({@@ -30,6 +33,8 @@ export const getJsxNodeProps = ({node,keys,effectKeys,+ assetKeys,+ componentIdentity,videoConfig,}: GetJsxNodePropsOptions): JsxNodeProps => {const filePath = findProjectFile({project, filePath: node.filePath});@@ -65,10 +70,11 @@ export const getJsxNodeProps = ({const result = computeSequencePropsStatusFromContent({fileContents: project.files[filePath],nodePath: node.nodePath,- componentIdentity: null,+ componentIdentity: componentIdentity ?? null,+ assetKeys,keys,effects,videoConfigValues: videoConfig ?? null,});- return {props: result.props, effects: result.effects};+ return result;};diff --git a/packages/codemods/src/index.ts b/packages/codemods/src/index.tsindex a134f140af..a5c4a48cc3 100644--- a/packages/codemods/src/index.ts+++ b/packages/codemods/src/index.ts@@ -1,74 +1,35 @@+import {applyVisualControl} from './apply-visual-control';import {- JsxElementIdentityMismatchError,- JsxElementNotFoundAtLocationError,- addEffect,- applyCodemod,- applyVisualControl,- assertValidEffect,basicCaptionsElementSource,+ getBasicCaptionsElementFile,+} from './basic-captions-element-source';+import {enumerateEffectArrayElements, pasteEffects} from './effect-operations';+import {findSearchPosition} from './find-search-position';+import {makeNewCompositionComponentSource} from './generate-canvas-capture-composition';+import {insertBasicCaptions} from './insert-basic-captions';+import {+ insertJsxElementIntoComposition,+ insertJsxElementIntoProjectWithNodePathRemappings,+ resolveCompositionComponent,+ resolveCompositionComponentWithFile,+} from './insert-jsx-element';+import {insertVideoLayers} from './insert-video-layers';+import {computeCanUpdateDefaultPropsFromContent,- computeSequencePropsStatusFromContent,- computeSequencePropsSubscriptionFromContent,- deleteEffect,- deleteEffects,- deleteJsxElementAtPath,- deleteJsxNodes,- duplicateCompositionInSource,- duplicateEffect,- duplicateEffects,- duplicateJsxElementAtPath,- duplicateJsxNodes,- ensureEffectImport,- ensureRemotionImports,- ensureUseCurrentFrameHook,- enumerateEffectArrayElements,- findEffectCallExpression,- findEffectsAttr,- findEnclosingFunctionPath,- findJsxElementPathForDeletion,findProjectFile,- findSearchPosition,- generateCanvasCaptureComposition,- getBasicCaptionsElementFile,getCanUpdateDefaultPropsForProject,getCompositionComponentInfo,- getCompositionDefaultPropsLine,getCompositionFile,getFolderFile,- getJsxElementTagLabel,- getJsxElementsWithNodePaths,getRootFileForProject,- insertBasicCaptions,- insertJsxElementIntoComposition,- insertJsxElementIntoProjectWithNodePathRemappings,- insertVideoLayers,- insertSolidIntoProject,- insertSolidIntoProjectWithNodePathRemappings,- insertSolidIntoSource,- makeConfigObjectExpression,- makeInMemoryInsertJsxElementCodemodEnvironment,- makeNewCompositionComponentSource,- parseAndApplyCodemod,- pasteEffects,- reorderEffect,- reorderSequence,- resolveCompositionComponent,- resolveCompositionComponentWithFile,- simpleDiff,- splitJsxSequence,- splitJsxSequences,- splitVideoFromAudio,- updateDefaultProps,- updateEffectKeyframes,- updateEffectKeyframesAst,- updateEffectProps,- updateEffectPropsAst,- updateInlineCaptionPatches,- updateMultipleSequenceProps,- updateSequenceKeyframes,- updateSequenceKeyframesAst,- updateSequencePropsAst,} from './internals';+import {parseAndApplyCodemod} from './parse-and-apply-codemod';+import {computeSequencePropsSubscriptionFromContent} from './sequence-props';+import {JsxElementIdentityMismatchError} from './sequence-props/jsx-component-identity';+import {JsxElementNotFoundAtLocationError} from './sequence-props/jsx-element-not-found-at-location-error';+import {simpleDiff} from './simple-diff';+import {updateDefaultProps} from './update-default-props';+import {updateInlineCaptionPatches} from './update-inline-caption-patches';export {addSolid, type AddSolidOptions, type AddSolidResult} from './add-solid';export {addMedia, type AddMediaOptions} from './add-media';@@ -87,6 +48,9 @@ export {} from './get-jsx-node-props';export {updateJsxNodeProps,+ updateMultipleJsxNodeProps,+ type JsxNodePropChange,+ type UpdateMultipleJsxNodePropsOptions,type UpdateJsxNodePropsOptions,} from './update-jsx-node-props';export {@@ -172,93 +136,57 @@ export {deleteJsxNodes, type DeleteJsxNodesOptions} from './delete-jsx-nodes';export type {EffectArrayElement,EffectDeletionTarget,- EffectKeyframeUpdate,EffectPropUpdate,EffectTarget,FormatEffectFile,+ PropDelta,+ UpdateEffectPropsResult,+} from './effect-operations';+export type {+ EffectKeyframeUpdate,FormatKeyframesFile,- InsertJsxElementCodemodEnvironment,IntroducedKeyframeIdentifiers,KeyframeOperation,- PropDelta,- RemovedProp,+ SequenceKeyframeUpdate,+} from './update-keyframes';+export type {+ InsertJsxElementCodemodEnvironment,ResolvedCompositionComponent,ResolvedCompositionComponentWithFile,- SequenceKeyframeUpdate,+} from './insert-jsx-element';+export type {+ RemovedProp,SequencePropUpdate,SequencePropsNodeUpdate,SequencePropsNodeUpdateResult,- UpdateEffectPropsResult,-} from './internals';+} from './update-sequence-props';export const CodemodsInternals = {JsxElementIdentityMismatchError,JsxElementNotFoundAtLocationError,- addEffect,- applyCodemod,applyVisualControl,- assertValidEffect,basicCaptionsElementSource,computeCanUpdateDefaultPropsFromContent,- computeSequencePropsStatusFromContent,computeSequencePropsSubscriptionFromContent,- deleteEffect,- deleteEffects,- deleteJsxElementAtPath,- deleteJsxNodes,- duplicateCompositionInSource,- duplicateEffect,- duplicateEffects,- duplicateJsxElementAtPath,- duplicateJsxNodes,- ensureEffectImport,- ensureRemotionImports,- ensureUseCurrentFrameHook,enumerateEffectArrayElements,- findEffectCallExpression,- findEffectsAttr,- findEnclosingFunctionPath,- findJsxElementPathForDeletion,findProjectFile,findSearchPosition,- generateCanvasCaptureComposition,getBasicCaptionsElementFile,getCanUpdateDefaultPropsForProject,getCompositionComponentInfo,- getCompositionDefaultPropsLine,getCompositionFile,getFolderFile,- getJsxElementTagLabel,- getJsxElementsWithNodePaths,getRootFileForProject,insertBasicCaptions,insertJsxElementIntoComposition,insertJsxElementIntoProjectWithNodePathRemappings,insertVideoLayers,- insertSolidIntoProject,- insertSolidIntoProjectWithNodePathRemappings,- insertSolidIntoSource,- makeConfigObjectExpression,- makeInMemoryInsertJsxElementCodemodEnvironment,makeNewCompositionComponentSource,parseAndApplyCodemod,pasteEffects,- reorderEffect,- reorderSequence,resolveCompositionComponent,resolveCompositionComponentWithFile,simpleDiff,- splitJsxSequence,- splitJsxSequences,- splitVideoFromAudio,updateDefaultProps,- updateEffectKeyframes,- updateEffectKeyframesAst,- updateEffectProps,- updateEffectPropsAst,updateInlineCaptionPatches,- updateMultipleSequenceProps,- updateSequenceKeyframes,- updateSequenceKeyframesAst,- updateSequencePropsAst,};diff --git a/packages/codemods/src/internals.ts b/packages/codemods/src/internals.tsindex a6c4601b45..fa169ae35b 100644--- a/packages/codemods/src/internals.ts+++ b/packages/codemods/src/internals.ts@@ -13,110 +13,6 @@ import {resolveCompositionComponentInProject} from './resolve-composition-componimport {getNodePathForRecastPath} from './sequence-props';import {parseAst} from './sequence-props/parse-ast';-export {applyVisualControl} from './apply-visual-control';-export {- basicCaptionsElementSource,- getBasicCaptionsElementFile,-} from './basic-captions-element-source';-export {- deleteJsxElementAtPath,- deleteJsxNodes,- findJsxElementPathForDeletion,- getJsxElementTagLabel,-} from './delete-jsx-nodes-internal';-export {duplicateCompositionInSource} from './duplicate-composition-in-source';-export {- duplicateJsxElementAtPath,- duplicateJsxNodes,-} from './duplicate-jsx-node';-export {- addEffect,- assertValidEffect,- deleteEffect,- deleteEffects,- duplicateEffect,- duplicateEffects,- ensureEffectImport,- enumerateEffectArrayElements,- findEffectCallExpression,- findEffectsAttr,- makeConfigObjectExpression,- pasteEffects,- reorderEffect,- updateEffectProps,- updateEffectPropsAst,- type EffectArrayElement,- type EffectDeletionTarget,- type EffectPropUpdate,- type EffectTarget,- type FormatEffectFile,- type PropDelta,- type UpdateEffectPropsResult,-} from './effect-operations';-export {- ensureRemotionImports,- ensureUseCurrentFrameHook,- findEnclosingFunctionPath,-} from './ensure-imports-and-frame-hook';-export {findSearchPosition} from './find-search-position';-export {- generateCanvasCaptureComposition,- makeNewCompositionComponentSource,-} from './generate-canvas-capture-composition';-export {getJsxElementsWithNodePaths} from './get-jsx-elements-with-node-paths';-export {insertBasicCaptions} from './insert-basic-captions';-export {insertVideoLayers} from './insert-video-layers';-export {- insertJsxElementIntoComposition,- insertJsxElementIntoProjectWithNodePathRemappings,- makeInMemoryInsertJsxElementCodemodEnvironment,- resolveCompositionComponent,- resolveCompositionComponentWithFile,- type InsertJsxElementCodemodEnvironment,- type ResolvedCompositionComponent,- type ResolvedCompositionComponentWithFile,-} from './insert-jsx-element';-export {parseAndApplyCodemod} from './parse-and-apply-codemod';-export {- applyCodemod,- type ApplyCodeModReturnType,- type Change,-} from './recast-mods';-export {reorderSequence} from './reorder-sequence';-export {- computeSequencePropsStatusFromContent,- computeSequencePropsSubscriptionFromContent,-} from './sequence-props';-export {JsxElementIdentityMismatchError} from './sequence-props/jsx-component-identity';-export {JsxElementNotFoundAtLocationError} from './sequence-props/jsx-element-not-found-at-location-error';-export {simpleDiff} from './simple-diff';-export {splitJsxSequence, splitJsxSequences} from './split-jsx-sequence';-export {splitVideoFromAudio} from './split-video-from-audio';-export {- getCompositionDefaultPropsLine,- updateDefaultProps,-} from './update-default-props';-export {updateInlineCaptionPatches} from './update-inline-caption-patches';-export {- updateEffectKeyframes,- updateEffectKeyframesAst,- updateSequenceKeyframes,- updateSequenceKeyframesAst,- type EffectKeyframeUpdate,- type FormatKeyframesFile,- type IntroducedKeyframeIdentifiers,- type KeyframeOperation,- type SequenceKeyframeUpdate,-} from './update-keyframes';-export {- updateMultipleSequenceProps,- updateSequencePropsAst,- type RemovedProp,- type SequencePropsNodeUpdate,- type SequencePropsNodeUpdateResult,- type SequencePropUpdate,-} from './update-sequence-props';-type AstNode = {type: string;start?: number | null;@@ -1102,17 +998,6 @@ export const insertSolidIntoProjectWithNodePathRemappings = <};};-export const insertSolidIntoProject = <Project extends CodemodProject>({- project,- request,-}: {- project: Project;- request: InsertJsxElementRequest;-}): Project => {- return insertSolidIntoProjectWithoutNodePathRemappings({project, request})- .project;-};-const relativeToRoot = (filePath: string, rootDir: string) => {const normalizedFile = normalizePath(filePath);const normalizedRoot = normalizePath(rootDir).replace(/\/$/, '');diff --git a/packages/codemods/src/recast-mods.ts b/packages/codemods/src/recast-mods.tsindex bcceb4fc59..4b1d194a01 100644--- a/packages/codemods/src/recast-mods.ts+++ b/packages/codemods/src/recast-mods.ts@@ -69,6 +69,100 @@ export const applyCodemod = ({});}+ if (+ (codeMod.type === 'new-composition' && codeMod.folderName === null) ||+ (codeMod.type === 'new-folder' && codeMod.parentName === null)+ ) {+ const functions = new Map<+ object,+ {path: recast.types.NodePath; hasRegistration: boolean}+ >();+ recast.visit(file, {+ visitNode(jsxPath) {+ const jsx = jsxPath.node;+ if (+ !recast.types.namedTypes.JSXElement.check(jsx) &&+ !recast.types.namedTypes.JSXFragment.check(jsx)+ ) {+ this.traverse(jsxPath);+ return false;+ }++ let parent = jsxPath.parentPath;+ while (parent) {+ if (recast.types.namedTypes.Function.check(parent.node)) {+ const existing = functions.get(parent.node);+ functions.set(parent.node, {+ path: parent,+ hasRegistration:+ existing?.hasRegistration === true ||+ (jsx.type === 'JSXElement' &&+ (getCompositionIdFromJSXElement(jsx as JSXElement) !== null ||+ getFolderNameFromJSXElement(jsx as JSXElement) !== null)),+ });+ break;+ }++ parent = parent.parentPath;+ }++ this.traverse(jsxPath);+ return false;+ },+ });+ const registered = [...functions.values()].filter(+ ({hasRegistration}) => hasRegistration,+ );+ const candidates =+ registered.length > 0 ? registered : [...functions.values()];+ if (candidates.length !== 1) {+ throw new Error(+ 'Adding registrations requires a single JSX component containing registrations, or a file with a single JSX component',+ );+ }++ const target = candidates[0].path;+ recast.visit(+ target.node as+ | FunctionDeclaration+ | FunctionExpression+ | ArrowFunctionExpression,+ {+ visitNode(rootPath) {+ const {node} = rootPath;+ if (+ recast.types.namedTypes.Function.check(node) &&+ node !== target.node+ ) {+ return false;+ }++ const key =+ node.type === 'ReturnStatement'+ ? 'argument'+ : node.type === 'ArrowFunctionExpression'+ ? 'body'+ : null;+ const root = key === null ? null : rootPath.get(key).node;+ if (root?.type === 'JSXElement' || root?.type === 'JSXFragment') {+ rootPath+ .get(key)+ .replace(+ codeMod.type === 'new-composition'+ ? addNewCompositionToRootJsx(root, codeMod, changesMade)+ : addNewFolderToRootJsx(root, codeMod, changesMade),+ );+ return false;+ }++ this.traverse(rootPath);+ return false;+ },+ },+ );+ return {newAst: file, changesMade};+ }+const body = file.program.body.map((node) => {return mapAll(node, codeMod, changesMade, null);});diff --git a/packages/codemods/src/reorder-effect.ts b/packages/codemods/src/reorder-effect.tsindex 91588a3333..a1e4a8080b 100644--- a/packages/codemods/src/reorder-effect.ts+++ b/packages/codemods/src/reorder-effect.ts@@ -28,12 +28,14 @@ export const reorderEffect = async <Project extends CodemodProject>({throw new Error('Effect index is out of range');}- const {output} = await reorderEffectInSource({- input,- sequenceNodePath: effect.nodePath,- fromIndex: effect.effectIndex,- toIndex,- });+ const {output, formatted, effectLabel, logLine} = await reorderEffectInSource(+ {+ input,+ sequenceNodePath: effect.nodePath,+ fromIndex: effect.effectIndex,+ toIndex,+ },+ );const result = getNodeEditResult({project,edits: [@@ -46,6 +48,7 @@ export const reorderEffect = async <Project extends CodemodProject>({});return {...result,+ editDetails: [{filePath, formatted, effectLabel, logLine}],updatedEffect: {...getUpdatedNodeReference({...result, node: effect}),effectIndex: toIndex,diff --git a/packages/codemods/src/reorder-jsx-node.ts b/packages/codemods/src/reorder-jsx-node.tsindex 274f154a74..bddc9d7772 100644--- a/packages/codemods/src/reorder-jsx-node.ts+++ b/packages/codemods/src/reorder-jsx-node.ts@@ -34,5 +34,16 @@ export const reorderJsxNode = async <Project extends CodemodProject>({position,});const result = getNodeEditResult({project, edits: [{filePath, ...edit}]});- return {...result, updatedNode: getUpdatedNodeReference({...result, node})};+ return {+ ...result,+ editDetails: [+ {+ filePath,+ formatted: edit.formatted,+ sequenceLabel: edit.sequenceLabel,+ logLine: edit.logLine,+ },+ ],+ updatedNode: getUpdatedNodeReference({...result, node}),+ };};diff --git a/packages/codemods/src/set-composition-default-props.ts b/packages/codemods/src/set-composition-default-props.tsindex b96ee666d8..ce5ddbef7d 100644--- a/packages/codemods/src/set-composition-default-props.ts+++ b/packages/codemods/src/set-composition-default-props.ts@@ -1,15 +1,26 @@+import type {EnumPath} from '@remotion/studio-shared';import type {CodemodProject} from './codemod-project';import type {CodemodValue} from './codemod-value';import {type CompositionTarget,requireComposition,} from './composition-editing';+import {+ getNodeEditResult,+ getUnchangedStructureRemappings,+ getUpdatedNodeReference,+} from './node-references';+import {+ getCompositionDefaultPropsLine,+ updateDefaultProps,+} from './update-default-props';import {updateJsxNodeProps} from './update-jsx-node-props';export type SetCompositionDefaultPropsOptions<Project extends CodemodProject> =CompositionTarget & {project: Project;defaultProps: Record<string, CodemodValue>;+ enumPaths?: EnumPath[];};export const setCompositionDefaultProps = <Project extends CodemodProject>({@@ -17,7 +28,34 @@ export const setCompositionDefaultProps = <Project extends CodemodProject>({compositionFile,compositionId,defaultProps,+ enumPaths,}: SetCompositionDefaultPropsOptions<Project>) => {const node = requireComposition({project, compositionFile, compositionId});- return updateJsxNodeProps({project, node, props: {defaultProps}});+ if (enumPaths === undefined) {+ return updateJsxNodeProps({project, node, props: {defaultProps}});+ }++ const input = project.files[node.filePath];+ const logLine = getCompositionDefaultPropsLine({input, compositionId});+ const {output} = updateDefaultProps({+ input,+ compositionId,+ newDefaultProps: defaultProps,+ enumPaths,+ });+ const result = getNodeEditResult({+ project,+ edits: [+ {+ filePath: node.filePath,+ output,+ nodePathRemappings: getUnchangedStructureRemappings({input, output}),+ },+ ],+ });+ return {+ ...result,+ logLine,+ updatedNode: getUpdatedNodeReference({...result, node}),+ };};diff --git a/packages/codemods/src/split-sequences.ts b/packages/codemods/src/split-sequences.tsindex 991f8e9506..bd1383a2e3 100644--- a/packages/codemods/src/split-sequences.ts+++ b/packages/codemods/src/split-sequences.ts@@ -12,7 +12,7 @@ import {splitJsxSequences} from './split-jsx-sequence';export type SplitSequencesOptions<Project extends CodemodProject> = {project: Project;- splits: {node: JsxNodeReference; frame: number}[];+ splits: {node: JsxNodeReference; frame: number; sequenceKeys?: string[]}[];};export const splitSequences = async <Project extends CodemodProject>({@@ -28,28 +28,32 @@ export const splitSequences = async <Project extends CodemodProject>({const groups = new Map<string, typeof splits>();for (const split of splits) {const filePath = findProjectFile({project, filePath: split.node.filePath});- const target = getJsxNodes({project, filePath}).find(- (node) =>- JSON.stringify(node.nodePath) === JSON.stringify(split.node.nodePath),- );- if (- !target?.componentIdentity ||- !/^dev\.remotion\.(remotion\.(Sequence|Video|OffthreadVideo|Audio|experimental_Video|experimental_Audio|Interactive\.[A-Za-z]+)|media\.(Video|Audio))$/.test(- target.componentIdentity,- )- ) {- throw new Error(- 'Only Remotion sequences, interactive elements, and timeline media can be split',+ if (split.sequenceKeys === undefined) {+ const target = getJsxNodes({project, filePath}).find(+ (node) =>+ JSON.stringify(node.nodePath) === JSON.stringify(split.node.nodePath),);- }+ if (+ !target?.componentIdentity ||+ !/^dev\.remotion\.(remotion\.(Sequence|Video|OffthreadVideo|Audio|experimental_Video|experimental_Audio|Interactive\.[A-Za-z]+)|media\.(Video|Audio))$/.test(+ target.componentIdentity,+ )+ ) {+ throw new Error(+ 'Only Remotion sequences, interactive elements, and timeline media can be split',+ );+ }- const status = getJsxNodeProps({- project,- node: split.node,- keys: ['from', 'durationInFrames', 'trimBefore'],- });- if (Object.values(status.props).some((prop) => prop.status !== 'static')) {- throw new Error('Sequence timing must be static to split it');+ const status = getJsxNodeProps({+ project,+ node: split.node,+ keys: ['from', 'durationInFrames', 'trimBefore'],+ });+ if (+ Object.values(status.props).some((prop) => prop.status !== 'static')+ ) {+ throw new Error('Sequence timing must be static to split it');+ }}const group = groups.get(filePath) ?? [];@@ -72,10 +76,14 @@ export const splitSequences = async <Project extends CodemodProject>({filePath,...(await splitJsxSequences({input: project.files[filePath],- splits: group.map(({node, frame}) => ({+ splits: group.map(({node, frame, sequenceKeys}) => ({nodePath: node.nodePath,splitFrame: frame,- sequenceKeys: ['from', 'durationInFrames', 'trimBefore'],+ sequenceKeys: sequenceKeys ?? [+ 'from',+ 'durationInFrames',+ 'trimBefore',+ ],})),})),})),@@ -83,6 +91,11 @@ export const splitSequences = async <Project extends CodemodProject>({const result = getNodeEditResult({project, edits});return {...result,+ editDetails: edits.map(({filePath, nodeLabels, logLines}) => ({+ filePath,+ nodeLabels,+ logLines,+ })),insertedNodes: getInsertedNodeReferences(result.nodePathRemappings),};};diff --git a/packages/studio-server/src/test/add-effect.test.ts b/packages/codemods/src/test/add-effect.test.tssimilarity index 96%rename from packages/studio-server/src/test/add-effect.test.tsrename to packages/codemods/src/test/add-effect.test.tsindex 634c1e734a..f9462f79bc 100644--- a/packages/studio-server/src/test/add-effect.test.ts+++ b/packages/codemods/src/test/add-effect.test.ts@@ -1,8 +1,6 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';-import {lineColumnToNodePath} from './test-utils';--const {addEffect} = CodemodsInternals;+import {addEffect} from '../effect-operations';+import {lineColumnToNodePath} from './node-path-test-utils';const buildInput = (jsx: string) => `import {Solid} from 'remotion';diff --git a/packages/codemods/src/test/default-props.test.ts b/packages/codemods/src/test/default-props.test.tsindex 1ac2d0cd10..eef96380c0 100644--- a/packages/codemods/src/test/default-props.test.ts+++ b/packages/codemods/src/test/default-props.test.ts@@ -1,7 +1,5 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '..';--const {computeCanUpdateDefaultPropsFromContent} = CodemodsInternals;+import {computeCanUpdateDefaultPropsFromContent} from '../internals';test('extracts editable default props including special values', () => {const source = `import {Composition, staticFile} from 'remotion';diff --git a/packages/studio-server/src/test/delete-effect.test.ts b/packages/codemods/src/test/delete-effect.test.tssimilarity index 95%rename from packages/studio-server/src/test/delete-effect.test.tsrename to packages/codemods/src/test/delete-effect.test.tsindex c5e0e04bb4..a83c86491c 100644--- a/packages/studio-server/src/test/delete-effect.test.ts+++ b/packages/codemods/src/test/delete-effect.test.ts@@ -1,8 +1,6 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';-import {lineColumnToNodePath} from './test-utils';--const {deleteEffect, deleteEffects} = CodemodsInternals;+import {deleteEffect, deleteEffects} from '../effect-operations';+import {lineColumnToNodePath} from './node-path-test-utils';const buildInput = (effects: string,diff --git a/packages/codemods/src/test/delete-jsx-nodes.test.ts b/packages/codemods/src/test/delete-jsx-nodes.test.tsnew file mode 100644index 0000000000..3e0b8d63ec--- /dev/null+++ b/packages/codemods/src/test/delete-jsx-nodes.test.ts@@ -0,0 +1,290 @@+import {expect, test} from 'bun:test';+import {deleteJsxNodes} from '../delete-jsx-nodes-internal';+import {+ lineColumnToNodePath,+ lineContainingToNodePath,+} from './node-path-test-utils';++const sample = `import React from 'react';+import {AbsoluteFill} from 'remotion';++export const X: React.FC = () => {+ return (+ <AbsoluteFill>+ <div />+ </AbsoluteFill>+ );+};+`;++test('deleteJsxNodes removes a JSX child from a parent element', async () => {+ const {output} = await deleteJsxNodes({+ input: sample,+ nodePaths: [lineColumnToNodePath(sample, 7)],+ });++ expect(output).not.toContain('<div');+ expect(output).toContain('<AbsoluteFill>');+});++const onlyReturn = `import React from 'react';++export const X: React.FC = () => {+ return <div />;+};+`;++test('deleteJsxNodes replaces sole return JSX with null', async () => {+ const {output} = await deleteJsxNodes({+ input: onlyReturn,+ nodePaths: [lineColumnToNodePath(onlyReturn, 4)],+ });++ expect(output).toContain('return null');+ expect(output).not.toContain('<div');+});++const conditional = `import React from 'react';++export const X: React.FC<{show: boolean}> = ({show}) => {+ return <>{show && <div />}</>;+};+`;++test('deleteJsxNodes turns conditional JSX into null', async () => {+ const {output} = await deleteJsxNodes({+ input: conditional,+ nodePaths: [lineColumnToNodePath(conditional, 4)],+ });++ expect(output).toContain('&& null');+ expect(output).not.toContain('<div');+});++const ternary = `import React from 'react';++export const X: React.FC<{show: boolean}> = ({show}) => {+ return <>{show ? <div /> : null}</>;+};+`;++test('deleteJsxNodes replaces JSX in ternary consequent with null', async () => {+ const {output} = await deleteJsxNodes({+ input: ternary,+ nodePaths: [lineColumnToNodePath(ternary, 4)],+ });++ expect(output).toMatch(/\?\s*null/);+ expect(output).not.toContain('<div');+});++const mapCase = `import React from 'react';++export const X: React.FC = () => {+ return (+ <>+ {[1].map((i) => (+ <div key={i} />+ ))}+ </>+ );+};+`;++test('deleteJsxNodes replaces JSX inside map callback', async () => {+ const {output} = await deleteJsxNodes({+ input: mapCase,+ nodePaths: [lineColumnToNodePath(mapCase, 7)],+ });++ expect(output).not.toContain('<div');+ expect(output).toMatch(/=>\s*\(?\s*null/);+});++const multipleSiblings = `import React from 'react';+import {AbsoluteFill} from 'remotion';++export const X: React.FC = () => {+ return (+ <AbsoluteFill>+ <div />+ <span />+ <p />+ </AbsoluteFill>+ );+};+`;++test('deleteJsxNodes removes multiple JSX children in one transform', async () => {+ const {output, nodeLabels, logLines} = await deleteJsxNodes({+ input: multipleSiblings,+ nodePaths: [+ lineColumnToNodePath(multipleSiblings, 7),+ lineColumnToNodePath(multipleSiblings, 8),+ ],+ });++ expect(output).not.toContain('<div');+ expect(output).not.toContain('<span');+ expect(output).toContain('<p');+ expect(nodeLabels).toEqual(['<div>', '<span>']);+ expect(logLines).toEqual([7, 8]);+});++test('deleteJsxNodes preserves source formatting and removes standalone JSX lines', async () => {+ const cases = [+ {+ input: `export const Comp = () => {+ return (+ <div>+ <Keep />+ <RemoveOne />+ <RemoveTwo />+ <Keep />+ </div>+ );+};+`,+ markers: ['<RemoveOne', '<RemoveTwo'],+ expected: `export const Comp = () => {+ return (+ <div>+ <Keep />+ <Keep />+ </div>+ );+};+`,+ },+ {+ input: `export const Comp = () => {+ return (+ <div>+ <Remove />+ </div>+ )+}+`,+ markers: ['<Remove'],+ expected: `export const Comp = () => {+ return (+ <div>+ </div>+ )+}+`,+ },+ {+ input: `export const Comp = () => {+ return [1].map((item) => (+ <Remove key={item} />+ ));+};+`,+ markers: ['<Remove'],+ expected: `export const Comp = () => {+ return [1].map((item) => null);+};+`,+ },+ {+ input: `const AnimatedBar = () => {+ return (+ <Remove />+ );+};+`,+ markers: ['<Remove'],+ expected: `const AnimatedBar = () => {+ return null;+};+`,+ },+ {+ input: `const AnimatedBar = () => {+ return (+ // Keep this explanation.+ <Remove />+ );+};+`,+ markers: ['<Remove'],+ expected: `const AnimatedBar = () => {+ return (+ // Keep this explanation.+ null+ );+};+`,+ },+ {+ input: `export const Comp = () => <div><Keep /><Remove /><Keep /></div>;+`,+ markers: ['<Remove'],+ expected: `export const Comp = () => <div><Keep /><Keep /></div>;+`,+ },+ {+ input:+ 'export const Comp = () => <div><Keep />\t<Remove /><Keep /></div>;\n',+ markers: ['<Remove'],+ expected: 'export const Comp = () => <div><Keep />\t<Keep /></div>;\n',+ },+ {+ input: `export const Comp = () => (+ <div>+ <Remove /> {/* keep this comment */}+ </div>+);+`,+ markers: ['<Remove'],+ expected: `export const Comp = () => (+ <div>+ {/* keep this comment */}+ </div>+);+`,+ },+ {+ input: `export const Comp = () => {+ return (+ <div>+ <RemoveParent>+ <RemoveChild />+ </RemoveParent>+ <Keep />+ </div>+ );+};+`,+ markers: ['<RemoveParent', '<RemoveChild'],+ expected: `export const Comp = () => {+ return (+ <div>+ <Keep />+ </div>+ );+};+`,+ },+ {+ input:+ 'export const Comp = () => {\r\n\treturn (\r\n\t\t<div>\r\n\t\t\t<Remove />\r\n\t\t</div>\r\n\t);\r\n};\r\n',+ markers: ['<Remove'],+ expected:+ 'export const Comp = () => {\r\n\treturn (\r\n\t\t<div>\r\n\t\t</div>\r\n\t);\r\n};\r\n',+ },+ ] as const;++ for (const item of cases) {+ const {output, formatted} = await deleteJsxNodes({+ input: item.input,+ nodePaths: item.markers.map((marker) =>+ lineContainingToNodePath(item.input, marker),+ ),+ });++ expect(output).toBe(item.expected);+ expect(formatted).toBe(true);+ }+});diff --git a/packages/studio-server/src/test/duplicate-effect.test.ts b/packages/codemods/src/test/duplicate-effect.test.tssimilarity index 94%rename from packages/studio-server/src/test/duplicate-effect.test.tsrename to packages/codemods/src/test/duplicate-effect.test.tsindex 096c30681e..08dc5076dd 100644--- a/packages/studio-server/src/test/duplicate-effect.test.ts+++ b/packages/codemods/src/test/duplicate-effect.test.ts@@ -1,8 +1,6 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';-import {lineColumnToNodePath} from './test-utils';--const {duplicateEffect, duplicateEffects} = CodemodsInternals;+import {duplicateEffect, duplicateEffects} from '../effect-operations';+import {lineColumnToNodePath} from './node-path-test-utils';const buildInput = (effects: string,diff --git a/packages/studio-server/src/test/duplicate-jsx-node.test.ts b/packages/codemods/src/test/duplicate-jsx-node.test.tssimilarity index 96%rename from packages/studio-server/src/test/duplicate-jsx-node.test.tsrename to packages/codemods/src/test/duplicate-jsx-node.test.tsindex 33c817d5da..5457d96fb6 100644--- a/packages/studio-server/src/test/duplicate-jsx-node.test.ts+++ b/packages/codemods/src/test/duplicate-jsx-node.test.ts@@ -1,8 +1,9 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';-import {lineColumnToNodePath, lineContainingToNodePath} from './test-utils';--const {duplicateJsxNodes} = CodemodsInternals;+import {duplicateJsxNodes} from '../duplicate-jsx-node';+import {+ lineColumnToNodePath,+ lineContainingToNodePath,+} from './node-path-test-utils';const sample = `import React from 'react';import {AbsoluteFill} from 'remotion';diff --git a/packages/studio-server/src/test/fixtures/canvas-capture-composition.txt b/packages/codemods/src/test/fixtures/canvas-capture-composition.txtsimilarity index 100%rename from packages/studio-server/src/test/fixtures/canvas-capture-composition.txtrename to packages/codemods/src/test/fixtures/canvas-capture-composition.txtdiff --git a/packages/studio-server/src/test/fixtures/canvas-capture-metadata.json b/packages/codemods/src/test/fixtures/canvas-capture-metadata.jsonsimilarity index 100%rename from packages/studio-server/src/test/fixtures/canvas-capture-metadata.jsonrename to packages/codemods/src/test/fixtures/canvas-capture-metadata.jsondiff --git a/packages/studio-server/src/test/snapshots/fixed.tsx b/packages/codemods/src/test/fixtures/fixed.tsx.txtsimilarity index 100%rename from packages/studio-server/src/test/snapshots/fixed.tsxrename to packages/codemods/src/test/fixtures/fixed.tsx.txtdiff --git a/packages/studio-server/src/test/snapshots/problematic.tsx b/packages/codemods/src/test/fixtures/problematic.tsx.txtsimilarity index 100%rename from packages/studio-server/src/test/snapshots/problematic.tsxrename to packages/codemods/src/test/fixtures/problematic.tsx.txtdiff --git a/packages/studio-server/src/test/snapshots/root-after.tsx b/packages/codemods/src/test/fixtures/root-after.tsx.txtsimilarity index 100%rename from packages/studio-server/src/test/snapshots/root-after.tsxrename to packages/codemods/src/test/fixtures/root-after.tsx.txtdiff --git a/packages/studio-server/src/test/snapshots/root-before.tsx b/packages/codemods/src/test/fixtures/root-before.tsx.txtsimilarity index 100%rename from packages/studio-server/src/test/snapshots/root-before.tsxrename to packages/codemods/src/test/fixtures/root-before.tsx.txtdiff --git a/packages/studio-server/src/test/generate-canvas-capture-composition.test.ts b/packages/codemods/src/test/generate-canvas-capture-composition.test.tssimilarity index 91%rename from packages/studio-server/src/test/generate-canvas-capture-composition.test.tsrename to packages/codemods/src/test/generate-canvas-capture-composition.test.tsindex 95c74e6f16..fa000cc6b0 100644--- a/packages/studio-server/src/test/generate-canvas-capture-composition.test.ts+++ b/packages/codemods/src/test/generate-canvas-capture-composition.test.ts@@ -1,13 +1,11 @@import {expect, test} from 'bun:test';import {readFileSync} from 'node:fs';import path from 'node:path';-import {CodemodsInternals} from '@remotion/codemods';import {CANVAS_CAPTURE_METADATA_TAG,parseCanvasCaptureData,} from '@remotion/studio-shared';--const {generateCanvasCaptureComposition} = CodemodsInternals;+import {generateCanvasCaptureComposition} from '../generate-canvas-capture-composition';test('generates the ideal interactive Canvas Capture composition markup', async () => {const fixtureDirectory = path.join(__dirname, 'fixtures');diff --git a/packages/codemods/src/test/get-jsx-elements-with-node-paths.test.ts b/packages/codemods/src/test/get-jsx-nodes.test.tssimilarity index 56%rename from packages/codemods/src/test/get-jsx-elements-with-node-paths.test.tsrename to packages/codemods/src/test/get-jsx-nodes.test.tsindex df3a5f8144..63edb1cac3 100644--- a/packages/codemods/src/test/get-jsx-elements-with-node-paths.test.ts+++ b/packages/codemods/src/test/get-jsx-nodes.test.ts@@ -1,14 +1,20 @@import {expect, test} from 'bun:test';-import {getJsxElementsWithNodePaths} from '../get-jsx-elements-with-node-paths';+import {getJsxNodes} from '../index';-test('lists JSX elements with their deletion paths in source order', () => {- const elements = getJsxElementsWithNodePaths({- source: `export const Video = () => (+test('lists JSX nodes with their deletion paths in source order', () => {+ const elements = getJsxNodes({+ filePath: 'Video.tsx',+ project: {+ rootDir: '/',+ files: {+ 'Video.tsx': `export const Video = () => (<AbsoluteFill><Sequence name="Intro" /><Series.Sequence durationInFrames={30} /></AbsoluteFill>);`,+ },+ },});expect(elements.map(({tagName}) => tagName)).toEqual([diff --git a/packages/codemods/src/test/insert-solid.test.ts b/packages/codemods/src/test/insert-solid.test.tsindex 1b45307648..21dccc57ed 100644--- a/packages/codemods/src/test/insert-solid.test.ts+++ b/packages/codemods/src/test/insert-solid.test.ts@@ -1,10 +1,6 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '..';--const {- insertJsxElementIntoProjectWithNodePathRemappings,- insertSolidIntoSource,-} = CodemodsInternals;+import {insertJsxElementIntoProjectWithNodePathRemappings} from '../insert-jsx-element';+import {insertSolidIntoSource} from '../internals';test('inserts a Solid into a component source file', () => {const result = insertSolidIntoSource({diff --git a/packages/codemods/src/test/node-path-test-utils.ts b/packages/codemods/src/test/node-path-test-utils.tsnew file mode 100644index 0000000000..6809ba3544--- /dev/null+++ b/packages/codemods/src/test/node-path-test-utils.ts@@ -0,0 +1,44 @@+import type {SequenceNodePath} from 'remotion';+import {getJsxNodes} from '../get-jsx-nodes';+import {lineColumnToNodePath as _lineColumnToNodePath} from '../sequence-props';+import {parseAst} from '../sequence-props/parse-ast';++export const lineColumnToNodePath = (+ input: string,+ line: number,+): SequenceNodePath => {+ const ast = parseAst(input);+ const result = _lineColumnToNodePath(ast, line);+ if (!result) {+ throw new Error(`No JSX element found at line ${line}`);+ }++ return result;+};++export const lineContainingToNodePath = (+ input: string,+ search: string,+): SequenceNodePath => {+ const sourceLines = input.split('\n');+ const line = sourceLines.findIndex((sourceLine) =>+ sourceLine.includes(search),+ );+ if (line === -1) {+ throw new Error(`Could not find ${JSON.stringify(search)} in source`);+ }++ const column = sourceLines[line].indexOf(search);+ const result = getJsxNodes({+ project: {rootDir: '/', files: {'/test.tsx': input}},+ filePath: '/test.tsx',+ }).findLast(+ (node) =>+ node.location?.line === line + 1 && node.location.column <= column,+ )?.nodePath;+ if (!result) {+ throw new Error(`No JSX element found for ${JSON.stringify(search)}`);+ }++ return result;+};diff --git a/packages/codemods/src/test/public-editing.test.ts b/packages/codemods/src/test/public-editing.test.tsindex bab99441de..bb7847153b 100644--- a/packages/codemods/src/test/public-editing.test.ts+++ b/packages/codemods/src/test/public-editing.test.ts@@ -30,6 +30,7 @@ import {updateEffectProps,updateJsxNodeKeyframes,updateJsxNodeProps,+ updateMultipleJsxNodeProps,type CodemodProject,} from '../index';@@ -268,6 +269,13 @@ export const VideoComposition = () => <><Video src="video.mp4" from={10} duratiotest('manage composition registrations and nested folders without changing components', () => {const original = makeProject();+ const helper = 'const Helper = () => <div>Keep this helper unchanged</div>;';+ original.files[compositionFile] = original.files[compositionFile]+ .replace(+ 'export const Root = () => ',+ `export const Root = () => {\n${helper}\nreturn `,+ )+ .replace('/>;\n', '/>;\n};\n');let {project} = addComposition({project: original,compositionFile,@@ -275,6 +283,7 @@ test('manage composition registrations and nested folders without changing compocomponent: {importName: 'Title', importPath: './Title'},metadata: {width: 1920, height: 1080, fps: 30, durationInFrames: 60},});+ expect(project.files[compositionFile]).toContain(helper);project = setCompositionDefaultProps({project,compositionFile,@@ -563,7 +572,8 @@ test('nested copies return root references and insertion preserves relative keystest('reject ambiguous registration roots and unsupported splitting or audio detachment', async () => {const project = makeProject();- project.files[compositionFile] += '\nconst AnotherComponent = () => <div />;';+ project.files[compositionFile] +=+ '\nconst AnotherRoot = () => <Composition id="Other" component={Video} />;';expect(() =>addComposition({project,@@ -595,3 +605,78 @@ test('node discovery and edits use original source locations with tabs and CRLF'expect(edited.project.files[filePath].startsWith('\uFEFF')).toBe(true);expect(edited.project.files[filePath]).toContain('\r\n');});++test('batch structured prop edits across files and preserve edit results in request order', () => {+ const project = {+ rootDir: '/',+ files: {+ 'first.tsx':+ 'export const First = () => <div style={{opacity: 0.5}} title="first" />;',+ 'second.tsx': 'export const Second = () => <div title="second" />;',+ },+ };+ const first = getJsxNodes({project, filePath: 'first.tsx'})[0];+ const second = getJsxNodes({project, filePath: 'second.tsx'})[0];+ const result = updateMultipleJsxNodeProps({+ project,+ changes: [+ {+ node: first,+ updates: [{key: 'style.opacity', value: 1, defaultValue: 1}],+ },+ {node: second, props: {title: 'updated second'}},+ {node: first, props: {title: 'updated first'}},+ ],+ });++ expect(result.changes).toHaveLength(2);+ expect(result.results[0].oldValueStrings).toEqual(['0.5']);+ expect(result.updatedNodes.map((node) => node.filePath)).toEqual([+ 'first.tsx',+ 'second.tsx',+ 'first.tsx',+ ]);+ expect(+ getJsxNodeProps({+ project: result.project,+ node: result.updatedNodes[0],+ keys: ['style.opacity', 'title'],+ }).props,+ ).toMatchObject({+ 'style.opacity': {codeValue: undefined},+ title: {codeValue: 'updated first'},+ });+ expect(+ getJsxNodeProps({+ project: result.project,+ node: result.updatedNodes[1],+ keys: ['title'],+ }).props.title,+ ).toMatchObject({codeValue: 'updated second'});+ expect(project.files['first.tsx']).toContain('opacity: 0.5');+});++test('set composition default props preserves serialized dates and enum assertions', () => {+ const input = `import {Composition} from 'remotion';+const untouched = "keep this spacing";+export const Root = () => <Composition id="Comp" defaultProps={{mode: 'old'}} />;+`;+ const result = setCompositionDefaultProps({+ project: {rootDir: '/', files: {'Root.tsx': input}},+ compositionFile: 'Root.tsx',+ compositionId: 'Comp',+ defaultProps: {+ mode: 'fast',+ date: 'remotion-date:2026-07-29T00:00:00.000Z',+ },+ enumPaths: [['mode']],+ });+ expect(result.logLine).toBe(3);+ expect(result.project.files['Root.tsx']).toContain(+ 'const untouched = "keep this spacing";',+ );+ expect(result.project.files['Root.tsx']).toContain("mode: 'fast' as const");+ expect(result.project.files['Root.tsx']).toMatch(+ /date: new Date\(\s*'2026-07-29T00:00:00\.000Z',?\s*\)/,+ );+});diff --git a/packages/studio-server/src/test/reorder-effect.test.ts b/packages/codemods/src/test/reorder-effect.test.tssimilarity index 93%rename from packages/studio-server/src/test/reorder-effect.test.tsrename to packages/codemods/src/test/reorder-effect.test.tsindex 582569acde..9d3ffb3cf0 100644--- a/packages/studio-server/src/test/reorder-effect.test.ts+++ b/packages/codemods/src/test/reorder-effect.test.ts@@ -1,8 +1,6 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';-import {lineColumnToNodePath} from './test-utils';--const {reorderEffect} = CodemodsInternals;+import {reorderEffect} from '../effect-operations';+import {lineColumnToNodePath} from './node-path-test-utils';const buildInput = (effects: string,diff --git a/packages/studio-server/src/test/reorder-sequence.test.ts b/packages/codemods/src/test/reorder-sequence.test.tssimilarity index 91%rename from packages/studio-server/src/test/reorder-sequence.test.tsrename to packages/codemods/src/test/reorder-sequence.test.tsindex 14a1c31c6a..ec163cc939 100644--- a/packages/studio-server/src/test/reorder-sequence.test.ts+++ b/packages/codemods/src/test/reorder-sequence.test.ts@@ -1,10 +1,7 @@import {expect, test} from 'bun:test';-import {CodemodsInternals} from '@remotion/codemods';-import {parseAst} from '../codemods/parse-ast';-import {lineColumnToNodePath as getNodePathAtPosition} from '../preview-server/routes/can-update-sequence-props';-import {lineColumnToNodePath} from './test-utils';--const {reorderSequence} = CodemodsInternals;+import {getJsxNodes} from '../get-jsx-nodes';+import {reorderSequence} from '../reorder-sequence';+import {lineColumnToNodePath} from './node-path-test-utils';const sequenceContaining = (input: string, search: string) => {const searchOffset = input.indexOf(search);@@ -20,12 +17,14 @@ const sequenceContaining = (input: string, search: string) => {}const sourceBeforeOpening = input.slice(0, openingOffset).split('\n');- const nodePath = getNodePathAtPosition(- parseAst(input),- sourceBeforeOpening.length,- sourceBeforeOpening.at(-1)?.length ?? 0,- input,- );+ const nodePath = getJsxNodes({+ project: {rootDir: '/', files: {'/test.tsx': input}},+ filePath: '/test.tsx',+ }).find(+ (node) =>+ node.location?.line === sourceBeforeOpening.length &&+ node.location.column === (sourceBeforeOpening.at(-1)?.length ?? 0),+ )?.nodePath;if (!nodePath) {throw new Error(`Could not resolve a Sequence containing ${JSON.stringify(search)}`,diff --git a/packages/codemods/src/test/split-jsx-sequence.test.ts b/packages/codemods/src/test/split-jsx-sequence.test.tsindex f778ec527f..abbd008bd6 100644--- a/packages/codemods/src/test/split-jsx-sequence.test.ts+++ b/packages/codemods/src/test/split-jsx-sequence.test.ts@@ -3,6 +3,10 @@ import * as recast from 'recast';import {getNodePathForRecastPath} from '../sequence-props';import {parseAst} from '../sequence-props/parse-ast';import {splitJsxSequence, splitJsxSequences} from '../split-jsx-sequence';+import {+ lineColumnToNodePath,+ lineContainingToNodePath,+} from './node-path-test-utils';test('splits fractional timing without persisting arithmetic noise', async () => {const input =@@ -75,3 +79,254 @@ test('splits multiple sibling sequences from the same source snapshot', async ()nodePathRemappings.filter((remapping) => remapping.oldNodePath === null),).toHaveLength(2);});++const wrap = (+ sequence: string,+) => `import {AbsoluteFill, Img, Interactive, Sequence, Series, Solid} from 'remotion';+import {Gif} from '@remotion/gif';++export const Comp = () => {+ return (+ <>+ ${sequence}+ </>+ );+};+`;++const sequenceLine = 7;+const sequenceTimingKeys = ['from', 'durationInFrames', 'trimBefore'];++const split = async (+ sequence: string,+ splitFrame: number,+ sequenceKeys = sequenceTimingKeys,+) => {+ const input = wrap(sequence);+ const {output} = await splitJsxSequence({+ input,+ nodePath: lineColumnToNodePath(input, sequenceLine),+ sequenceKeys,+ splitFrame,+ });++ return output;+};++test('splitJsxSequence splits a sequence with no duration', async () => {+ const output = await split('<Sequence from={0} />', 30);++ expect(output).toContain('<Sequence from={0} durationInFrames={30} />');+ expect(output).toContain('<Sequence from={30} trimBefore={30} />');+});++test('splitJsxSequence remaps following JSX siblings', async () => {+ const input = wrap(+ '<Sequence name="split" from={0} durationInFrames={50} />\n\t\t\t<Sequence name="following" />',+ );+ const {output, nodePathRemappings} = await splitJsxSequence({+ input,+ nodePath: lineContainingToNodePath(input, 'name="split"'),+ sequenceKeys: sequenceTimingKeys,+ splitFrame: 30,+ });++ expect(nodePathRemappings).toEqual([+ {+ oldNodePath: lineContainingToNodePath(input, 'name="split"'),+ newNodePath: lineContainingToNodePath(output, 'name="split"'),+ },+ {+ oldNodePath: lineContainingToNodePath(input, 'name="following"'),+ newNodePath: lineContainingToNodePath(output, 'name="following"'),+ },+ {+ oldNodePath: null,+ newNodePath: lineContainingToNodePath(output, 'from={30}'),+ },+ ]);+});++test('splitJsxSequence omits right Infinity duration', async () => {+ const output = await split(+ '<Sequence from={0} durationInFrames={Infinity} />',+ 30,+ );++ expect(output).toContain('<Sequence from={0} durationInFrames={30} />');+ expect(output).toContain('<Sequence from={30} trimBefore={30} />');+ expect(output).not.toContain('durationInFrames={Infinity}');+});++test('splitJsxSequence keeps missing left from omitted', async () => {+ const output = await split('<Sequence durationInFrames={50} />', 30);++ expect(output).toContain('<Sequence durationInFrames={30} />');+ expect(output).toContain(+ '<Sequence from={30} durationInFrames={20} trimBefore={30} />',+ );+});++test('splitJsxSequence splits finite duration and trimBefore', async () => {+ const output = await split(+ '<Sequence from={10} durationInFrames={50} trimBefore={5} />',+ 30,+ );++ expect(output).toContain(+ '<Sequence from={10} durationInFrames={20} trimBefore={5} />',+ );+ expect(output).toContain(+ '<Sequence from={30} durationInFrames={30} trimBefore={25} />',+ );+});++test('splitJsxSequence preserves surrounding formatting without calling Prettier', async () => {+ const input = `const deliberatelyUnformatted = {value : true}++export const Comp = () => {+ return (+ <>+ <Sequence+ name="clip"+ from={0}+ durationInFrames={50}+ >+ <div>Child</div>+ </Sequence>+ <Keep prop = {1}/>+ </>+ )+}+`;+ const {output} = await splitJsxSequence({+ input,+ nodePath: lineContainingToNodePath(input, '<Sequence'),+ sequenceKeys: sequenceTimingKeys,+ splitFrame: 30,+ });++ expect(output).toStartWith(+ 'const deliberatelyUnformatted = {value : true}\n',+ );+ expect(output).toContain(+ '<Sequence name="clip" from={0} durationInFrames={30}>\n',+ );+ expect(output).toContain(+ '<Sequence name="clip" from={30} durationInFrames={20} trimBefore={30}>\n',+ );+ expect(output).toContain(' <Keep prop = {1}/>');+ expect(output).toEndWith(' )\n}\n');+});++test('splitJsxSequence formats a split component root as a fragment', async () => {+ const input = `export const Comp = () => <Sequence from={0} durationInFrames={50}><span>Hi</span></Sequence>;++const keep = { value : true }+`;+ const {output} = await splitJsxSequence({+ input,+ nodePath: lineContainingToNodePath(input, '<Sequence'),+ sequenceKeys: sequenceTimingKeys,+ splitFrame: 30,+ });++ expect(output).toBe(`export const Comp = () => <>+ <Sequence from={0} durationInFrames={30}>+ <span>Hi</span>+ </Sequence>+ <Sequence from={30} durationInFrames={20} trimBefore={30}>+ <span>Hi</span>+ </Sequence>+</>;++const keep = { value : true }+`);+});++test('splitJsxSequence splits a video with a negative from', async () => {+ const output = await split(+ '<Video src="video.mov" from={-2644} trimBefore={272} />',+ 100,+ );++ expect(output).toContain('from={-2644}');+ expect(output).toContain('durationInFrames={2744}');+ expect(output).toContain('trimBefore={272}');+ expect(output).toContain(+ '<Video src="video.mov" from={100} trimBefore={3016} />',+ );+});++test('splitJsxSequence splits from-only sequence', async () => {+ const output = await split('<Sequence from={10} />', 30);++ expect(output).toContain('<Sequence from={10} durationInFrames={20} />');+ expect(output).toContain('<Sequence from={30} trimBefore={20} />');+});++test('splitJsxSequence splits sequence-backed components', async () => {+ expect(+ await split('<AbsoluteFill from={0} durationInFrames={50} />', 30),+ ).toContain(+ '<AbsoluteFill from={30} durationInFrames={20} trimBefore={30} />',+ );+ expect(+ await split('<Img src="image.png" from={0} durationInFrames={50} />', 30),+ ).toContain(+ '<Img src="image.png" from={30} durationInFrames={20} trimBefore={30} />',+ );+ expect(+ await split('<Gif src="anim.gif" from={0} durationInFrames={50} />', 30),+ ).toContain(+ '<Gif src="anim.gif" from={30} durationInFrames={20} trimBefore={30} />',+ );+ const solidOutput = await split(+ '<Solid width={100} height={100} from={0} durationInFrames={50} />',+ 30,+ );+ expect(solidOutput).toContain(+ '<Solid width={100} height={100} from={0} durationInFrames={30} />',+ );+ expect(solidOutput).toContain('from={30}');+ expect(solidOutput).toContain('durationInFrames={20}');+ expect(solidOutput).toContain('trimBefore={30}');+ expect(+ await split('<Interactive.Div from={0} durationInFrames={50} />', 30),+ ).toContain(+ '<Interactive.Div from={30} durationInFrames={20} trimBefore={30} />',+ );+});++test('splitJsxSequence rejects boundary and dynamic splits', async () => {+ await expect(+ split('<Sequence from={10} durationInFrames={20} />', 10),+ ).rejects.toThrow(/sequence start/);+ await expect(+ split('<Sequence from={10} durationInFrames={20} />', 30),+ ).rejects.toThrow(/sequence end/);+ await expect(+ split('<Sequence from={10} durationInFrames={20} />', 8),+ ).rejects.toThrow(/sequence start/);+ await expect(+ split('<Sequence from={10} durationInFrames={20} />', 10.5),+ ).rejects.toThrow(/integer/);+ await expect(+ split('<Sequence from={start} durationInFrames={20} />', 15),+ ).rejects.toThrow(/dynamic from/);+});++test('splitJsxSequence rejects Series.Sequence', async () => {+ await expect(+ split('<Series.Sequence durationInFrames={50} />', 30, [+ 'durationInFrames',+ 'trimBefore',+ ]),+ ).rejects.toThrow('<Series.Sequence> cannot be split');+});++test('splitJsxSequence rejects regular DOM elements', async () => {+ await expect(+ split('<div from={0} durationInFrames={50} />', 30, []),+ ).rejects.toThrow('<div> cannot be split');+});diff --git a/packages/codemods/src/test/split-video-from-audio.test.ts b/packages/codemods/src/test/split-video-from-audio.test.tsnew file mode 100644index 0000000000..b7c6369d7b--- /dev/null+++ b/packages/codemods/src/test/split-video-from-audio.test.ts@@ -0,0 +1,266 @@+import {expect, test} from 'bun:test';+import {splitVideoFromAudio} from '../split-video-from-audio';+import {lineContainingToNodePath} from './node-path-test-utils';++const wrap = (+ element: string,+ imports = `import {Video} from '@remotion/media';`,+) => `${imports}++export const Comp = () => {+ return (+ <>+ ${element}+ </>+ );+};+`;++const split = async (element: string, imports?: string) => {+ const input = wrap(element, imports);+ const {output} = await splitVideoFromAudio({+ input,+ nodePath: lineContainingToNodePath(input, element),+ });++ return output;+};++test('splitVideoFromAudio mutes the video and adds an Audio with the same timing', async () => {+ const output = await split(+ '<Video src="video.mp4" from={10} durationInFrames={50} trimBefore={5} playbackRate={2} volume={0.5} style={{opacity: 0.5}} />',+ );++ const singleLine = output.replace(/\s+/g, ' ');++ expect(output).toContain(`import {Video, Audio} from '@remotion/media';`);+ expect(singleLine).toContain(+ '<Video src="video.mp4" from={10} durationInFrames={50} trimBefore={5} playbackRate={2} volume={0.5} style={{opacity: 0.5}} muted />',+ );+ expect(singleLine).toContain(+ '<Audio src="video.mp4" from={10} durationInFrames={50} trimBefore={5} playbackRate={2} volume={0.5} />',+ );+});++test('splitVideoFromAudio preserves unrelated source formatting without calling the formatter', async () => {+ const input = `import{Video}from"@remotion/media"++const untouched = {keep : "spacing"}+export const Comp=()=>(+ <>+ <Video+ src = {"video.mp4"}+ from = {10}+ style = {{opacity:.5}}+ />+ <div data-value = "unchanged"/>+ </>+)+`;+ let formatCalls = 0;+ const {formatted, nodePathRemappings, output} = await splitVideoFromAudio({+ input,+ nodePath: lineContainingToNodePath(input, '<Video'),+ formatFile: () => {+ formatCalls++;+ throw new Error('Prettier must not be called');+ },+ });++ expect(formatCalls).toBe(0);+ expect(formatted).toBe(true);+ expect(output).toBe(`import{Video, Audio}from"@remotion/media"++const untouched = {keep : "spacing"}+export const Comp=()=>(+ <>+ <Video+ src = {"video.mp4"}+ from = {10}+ style = {{opacity:.5}}+ muted+ />+ <Audio src={"video.mp4"} from={10} />+ <div data-value = "unchanged"/>+ </>+)+`);+ expect(nodePathRemappings).toEqual([+ {+ oldNodePath: lineContainingToNodePath(input, '<Video'),+ newNodePath: lineContainingToNodePath(output, '<Video'),+ },+ {+ oldNodePath: lineContainingToNodePath(input, '<div'),+ newNodePath: lineContainingToNodePath(output, '<div'),+ },+ {+ oldNodePath: null,+ newNodePath: lineContainingToNodePath(output, '<Audio'),+ },+ ]);+});++test('splitVideoFromAudio does not copy non-audio props', async () => {+ const output = await split(+ '<Video src="video.mp4" name="my video" freeze={20} crop={{x: 0, y: 0, width: 100, height: 100}} />',+ );++ expect(output).toContain('<Audio src="video.mp4" />');+});++test('splitVideoFromAudio wraps a root video in a fragment', async () => {+ const input = `import {Video} from '@remotion/media';++export const Comp = () => <Video src="video.mp4" />;+`;+ const {output} = await splitVideoFromAudio({+ input,+ nodePath: lineContainingToNodePath(input, '<Video'),+ });++ expect(output).toBe(`import {Video, Audio} from '@remotion/media';++export const Comp = () => <>+ <Video src="video.mp4" muted />+ <Audio src="video.mp4" />+</>;+`);+});++test('splitVideoFromAudio separates siblings with one space on a shared line', async () => {+ const input = `import {Video} from '@remotion/media';++export const Comp = () => (+ <div>+ <Video src="video.mp4" /></div>+);+`;+ const {output} = await splitVideoFromAudio({+ input,+ nodePath: lineContainingToNodePath(input, '<Video'),+ });++ expect(output).toBe(`import {Video, Audio} from '@remotion/media';++export const Comp = () => (+ <div>+ <Video src="video.mp4" muted /> <Audio src="video.mp4" /></div>+);+`);+});++test('splitVideoFromAudio preserves CRLF and tab indentation', async () => {+ const input = [+ `import {Video} from '@remotion/media';`,+ '',+ 'export const Comp = () => {',+ '\treturn (',+ '\t\t<>',+ '\t\t\t<Video',+ '\t\t\t\tsrc="video.mp4"',+ '\t\t\t\ttrimBefore={10}',+ '\t\t\t/>',+ '\t\t</>',+ '\t);',+ '};',+ '',+ ].join('\r\n');+ const {output} = await splitVideoFromAudio({+ input,+ nodePath: lineContainingToNodePath(input, '<Video'),+ });++ expect(output).toBe(+ [+ `import {Video, Audio} from '@remotion/media';`,+ '',+ 'export const Comp = () => {',+ '\treturn (',+ '\t\t<>',+ '\t\t\t<Video',+ '\t\t\t\tsrc="video.mp4"',+ '\t\t\t\ttrimBefore={10}',+ '\t\t\t\tmuted',+ '\t\t\t/>',+ '\t\t\t<Audio src="video.mp4" trimBefore={10} />',+ '\t\t</>',+ '\t);',+ '};',+ '',+ ].join('\r\n'),+ );+});++test('splitVideoFromAudio replaces an existing muted prop', async () => {+ const output = await split('<Video src="video.mp4" muted={false} />');++ expect(output).toContain('<Video src="video.mp4" muted />');+ expect(output).not.toContain('muted={false}');+});++test('splitVideoFromAudio reuses an existing Audio import', async () => {+ const output = await split(+ '<Video src="video.mp4" />',+ `import {Audio, Video} from '@remotion/media';`,+ );++ expect(output).toContain(`import {Audio, Video} from '@remotion/media';`);+ expect(output.match(/from '@remotion\/media'/g)?.length).toBe(1);+});++test('splitVideoFromAudio uses an aliased Audio import', async () => {+ const output = await split(+ '<Video src="video.mp4" />',+ `import {Audio as Sound, Video} from '@remotion/media';`,+ );++ expect(output).toContain(+ `import {Audio as Sound, Video} from '@remotion/media';`,+ );+ expect(output).toContain('<Sound src="video.mp4" />');+});++test('splitVideoFromAudio imports Audio from the same module as the tag', async () => {+ const output = await split(+ '<OffthreadVideo src="video.mp4" from={5} />',+ `import {OffthreadVideo} from 'remotion';`,+ );++ expect(output).toContain(`import {OffthreadVideo, Audio} from 'remotion';`);+ expect(output).toContain('<OffthreadVideo src="video.mp4" from={5} muted />');+ expect(output).toContain('<Audio src="video.mp4" from={5} />');+});++test('splitVideoFromAudio follows import aliases', async () => {+ const output = await split(+ '<V src="video.mp4" />',+ `import {Video as V} from '@remotion/media';`,+ );++ expect(output).toContain(+ `import {Video as V, Audio} from '@remotion/media';`,+ );+ expect(output).toContain('<Audio src="video.mp4" />');+});++test('splitVideoFromAudio rejects elements without a src attribute', async () => {+ await expect(split('<Video from={0} />')).rejects.toThrow(+ '<Video> has no src attribute',+ );+});++test('splitVideoFromAudio rejects unimported tags', async () => {+ await expect(split('<video src="video.mp4" />')).rejects.toThrow(+ 'Could not find the import of <video>',+ );+});++test('splitVideoFromAudio rejects an Audio import from another module', async () => {+ await expect(+ split(+ '<Video src="video.mp4" />',+ `import {Video} from '@remotion/media';\nimport {Audio} from 'remotion';`,+ ),+ ).rejects.toThrow('Audio is already imported from "remotion"');+});diff --git a/packages/studio-server/src/test/update-default-props.test.ts b/packages/codemods/src/test/update-default-props.test.tssimilarity index 88%rename from packages/studio-server/src/test/update-default-props.test.tsrename to packages/codemods/src/test/update-default-props.test.tsindex 0028042141..10613b9dbf 100644--- a/packages/studio-server/src/test/update-default-props.test.ts+++ b/packages/codemods/src/test/update-default-props.test.ts@@ -1,18 +1,19 @@import {expect, test} from 'bun:test';import {readFileSync} from 'node:fs';import path from 'node:path';-import {CodemodsInternals} from '@remotion/codemods';-import {parseAst} from '../codemods/parse-ast';--const {getCompositionDefaultPropsLine, updateDefaultProps} = CodemodsInternals;+import {parseAst} from '../sequence-props/parse-ast';+import {+ getCompositionDefaultPropsLine,+ updateDefaultProps,+} from '../update-default-props';test('updates default props without changing surrounding source', () => {const file = readFileSync(- path.join(__dirname, 'snapshots', 'root-before.tsx'),+ path.join(__dirname, 'fixtures', 'root-before.tsx.txt'),'utf-8',);const expected = readFileSync(- path.join(__dirname, 'snapshots', 'root-after.tsx'),+ path.join(__dirname, 'fixtures', 'root-after.tsx.txt'),'utf-8',);@@ -28,7 +29,7 @@ test('updates default props without changing surrounding source', () => {test('getCompositionDefaultPropsLine returns the opening tag line (ast-types visitor must traverse)', () => {const file = readFileSync(- path.join(__dirname, 'snapshots', 'root-before.tsx'),+ path.join(__dirname, 'fixtures', 'root-before.tsx.txt'),'utf-8',);@@ -42,11 +43,11 @@ test('getCompositionDefaultPropsLine returns the opening tag line (ast-types vistest('replaces multiline default props with a compact value', () => {const file = readFileSync(- path.join(__dirname, 'snapshots', 'problematic.tsx'),+ path.join(__dirname, 'fixtures', 'problematic.tsx.txt'),'utf-8',);const expected = readFileSync(- path.join(__dirname, 'snapshots', 'fixed.tsx'),+ path.join(__dirname, 'fixtures', 'fixed.tsx.txt'),'utf-8',);diff --git a/packages/studio-server/src/test/update-effect-props.test.ts b/packages/codemods/src/test/update-effect-props.test.tssimilarity index 98%rename from packages/studio-server/src/test/update-effect-props.test.tsrename to packages/codemods/src/test/update-effect-props.test.tsindex 958e2deb0c..5d93ccd50c 100644--- a/packages/studio-server/src/test/update-effect-props.test.ts+++ b/packages/codemods/src/test/update-effect-props.test.ts@@ -1,6 +1,6 @@import {expect, test} from 'bun:test';-import {updateEffectPropsAst} from '../codemods/update-effect-props/update-effect-props';-import {lineColumnToNodePath} from './test-utils';+import {updateEffectPropsAst} from '../effect-operations';+import {lineColumnToNodePath} from './node-path-test-utils';const tintSchema = {color: {diff --git a/packages/studio-server/src/test/update-keyframes-imports.test.ts b/packages/codemods/src/test/update-keyframes-imports.test.tssimilarity index 99%rename from packages/studio-server/src/test/update-keyframes-imports.test.tsrename to packages/codemods/src/test/update-keyframes-imports.test.tsindex 1f3eabd1b7..65b3b41d74 100644--- a/packages/studio-server/src/test/update-keyframes-imports.test.ts+++ b/packages/codemods/src/test/update-keyframes-imports.test.ts@@ -3,8 +3,8 @@ import type {InteractivitySchema} from 'remotion';import {updateEffectKeyframesAst,updateSequenceKeyframesAst,-} from '../codemods/update-keyframes/update-keyframes';-import {lineColumnToNodePath} from './test-utils';+} from '../update-keyframes';+import {lineColumnToNodePath} from './node-path-test-utils';const getLine = (input: string, needle: string): number => {const lineIndex = inputdiff --git a/packages/codemods/src/update-effect-keyframes.ts b/packages/codemods/src/update-effect-keyframes.tsindex eff7f0a5b6..0645822df9 100644--- a/packages/codemods/src/update-effect-keyframes.ts+++ b/packages/codemods/src/update-effect-keyframes.ts@@ -19,6 +19,7 @@ export const updateEffectKeyframes = async <Project extends CodemodProject>({updates,schema,videoConfig,+ prettierConfigOverride,}: UpdateEffectKeyframesOptions<Project>) => {if (updates.length === 0) {throw new Error('Expected at least one keyframe update');@@ -29,13 +30,14 @@ export const updateEffectKeyframes = async <Project extends CodemodProject>({}const {filePath, input} = getEffectSource({project, node: effect});- const {output} = await updateEffectKeyframesInSource({+ const {output, ...details} = await updateEffectKeyframesInSource({input,sequenceNodePath: effect.nodePath,effectIndex: effect.effectIndex,updates,schema,videoConfigValues: videoConfig ?? null,+ prettierConfigOverride,});const result = getNodeEditResult({project,@@ -49,6 +51,7 @@ export const updateEffectKeyframes = async <Project extends CodemodProject>({});return {...result,+ ...details,updatedEffect: {...getUpdatedNodeReference({...result, node: effect}),effectIndex: effect.effectIndex,diff --git a/packages/codemods/src/update-effect-props.ts b/packages/codemods/src/update-effect-props.tsindex 72a0abbbc8..03d6c732a2 100644--- a/packages/codemods/src/update-effect-props.ts+++ b/packages/codemods/src/update-effect-props.ts@@ -1,7 +1,11 @@import type {InteractivitySchema} from 'remotion';import type {CodemodProject} from './codemod-project';import type {CodemodValue} from './codemod-value';-import {updateEffectProps as updateEffectPropsInSource} from './effect-operations';+import {+ updateEffectProps as updateEffectPropsInSource,+ type EffectPropUpdate,+ type UpdateEffectPropsResult,+} from './effect-operations';import {type EffectReference, getEffectSource} from './effect-references';import {getJsxNodeProps} from './get-jsx-node-props';import {@@ -13,14 +17,17 @@ import {export type UpdateEffectPropsOptions<Project extends CodemodProject> = {project: Project;effect: EffectReference;- props: Record<string, CodemodValue>;schema?: InteractivitySchema;-};+} & (+ | {props: Record<string, CodemodValue>; updates?: never}+ | {updates: EffectPropUpdate[]; props?: never}+);export const updateEffectProps = async <Project extends CodemodProject>({project,effect,props,+ updates,schema = {},}: UpdateEffectPropsOptions<Project>) => {const {filePath, input, length} = getEffectSource({project, node: effect});@@ -32,7 +39,14 @@ export const updateEffectProps = async <Project extends CodemodProject>({throw new Error('Effect index is out of range');}- const keys = Object.keys(props);+ const propUpdates =+ updates ??+ Object.entries(props).map(([key, value]) => ({+ key,+ value,+ defaultValue: null,+ }));+ const keys = propUpdates.map(({key}) => key);if (keys.length === 0) {throw new Error('Expected at least one effect prop');}@@ -50,24 +64,26 @@ export const updateEffectProps = async <Project extends CodemodProject>({}let output = input;- for (const [key, value] of Object.entries(props)) {+ const results: UpdateEffectPropsResult[] = [];+ for (const update of propUpdates) {+ const {key} = update;if (!/^[A-Za-z_$][\w$]*$/.test(key)) {throw new Error('Effect prop names must be JavaScript identifiers');}- if (status.props[key]?.status === 'computed') {+ if (!updates && status.props[key]?.status === 'computed') {throw new Error(`Cannot update computed effect prop "${key}"`);}- output = (- await updateEffectPropsInSource({- input: output,- sequenceNodePath: effect.nodePath,- effectIndex: effect.effectIndex,- update: {key, value, defaultValue: null},- schema,- })- ).output;+ const edit = await updateEffectPropsInSource({+ input: output,+ sequenceNodePath: effect.nodePath,+ effectIndex: effect.effectIndex,+ update,+ schema,+ });+ output = edit.output;+ results.push(edit);}const result = getNodeEditResult({@@ -82,6 +98,7 @@ export const updateEffectProps = async <Project extends CodemodProject>({});return {...result,+ results,updatedEffect: {...getUpdatedNodeReference({...result, node: effect}),effectIndex: effect.effectIndex,diff --git a/packages/codemods/src/update-jsx-node-keyframes.ts b/packages/codemods/src/update-jsx-node-keyframes.tsindex f92fb8f4ad..7a5fab5934 100644--- a/packages/codemods/src/update-jsx-node-keyframes.ts+++ b/packages/codemods/src/update-jsx-node-keyframes.ts@@ -20,6 +20,7 @@ export type UpdateJsxNodeKeyframesOptions<Project extends CodemodProject> = {updates: JsxNodeKeyframeUpdate[];schema?: InteractivitySchema;videoConfig?: VideoConfigValues;+ prettierConfigOverride?: Record<string, unknown> | null;};export const updateJsxNodeKeyframes = async <Project extends CodemodProject>({@@ -28,6 +29,7 @@ export const updateJsxNodeKeyframes = async <Project extends CodemodProject>({updates,schema,videoConfig,+ prettierConfigOverride,}: UpdateJsxNodeKeyframesOptions<Project>) => {if (updates.length === 0) {throw new Error('Expected at least one keyframe update');@@ -35,12 +37,13 @@ export const updateJsxNodeKeyframes = async <Project extends CodemodProject>({const filePath = findProjectFile({project, filePath: node.filePath});const input = project.files[filePath];- const {output} = await updateSequenceKeyframes({+ const {output, ...details} = await updateSequenceKeyframes({input,nodePath: node.nodePath,updates,schema,videoConfigValues: videoConfig ?? null,+ prettierConfigOverride,});const result = getNodeEditResult({project,@@ -52,5 +55,9 @@ export const updateJsxNodeKeyframes = async <Project extends CodemodProject>({},],});- return {...result, updatedNode: getUpdatedNodeReference({...result, node})};+ return {+ ...result,+ ...details,+ updatedNode: getUpdatedNodeReference({...result, node}),+ };};diff --git a/packages/codemods/src/update-jsx-node-props.ts b/packages/codemods/src/update-jsx-node-props.tsindex 11a8a476d2..31afa77d4a 100644--- a/packages/codemods/src/update-jsx-node-props.ts+++ b/packages/codemods/src/update-jsx-node-props.ts@@ -11,75 +11,148 @@ import {getNodeEditResult,getUpdatedNodeReference,type JsxNodeReference,+ type NodeSourceEdit,} from './node-references';import {parseAst} from './sequence-props/parse-ast';-import {updateMultipleSequenceProps} from './update-sequence-props';+import {+ updateMultipleSequenceProps,+ type SequencePropUpdate,+ type SequencePropsNodeUpdateResult,+} from './update-sequence-props';++type JsxNodePropValues =+ | {props: Record<string, CodemodValue | undefined>; updates?: never}+ | {updates: SequencePropUpdate[]; props?: never};-export type UpdateJsxNodePropsOptions<Project extends CodemodProject> = {- project: Project;+export type JsxNodePropChange = JsxNodePropValues & {node: JsxNodeReference;- props: Record<string, CodemodValue | undefined>;schema?: InteractivitySchema;videoConfig?: VideoConfigValues;};-export const updateJsxNodeProps = <Project extends CodemodProject>({+export type UpdateJsxNodePropsOptions<Project extends CodemodProject> =+ JsxNodePropChange & {+ project: Project;+ prettierConfigOverride?: Record<string, unknown> | null;+ };++export type UpdateMultipleJsxNodePropsOptions<Project extends CodemodProject> =+ {+ project: Project;+ changes: JsxNodePropChange[];+ prettierConfigOverride?: Record<string, unknown> | null;+ };++export const updateMultipleJsxNodeProps = <Project extends CodemodProject>({project,- node,- props,- schema = {},- videoConfig,-}: UpdateJsxNodePropsOptions<Project>) => {- const keys = Object.keys(props);- if (keys.length === 0) {- throw new Error('Expected at least one prop to update');+ changes,+ prettierConfigOverride,+}: UpdateMultipleJsxNodePropsOptions<Project>) => {+ if (changes.length === 0) {+ throw new Error('Expected at least one node to update');}- const status = getJsxNodeProps({project, node, keys, videoConfig});- for (const key of keys) {- if (- !key ||- key.split('.').some((part) => !part) ||- key.split('.').length > 2- ) {- throw new Error(- 'Prop keys must be names or one-level nested paths such as style.opacity',- );- }+ const groups = new Map<+ string,+ {change: JsxNodePropChange; index: number}[]+ >();+ for (const [index, change] of changes.entries()) {+ const filePath = findProjectFile({project, filePath: change.node.filePath});+ const group = groups.get(filePath) ?? [];+ group.push({change, index});+ groups.set(filePath, group);+ }++ const edits: NodeSourceEdit[] = [];+ const results: SequencePropsNodeUpdateResult[] = [];+ for (const [filePath, group] of groups) {+ const input = project.files[filePath];+ const ast = parseAst(input);+ const captured = captureJsxNodePaths(ast);+ const edit = updateMultipleSequenceProps({+ input,+ ast,+ prettierConfigOverride,+ changes: group.map(({change}) => {+ const updates =+ change.updates ??+ Object.entries(change.props).map(([key, value]) => ({+ key,+ value,+ defaultValue: null,+ }));+ if (updates.length === 0) {+ throw new Error('Expected at least one prop to update');+ }- if (status.props[key]?.status === 'computed') {- throw new Error(`Cannot update computed prop "${key}"`);+ const keys = updates.map(({key}) => key);+ const status = change.updates+ ? null+ : getJsxNodeProps({+ project,+ node: change.node,+ keys,+ videoConfig: change.videoConfig,+ });+ for (const key of keys) {+ if (+ !key ||+ key.split('.').some((part) => !part) ||+ key.split('.').length > 2+ ) {+ throw new Error(+ 'Prop keys must be names or one-level nested paths such as style.opacity',+ );+ }++ if (status?.props[key]?.status === 'computed') {+ throw new Error(`Cannot update computed prop "${key}"`);+ }+ }++ return {+ nodePath: change.node.nodePath,+ updates,+ schema: change.schema ?? {},+ videoConfigValues: change.videoConfig ?? null,+ };+ }),+ });+ const {nodePathRemappings} = getNodePathRemappings({+ ast: edit.ast,+ captured,+ output: edit.output,+ });+ edits.push({filePath, output: edit.output, nodePathRemappings});+ for (const [index, item] of group.entries()) {+ results[item.index] = edit.results[index];}}- const filePath = findProjectFile({project, filePath: node.filePath});- const input = project.files[filePath];- const ast = parseAst(input);- const captured = captureJsxNodePaths(ast);- const edit = updateMultipleSequenceProps({- input,- ast,- changes: [- {- nodePath: node.nodePath,- updates: Object.entries(props).map(([key, value]) => ({- key,- value,- defaultValue: null,- })),- schema,- videoConfigValues: videoConfig ?? null,- },- ],- });- const {nodePathRemappings} = getNodePathRemappings({- ast: edit.ast,- captured,- output: edit.output,- });- const result = getNodeEditResult({+ const result = getNodeEditResult({project, edits});+ return {+ ...result,+ results,+ formatted: true,+ updatedNodes: changes.map(({node}) =>+ getUpdatedNodeReference({...result, node}),+ ),+ };+};++export const updateJsxNodeProps = <Project extends CodemodProject>({+ project,+ prettierConfigOverride,+ ...change+}: UpdateJsxNodePropsOptions<Project>) => {+ const result = updateMultipleJsxNodeProps({project,- edits: [{filePath, output: edit.output, nodePathRemappings}],+ changes: [change],+ prettierConfigOverride,});- return {...result, updatedNode: getUpdatedNodeReference({...result, node})};+ return {+ ...result,+ ...result.results[0],+ updatedNode: result.updatedNodes[0],+ };};diff --git a/packages/player-example/src/BrowserBundlerExample.tsx b/packages/player-example/src/BrowserBundlerExample.tsxindex 13f4c93a9a..6c553d5d09 100644--- a/packages/player-example/src/BrowserBundlerExample.tsx+++ b/packages/player-example/src/BrowserBundlerExample.tsx@@ -3,7 +3,7 @@ import {createBrowserBundler,type VirtualProject,} from '@remotion/browser-bundler';-import {CodemodsInternals, addSolid, deleteJsxNodes} from '@remotion/codemods';+import {addSolid, deleteJsxNodes, getJsxNodes} from '@remotion/codemods';import Link from 'next/link';import React, {useCallback, useEffect, useRef, useState} from 'react';import type {@@ -163,8 +163,13 @@ export const BrowserBundlerExample: React.FC = () => {// Coalesce edits before compilation, but never discard a compiled// update: the next HMR update builds on this bundle's module graph.- const sourceNodes = CodemodsInternals.getJsxElementsWithNodePaths({- source: videoSource,+ const sourceNodes = getJsxNodes({+ project: {+ ...project,+ rootDir: '/',+ files: {...project.files, 'src/Video.tsx': videoSource},+ },+ filePath: 'src/Video.tsx',}).filter(({tagName}) => layerElementNames.has(tagName)).map(({nodePath}) => ({filePath: 'src/Video.tsx', nodePath}));diff --git a/packages/studio-server/src/codemods/apply-codemod-to-file.ts b/packages/studio-server/src/codemods/apply-codemod-to-file.tsindex 92ca241389..8ce0110db0 100644--- a/packages/studio-server/src/codemods/apply-codemod-to-file.ts+++ b/packages/studio-server/src/codemods/apply-codemod-to-file.ts@@ -1,5 +1,20 @@-import {existsSync, readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {existsSync} from 'node:fs';+import {readFile} from 'node:fs/promises';+import path from 'node:path';+import {+ CodemodsInternals,+ addComposition,+ addFolder,+ deleteComposition,+ duplicateComposition,+ moveComposition,+ moveFolder,+ renameComposition,+ renameFolder,+ unwrapFolder,+ updateCompositionMetadata,+ type CompositionDestination,+} from '@remotion/codemods';import type {RecastCodemod,SymbolicatedStackFrame,@@ -32,7 +47,7 @@ export const resolveFilePathFromSymbolicatedStack = (return absolutePath;};-export const applyCodemodToFile = ({+export const applyCodemodToFile = async ({filePath,codeMod,}: {@@ -41,11 +56,147 @@ export const applyCodemodToFile = ({}): Promise<string> => {checkIfTypeScriptFile(filePath);- const input = readFileSync(filePath, 'utf-8');- const {newContents} = parseAndApplyCodemod({- codeMod,- input,- });+ const input = await readFile(filePath, 'utf-8');+ const options = {+ project: {files: {[filePath]: input}, rootDir: path.dirname(filePath)},+ compositionFile: filePath,+ };+ if (+ codeMod.type === 'apply-visual-control' ||+ (codeMod.type === 'new-composition' && codeMod.canvasCapture !== null)+ ) {+ return parseAndApplyCodemod({input, codeMod}).newContents;+ }++ if (codeMod.type === 'new-composition') {+ return addComposition({+ ...options,+ compositionId: codeMod.newId,+ component: {+ importName: codeMod.componentName,+ importPath: codeMod.componentImportPath,+ },+ metadata: {+ width: codeMod.newWidth,+ height: codeMod.newHeight,+ fps: codeMod.newFps,+ durationInFrames: codeMod.newDurationInFrames,+ },+ folder:+ codeMod.folderName === null+ ? undefined+ : {name: codeMod.folderName, parentName: codeMod.parentName},+ }).project.files[filePath];+ }++ if (codeMod.type === 'rename-composition') {+ return renameComposition({+ ...options,+ compositionId: codeMod.idToRename,+ newId: codeMod.newId,+ }).project.files[filePath];+ }++ if (codeMod.type === 'delete-composition') {+ return deleteComposition({...options, compositionId: codeMod.idToDelete})+ .project.files[filePath];+ }++ if (+ codeMod.type === 'duplicate-composition' ||+ codeMod.type === 'update-composition-metadata'+ ) {+ const metadata = {+ width: codeMod.newWidth ?? undefined,+ height: codeMod.newHeight ?? undefined,+ fps:+ codeMod.type === 'duplicate-composition' && codeMod.tag === 'Still'+ ? undefined+ : (codeMod.newFps ?? undefined),+ durationInFrames:+ codeMod.type === 'duplicate-composition' && codeMod.tag === 'Still'+ ? undefined+ : (codeMod.newDurationInFrames ?? undefined),+ };+ const result =+ codeMod.type === 'duplicate-composition'+ ? duplicateComposition({+ ...options,+ compositionId: codeMod.idToDuplicate,+ newId: codeMod.newId,+ tag: codeMod.tag,+ metadata,+ })+ : updateCompositionMetadata({+ ...options,+ compositionId: codeMod.idToUpdate,+ metadata,+ });+ return result.project.files[filePath];+ }++ if (codeMod.type === 'move-composition-to-folder') {+ return moveComposition({+ ...options,+ compositionId: codeMod.idToMove,+ destination:+ codeMod.folderName === null+ ? {type: 'root'}+ : {+ type: 'folder',+ folder: {+ name: codeMod.folderName,+ parentName: codeMod.parentName,+ },+ },+ }).project.files[filePath];+ }++ if (codeMod.type === 'move-composition-or-folder') {+ const target = codeMod.destination;+ const destination: CompositionDestination =+ target.type === 'root'+ ? target+ : target.type === 'folder'+ ? {+ type: 'folder',+ folder: {name: target.folderName, parentName: target.parentName},+ }+ : {+ type: target.type,+ target:+ target.target.type === 'composition'+ ? target.target+ : {+ type: 'folder',+ name: target.target.folderName,+ parentName: target.target.parentName,+ },+ };+ const result =+ codeMod.source.type === 'composition'+ ? moveComposition({+ ...options,+ compositionId: codeMod.source.compositionId,+ destination,+ })+ : moveFolder({+ ...options,+ folder: {+ name: codeMod.source.folderName,+ parentName: codeMod.source.parentName,+ },+ destination,+ });+ return result.project.files[filePath];+ }- return Promise.resolve(newContents);+ const folder = {name: codeMod.folderName, parentName: codeMod.parentName};+ const folderResult =+ codeMod.type === 'new-folder'+ ? addFolder({...options, folder})+ : codeMod.type === 'rename-folder'+ ? renameFolder({...options, folder, newName: codeMod.newName})+ : unwrapFolder({...options, folder});+ return folderResult.project.files[filePath];};diff --git a/packages/studio-server/src/codemods/delete-jsx-nodes.ts b/packages/studio-server/src/codemods/delete-jsx-nodes.tsdeleted file mode 100644index a7cc0dc142..0000000000--- a/packages/studio-server/src/codemods/delete-jsx-nodes.ts+++ /dev/null@@ -1,27 +0,0 @@-import {CodemodsInternals} from '@remotion/codemods';-import type {SequenceNodePath} from 'remotion';--const {- deleteJsxElementAtPath,- deleteJsxNodes: deleteJsxNodesCodemod,- findJsxElementPathForDeletion,- getJsxElementTagLabel,-} = CodemodsInternals;--export {- deleteJsxElementAtPath,- findJsxElementPathForDeletion,- getJsxElementTagLabel,-};--export const deleteJsxNodes = ({- input,- nodePaths,-}: {- input: string;- nodePaths: SequenceNodePath[];-}) =>- deleteJsxNodesCodemod({- input,- nodePaths,- });diff --git a/packages/studio-server/src/codemods/split-jsx-sequence.ts b/packages/studio-server/src/codemods/split-jsx-sequence.tsdeleted file mode 100644index 166e7625dc..0000000000--- a/packages/studio-server/src/codemods/split-jsx-sequence.ts+++ /dev/null@@ -1,47 +0,0 @@-import {CodemodsInternals} from '@remotion/codemods';-import type {SequenceNodePath} from 'remotion';--const {- splitJsxSequence: splitJsxSequenceCodemod,- splitJsxSequences: splitJsxSequencesCodemod,-} = CodemodsInternals;--export const splitJsxSequence = ({- input,- nodePath,- sequenceKeys,- splitFrame,- prettierConfigOverride,-}: {- input: string;- nodePath: SequenceNodePath;- sequenceKeys: string[];- splitFrame: number;- prettierConfigOverride?: Record<string, unknown> | null;-}) =>- splitJsxSequenceCodemod({- input,- nodePath,- sequenceKeys,- splitFrame,- prettierConfigOverride,- });--export const splitJsxSequences = ({- input,- splits,- prettierConfigOverride,-}: {- input: string;- splits: Array<{- nodePath: SequenceNodePath;- sequenceKeys: string[];- splitFrame: number;- }>;- prettierConfigOverride?: Record<string, unknown> | null;-}) =>- splitJsxSequencesCodemod({- input,- splits,- prettierConfigOverride,- });diff --git a/packages/studio-server/src/codemods/update-effect-props/update-effect-props.ts b/packages/studio-server/src/codemods/update-effect-props/update-effect-props.tsindex f3d74b83ff..0173b5642b 100644--- a/packages/studio-server/src/codemods/update-effect-props/update-effect-props.ts+++ b/packages/studio-server/src/codemods/update-effect-props/update-effect-props.ts@@ -1,11 +1,12 @@-import type {JSXAttribute} from '@babel/types';import {CodemodsInternals,+ updateEffectProps as updateEffectPropsInProject,type EffectArrayElement,type EffectPropUpdate,type PropDelta,type UpdateEffectPropsResult,} from '@remotion/codemods';+import type {InteractivitySchema, SequenceNodePath} from 'remotion';export type {EffectArrayElement,@@ -14,19 +15,26 @@ export type {UpdateEffectPropsResult,};-export const {- enumerateEffectArrayElements,- findEffectCallExpression,- updateEffectProps,- updateEffectPropsAst,-} = CodemodsInternals;+export const {enumerateEffectArrayElements} = CodemodsInternals;-const {findEffectsAttr: findEffectsAttrCodemod} = CodemodsInternals;--export const findEffectsAttr = (- attrs: readonly (JSXAttribute | unknown)[],-): JSXAttribute | null => {- return findEffectsAttrCodemod(- attrs as Parameters<typeof findEffectsAttrCodemod>[0],- );+export const updateEffectProps = async ({+ input,+ sequenceNodePath,+ effectIndex,+ update,+ schema,+}: {+ input: string;+ sequenceNodePath: SequenceNodePath;+ effectIndex: number;+ update: EffectPropUpdate;+ schema: InteractivitySchema;+}): Promise<UpdateEffectPropsResult> => {+ const result = await updateEffectPropsInProject({+ project: {files: {'source.tsx': input}, rootDir: '/'},+ effect: {filePath: 'source.tsx', nodePath: sequenceNodePath, effectIndex},+ updates: [update],+ schema,+ });+ return {...result.results[0], output: result.project.files['source.tsx']};};diff --git a/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts b/packages/studio-server/src/codemods/update-keyframes/update-keyframes.tsindex a1097b1de6..042db7533f 100644--- a/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts+++ b/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts@@ -1,10 +1,16 @@import {- CodemodsInternals,+ updateJsxNodeKeyframes,+ updateEffectKeyframes as updateEffectKeyframesInProject,type EffectKeyframeUpdate,type IntroducedKeyframeIdentifiers,type KeyframeOperation,type SequenceKeyframeUpdate,} from '@remotion/codemods';+import type {+ InteractivitySchema,+ SequenceNodePath,+ VideoConfigValues,+} from 'remotion';export type {EffectKeyframeUpdate,@@ -13,26 +19,44 @@ export type {SequenceKeyframeUpdate,};-export const {updateEffectKeyframesAst, updateSequenceKeyframesAst} =- CodemodsInternals;--const {- updateEffectKeyframes: updateEffectKeyframesCodemod,- updateSequenceKeyframes: updateSequenceKeyframesCodemod,-} = CodemodsInternals;--type UpdateSequenceKeyframesInput = Omit<- Parameters<typeof updateSequenceKeyframesCodemod>[0],- 'formatFile'->;--type UpdateEffectKeyframesInput = Omit<- Parameters<typeof updateEffectKeyframesCodemod>[0],- 'formatFile'->;+type KeyframeInput = {+ input: string;+ updates: SequenceKeyframeUpdate[];+ schema?: InteractivitySchema;+ prettierConfigOverride?: Record<string, unknown> | null;+ videoConfigValues: VideoConfigValues | null;+};-export const updateSequenceKeyframes = (input: UpdateSequenceKeyframesInput) =>- updateSequenceKeyframesCodemod(input);+export const updateSequenceKeyframes = async ({+ input,+ nodePath,+ videoConfigValues,+ ...options+}: KeyframeInput & {nodePath: SequenceNodePath}) => {+ const result = await updateJsxNodeKeyframes({+ project: {files: {'source.tsx': input}, rootDir: '/'},+ node: {filePath: 'source.tsx', nodePath},+ videoConfig: videoConfigValues ?? undefined,+ ...options,+ });+ return {...result, output: result.project.files['source.tsx']};+};-export const updateEffectKeyframes = (input: UpdateEffectKeyframesInput) =>- updateEffectKeyframesCodemod(input);+export const updateEffectKeyframes = async ({+ input,+ sequenceNodePath,+ effectIndex,+ videoConfigValues,+ ...options+}: KeyframeInput & {+ sequenceNodePath: SequenceNodePath;+ effectIndex: number;+}) => {+ const result = await updateEffectKeyframesInProject({+ project: {files: {'source.tsx': input}, rootDir: '/'},+ effect: {filePath: 'source.tsx', nodePath: sequenceNodePath, effectIndex},+ videoConfig: videoConfigValues ?? undefined,+ ...options,+ });+ return {...result, output: result.project.files['source.tsx']};+};diff --git a/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts b/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.tsindex 1978e35b9d..6cb6f14c90 100644--- a/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts+++ b/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts@@ -1,6 +1,5 @@-import type {File} from '@babel/types';import {- CodemodsInternals,+ updateMultipleJsxNodeProps,type RemovedProp,type SequencePropsNodeUpdate,type SequencePropsNodeUpdateResult,@@ -12,17 +11,11 @@ import type {VideoConfigValues,} from 'remotion';-const {- updateMultipleSequenceProps: updateMultipleSequencePropsCodemod,- updateSequencePropsAst,-} = CodemodsInternals;-export {type RemovedProp,type SequencePropsNodeUpdate,type SequencePropsNodeUpdateResult,type SequencePropUpdate,- updateSequencePropsAst,};type PrettierConfigOverride = Record<string, unknown> | null;@@ -31,7 +24,6 @@ type UpdateMultipleSequencePropsResult = {output: string;formatted: boolean;results: SequencePropsNodeUpdateResult[];- ast: File;};type UpdateSequencePropsResult = {@@ -46,22 +38,28 @@ export const updateMultipleSequenceProps = ({input,changes,prettierConfigOverride,- ast: providedAst,}: {input: string;changes: SequencePropsNodeUpdate[];prettierConfigOverride: PrettierConfigOverride;- ast?: File;}): Promise<UpdateMultipleSequencePropsResult> => {return Promise.resolve().then(() => {- const {output, results, ast} = updateMultipleSequencePropsCodemod({- input,- changes,- ast: providedAst,+ const result = updateMultipleJsxNodeProps({+ project: {files: {'source.tsx': input}, rootDir: '/'},+ changes: changes.map(+ ({nodePath, updates, schema, videoConfigValues}) => ({+ node: {filePath: 'source.tsx', nodePath},+ updates,+ schema,+ videoConfig: videoConfigValues ?? undefined,+ }),+ ),prettierConfigOverride,});+ const output = result.project.files['source.tsx'];+ const {results} = result;- return {output, formatted: true, results, ast};+ return {output, formatted: true, results};});};diff --git a/packages/studio-server/src/preview-server/routes/add-effect.ts b/packages/studio-server/src/preview-server/routes/add-effect.tsindex 210098a58b..8109e8eb1f 100644--- a/packages/studio-server/src/preview-server/routes/add-effect.ts+++ b/packages/studio-server/src/preview-server/routes/add-effect.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {addEffect} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {AddEffectRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {addEffect} = CodemodsInternals;-export const addEffectHandler: ApiHandler<AddEffectRequest,AddEffectResponse@@ -52,14 +50,16 @@ export const addEffectHandler: ApiHandler<});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, formatted, effectLabel, nodeLabel, logLine} =- await addEffect({- input: fileContents,- sequenceNodePath: sequenceNodePath.nodePath,- effectName,- effectImportPath,- effectConfig,- });+ const result = await addEffect({+ project: {files: {[absolutePath]: fileContents}, rootDir: remotionRoot},+ node: {filePath: absolutePath, nodePath: sequenceNodePath.nodePath},+ importName: effectName,+ importPath: effectImportPath,+ props: effectConfig,+ });+ const output = result.project.files[absolutePath];+ const {formatted, effectLabel, nodeLabel, logLine} =+ result.editDetails[0];pushToUndoStack({filePath: absolutePath,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 3292aeba3e..4824e274c9 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@@ -74,13 +74,6 @@ let cachedSequencePropsStatusAst: {videoConfigIdentifierValues: Map<string, VideoConfigIdentifierValues>;} | null = null;-// A subsequent save can consume the last read-only snapshot if the file has-// not changed. The save mutates the AST, so it must only be reused once.-let reusableSequencePropsStatusAst: {- fileContents: string;- ast: File;-} | null = null;-const getCachedSequencePropsStatusAst = (fileContents: string) => {if (cachedSequencePropsStatusAst?.fileContents !== fileContents) {const snapshot = {@@ -92,7 +85,6 @@ const getCachedSequencePropsStatusAst = (fileContents: string) => {>(),};cachedSequencePropsStatusAst = snapshot;- reusableSequencePropsStatusAst = snapshot;queueMicrotask(() => {if (cachedSequencePropsStatusAst === snapshot) {cachedSequencePropsStatusAst = null;@@ -103,22 +95,6 @@ const getCachedSequencePropsStatusAst = (fileContents: string) => {return cachedSequencePropsStatusAst;};-export const takeCachedSequencePropsStatusAst = (- fileContents: string,-): File | null => {- if (reusableSequencePropsStatusAst?.fileContents !== fileContents) {- return null;- }-- const {ast} = reusableSequencePropsStatusAst;- reusableSequencePropsStatusAst = null;- if (cachedSequencePropsStatusAst?.ast === ast) {- cachedSequencePropsStatusAst = null;- }-- return ast;-};-const staticStatus = (codeValue: unknown,numericExpression: VideoConfigNumericExpression | null,@@ -2027,37 +2003,6 @@ const computeSequencePropsStatusFromAstAndIdentifiers = ({};};-export const computeSequencePropsStatusFromAst = ({- ast,- nodePath,- componentIdentity,- keys,- assetKeys = [],- effects,- videoConfigValues,-}: {- ast: File;- nodePath: SequenceNodePath;- componentIdentity: JsxComponentIdentity | null;- keys: string[];- assetKeys?: string[];- effects: string[][];- videoConfigValues: VideoConfigValues | null;-}): CanUpdateSequencePropsResponseTrue => {- return computeSequencePropsStatusFromAstAndIdentifiers({- ast,- nodePath,- componentIdentity,- keys,- assetKeys,- effects,- videoConfigIdentifierValues: getVideoConfigIdentifierValues({- ast,- videoConfigValues,- }),- });-};-export const computeSequencePropsStatusFromContent = ({fileContents,nodePath,diff --git a/packages/studio-server/src/preview-server/routes/delete-effect.ts b/packages/studio-server/src/preview-server/routes/delete-effect.tsindex 919ee615bb..d34c173fae 100644--- a/packages/studio-server/src/preview-server/routes/delete-effect.ts+++ b/packages/studio-server/src/preview-server/routes/delete-effect.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {deleteEffects} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {DeleteEffectRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {deleteEffects} = CodemodsInternals;-const getDeletedEffectDescription = (effectLabels: string[]): string => {if (effectLabels.length === 1) {return effectLabels[0];@@ -62,22 +60,20 @@ export const deleteEffectHandler: ApiHandler<});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, formatted, effectLabels, logLines} =- await deleteEffects({- input: fileContents,- effects: fileItems.map((item) =>- item.type === 'single-effect'- ? {- type: 'single-effect',- sequenceNodePath: item.sequenceNodePath.nodePath,- effectIndex: item.effectIndex,- }- : {- type: 'all-effects',- sequenceNodePath: item.sequenceNodePath.nodePath,- },- ),- });+ const result = await deleteEffects({+ project: {+ files: {[absolutePath]: fileContents},+ rootDir: remotionRoot,+ },+ effects: fileItems.map((item) => ({+ filePath: absolutePath,+ nodePath: item.sequenceNodePath.nodePath,+ effectIndex:+ item.type === 'all-effects' ? null : item.effectIndex,+ })),+ });+ const output = result.project.files[absolutePath];+ const {formatted, effectLabels, logLines} = result.editDetails[0];return {absolutePath,diff --git a/packages/studio-server/src/preview-server/routes/delete-jsx-nodes.ts b/packages/studio-server/src/preview-server/routes/delete-jsx-nodes.tsindex 074112c4fb..7ef4f02971 100644--- a/packages/studio-server/src/preview-server/routes/delete-jsx-nodes.ts+++ b/packages/studio-server/src/preview-server/routes/delete-jsx-nodes.ts@@ -1,10 +1,10 @@import {readFileSync} from 'node:fs';+import {deleteJsxNodes} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {DeleteJsxNodesRequest,DeleteJsxNodesResponse,} from '@remotion/studio-shared';-import {deleteJsxNodes} from '../../codemods/delete-jsx-nodes';import {writeFileAndNotifyFileWatchers} from '../../file-watcher';import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';import type {ApiHandler} from '../api-types';@@ -67,11 +67,21 @@ export const deleteJsxNodesHandler: ApiHandler<const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, nodeLabels, logLines, nodePathRemappings} =- await deleteJsxNodes({- input: fileContents,- nodePaths: fileItems.map((item) => item.nodePath),- });+ const result = await deleteJsxNodes({+ project: {+ files: {[absolutePath]: fileContents},+ rootDir: remotionRoot,+ },+ nodes: fileItems.map((item) => ({+ filePath: absolutePath,+ nodePath: item.nodePath,+ })),+ });+ const output = result.project.files[absolutePath];+ const {nodeLabels, logLines} = result.editDetails[0];+ const nodePathRemappings = result.nodePathRemappings.map(+ ({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath}),+ );return {absolutePath,diff --git a/packages/studio-server/src/preview-server/routes/duplicate-effect.ts b/packages/studio-server/src/preview-server/routes/duplicate-effect.tsindex 8fc7e4d175..31a6376c6c 100644--- a/packages/studio-server/src/preview-server/routes/duplicate-effect.ts+++ b/packages/studio-server/src/preview-server/routes/duplicate-effect.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {duplicateEffects} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {DuplicateEffectRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {duplicateEffects} = CodemodsInternals;-const getDuplicatedEffectDescription = (effectLabels: string[]): string => {if (effectLabels.length === 1) {return effectLabels[0];@@ -62,14 +60,19 @@ export const duplicateEffectHandler: ApiHandler<});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, formatted, effectLabels, logLines} =- await duplicateEffects({- input: fileContents,- effects: fileItems.map((item) => ({- sequenceNodePath: item.sequenceNodePath.nodePath,- effectIndex: item.effectIndex,- })),- });+ const result = await duplicateEffects({+ project: {+ files: {[absolutePath]: fileContents},+ rootDir: remotionRoot,+ },+ effects: fileItems.map((item) => ({+ filePath: absolutePath,+ nodePath: item.sequenceNodePath.nodePath,+ effectIndex: item.effectIndex,+ })),+ });+ const output = result.project.files[absolutePath];+ const {formatted, effectLabels, logLines} = result.editDetails[0];return {absolutePath,diff --git a/packages/studio-server/src/preview-server/routes/duplicate-jsx-node.ts b/packages/studio-server/src/preview-server/routes/duplicate-jsx-node.tsindex 2438e4aa55..e46867502e 100644--- a/packages/studio-server/src/preview-server/routes/duplicate-jsx-node.ts+++ b/packages/studio-server/src/preview-server/routes/duplicate-jsx-node.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {duplicateJsxNodes} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {DuplicateJsxNodeRequest,@@ -20,8 +20,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {duplicateJsxNodes} = CodemodsInternals;-export const duplicateJsxNodeHandler: ApiHandler<DuplicateJsxNodeRequest,DuplicateJsxNodeResponse@@ -52,11 +50,21 @@ export const duplicateJsxNodeHandler: ApiHandler<action: 'modify',});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, nodeLabels, logLines, nodePathRemappings} =- await duplicateJsxNodes({- input: fileContents,- nodePaths: fileItems.map((item) => item.nodePath),- });+ const result = await duplicateJsxNodes({+ project: {+ files: {[absolutePath]: fileContents},+ rootDir: remotionRoot,+ },+ nodes: fileItems.map((item) => ({+ filePath: absolutePath,+ nodePath: item.nodePath,+ })),+ });+ const output = result.project.files[absolutePath];+ const {nodeLabels, logLines} = result.editDetails[0];+ const nodePathRemappings = result.nodePathRemappings.map(+ ({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath}),+ );return {absolutePath,diff --git a/packages/studio-server/src/preview-server/routes/reorder-effect.ts b/packages/studio-server/src/preview-server/routes/reorder-effect.tsindex ceffff5ebe..58cc004073 100644--- a/packages/studio-server/src/preview-server/routes/reorder-effect.ts+++ b/packages/studio-server/src/preview-server/routes/reorder-effect.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {reorderEffect} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {ReorderEffectRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {reorderEffect} = CodemodsInternals;-export const reorderEffectHandler: ApiHandler<ReorderEffectRequest,ReorderEffectResponse@@ -45,12 +43,17 @@ export const reorderEffectHandler: ApiHandler<});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, formatted, effectLabel, logLine} = await reorderEffect({- input: fileContents,- sequenceNodePath: sequenceNodePath.nodePath,- fromIndex,+ const result = await reorderEffect({+ project: {files: {[absolutePath]: fileContents}, rootDir: remotionRoot},+ effect: {+ filePath: absolutePath,+ nodePath: sequenceNodePath.nodePath,+ effectIndex: fromIndex,+ },toIndex,});+ const output = result.project.files[absolutePath];+ const {formatted, effectLabel, logLine} = result.editDetails[0];pushToUndoStack({filePath: absolutePath,diff --git a/packages/studio-server/src/preview-server/routes/reorder-sequence.ts b/packages/studio-server/src/preview-server/routes/reorder-sequence.tsindex 9bfae7eee0..7d405110ab 100644--- a/packages/studio-server/src/preview-server/routes/reorder-sequence.ts+++ b/packages/studio-server/src/preview-server/routes/reorder-sequence.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {reorderJsxNode} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {ReorderSequenceRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {reorderSequence} = CodemodsInternals;-export const reorderSequenceHandler: ApiHandler<ReorderSequenceRequest,ReorderSequenceResponse@@ -45,13 +43,17 @@ export const reorderSequenceHandler: ApiHandler<});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, sequenceLabel, logLine, nodePathRemappings} =- await reorderSequence({- input: fileContents,- sourceNodePath: sourceNodePath.nodePath,- targetNodePath: targetNodePath.nodePath,- position,- });+ const result = await reorderJsxNode({+ project: {files: {[absolutePath]: fileContents}, rootDir: remotionRoot},+ node: {filePath: absolutePath, nodePath: sourceNodePath.nodePath},+ target: {filePath: absolutePath, nodePath: targetNodePath.nodePath},+ position,+ });+ const output = result.project.files[absolutePath];+ const {sequenceLabel, logLine} = result.editDetails[0];+ const nodePathRemappings = result.nodePathRemappings.map(+ ({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath}),+ );const nodePathMutation = broadcastSequenceNodePathMutation([{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 27e38e5f83..f372a4eeb7 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@@ -1,5 +1,4 @@import {readFileSync} from 'node:fs';-import type {File} from '@babel/types';import {CodemodsInternals} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {@@ -32,11 +31,7 @@ import {suppressUndoStackInvalidation,} from '../undo-stack';import {suppressBundlerUpdateForFile} from '../watch-ignore-next-change';-import {- computeSequencePropsStatusFromAst,- computeSequencePropsStatusFromContent,- takeCachedSequencePropsStatusAst,-} from './can-update-sequence-props';+import {computeSequencePropsStatusFromContent} from './can-update-sequence-props';import {logEffectUpdate} from './log-updates/log-effect-update';import {logUpdate} from './log-updates/log-update';import {withSourceFileWriteQueue} from './source-file-write-queue';@@ -360,7 +355,6 @@ export const saveSequencePropsHandler: ApiHandler<const snapshots: SequencePropUndoSnapshot[] = [];const outputByPath = new Map<string, string>();- const statusAstByPath = new Map<string, File>();const resultByIndex = new Map<number, SequencePropEditResult>();const updatedNodePaths = new Map<string, SequenceNodePath>();const sequenceKeyframeLogs: SequenceKeyframeLog[] = [];@@ -370,11 +364,6 @@ export const saveSequencePropsHandler: ApiHandler<for (const [absolutePath, group] of editGroups) {const fileContents = readFileSync(absolutePath, 'utf-8');let output = fileContents;- const cachedStatusAst =- group.edits.length > 0- ? takeCachedSequencePropsStatusAst(fileContents)- : null;- let sequencePropsAst: File | null = null;let firstLogLine = Number.POSITIVE_INFINITY;if (group.edits.length > 0) {@@ -382,15 +371,12 @@ export const saveSequencePropsHandler: ApiHandler<output: sequencePropsOutput,formatted,results: updateResults,- ast,} = await updateMultipleSequenceProps({input: output,changes: group.edits.map(convertSequencePropEditToCodemodChange),prettierConfigOverride: null,- ast: cachedStatusAst ?? undefined,});output = sequencePropsOutput;- sequencePropsAst = ast;const firstUpdate = updateResults[0];if (firstUpdate) {firstLogLine = Math.min(firstLogLine, firstUpdate.logLine);@@ -592,16 +578,6 @@ export const saveSequencePropsHandler: ApiHandler<}}- if (- sequencePropsAst &&- group.captionPatches.length === 0 &&- group.addedKeyframes.length === 0 &&- group.movedSequenceKeyframes.length === 0 &&- group.effectKeyframes.length === 0- ) {- statusAstByPath.set(absolutePath, sequencePropsAst);- }-outputByPath.set(absolutePath, output);snapshots.push({filePath: absolutePath,@@ -744,16 +720,10 @@ export const saveSequencePropsHandler: ApiHandler<effects: [],videoConfigValues: target.nodePath.videoConfigValues,};- const statusAst = statusAstByPath.get(absolutePath);- const newStatus = statusAst- ? computeSequencePropsStatusFromAst({- ...statusInput,- ast: statusAst,- })- : computeSequencePropsStatusFromContent({- ...statusInput,- fileContents: output,- });+ const newStatus = computeSequencePropsStatusFromContent({+ ...statusInput,+ fileContents: output,+ });return {fileName: target.fileName,diff --git a/packages/studio-server/src/preview-server/routes/split-jsx-sequence.ts b/packages/studio-server/src/preview-server/routes/split-jsx-sequence.tsindex 3561471aaf..95fa367505 100644--- a/packages/studio-server/src/preview-server/routes/split-jsx-sequence.ts+++ b/packages/studio-server/src/preview-server/routes/split-jsx-sequence.ts@@ -1,10 +1,10 @@import {readFileSync} from 'node:fs';+import {splitSequences} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {SplitJsxSequenceRequest,SplitJsxSequenceResponse,} from '@remotion/studio-shared';-import {splitJsxSequences} from '../../codemods/split-jsx-sequence';import {writeFileAndNotifyFileWatchers} from '../../file-watcher';import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';import type {ApiHandler} from '../api-types';@@ -49,17 +49,24 @@ export const splitJsxSequenceHandler: ApiHandler<action: 'modify',});const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, nodeLabels, logLines, nodePathRemappings} =- await splitJsxSequences({- input: fileContents,- splits: fileSequences.map(- ({nodePath, sequenceKeys, splitFrame}) => ({- nodePath,- sequenceKeys,- splitFrame,- }),- ),- });+ const result = await splitSequences({+ project: {+ files: {[absolutePath]: fileContents},+ rootDir: remotionRoot,+ },+ splits: fileSequences.map(+ ({nodePath, sequenceKeys, splitFrame}) => ({+ node: {filePath: absolutePath, nodePath},+ sequenceKeys,+ frame: splitFrame,+ }),+ ),+ });+ const output = result.project.files[absolutePath];+ const {nodeLabels, logLines} = result.editDetails[0];+ const nodePathRemappings = result.nodePathRemappings.map(+ ({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath}),+ );return {absolutePath,diff --git a/packages/studio-server/src/preview-server/routes/split-video-from-audio.ts b/packages/studio-server/src/preview-server/routes/split-video-from-audio.tsindex 681d420ea5..d02c91d2f7 100644--- a/packages/studio-server/src/preview-server/routes/split-video-from-audio.ts+++ b/packages/studio-server/src/preview-server/routes/split-video-from-audio.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {detachAudio} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {SplitVideoFromAudioRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {splitVideoFromAudio} = CodemodsInternals;-export const splitVideoFromAudioHandler: ApiHandler<SplitVideoFromAudioRequest,SplitVideoFromAudioResponse@@ -41,11 +39,15 @@ export const splitVideoFromAudioHandler: ApiHandler<const fileContents = readFileSync(absolutePath, 'utf-8');- const {output, formatted, nodeLabel, logLine, nodePathRemappings} =- await splitVideoFromAudio({- input: fileContents,- nodePath,- });+ const result = await detachAudio({+ project: {files: {[absolutePath]: fileContents}, rootDir: remotionRoot},+ node: {filePath: absolutePath, nodePath},+ });+ const output = result.project.files[absolutePath];+ const {formatted, nodeLabel, logLine} = result.editDetails[0];+ const nodePathRemappings = result.nodePathRemappings.map(+ ({oldNodePath, newNodePath}) => ({oldNodePath, newNodePath}),+ );const nodePathMutation = broadcastSequenceNodePathMutation([{diff --git a/packages/studio-server/src/preview-server/routes/update-default-props.ts b/packages/studio-server/src/preview-server/routes/update-default-props.tsindex 6343611ac2..bd25a0e757 100644--- a/packages/studio-server/src/preview-server/routes/update-default-props.ts+++ b/packages/studio-server/src/preview-server/routes/update-default-props.ts@@ -1,5 +1,5 @@import {readFileSync} from 'node:fs';-import {CodemodsInternals} from '@remotion/codemods';+import {setCompositionDefaultProps} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {UpdateDefaultPropsRequest,@@ -21,8 +21,6 @@ import {withSourceFileWriteQueue,} from './source-file-write-queue';-const {getCompositionDefaultPropsLine, updateDefaultProps} = CodemodsInternals;-export const updateDefaultPropsHandler: ApiHandler<UpdateDefaultPropsRequest,UpdateDefaultPropsResponse@@ -46,16 +44,18 @@ export const updateDefaultPropsHandler: ApiHandler<checkIfTypeScriptFile(projectInfo.rootFile);const fileContents = readFileSync(projectInfo.rootFile, 'utf-8');- const logLine = getCompositionDefaultPropsLine({- input: fileContents,- compositionId,- });- const {output} = updateDefaultProps({+ const result = setCompositionDefaultProps({+ project: {+ files: {[projectInfo.rootFile]: fileContents},+ rootDir: remotionRoot,+ },+ compositionFile: projectInfo.rootFile,compositionId,- input: fileContents,- newDefaultProps: JSON.parse(defaultProps),+ defaultProps: JSON.parse(defaultProps),enumPaths,});+ const {logLine} = result;+ const output = result.project.files[projectInfo.rootFile];pushToUndoStack({filePath: projectInfo.rootFile,diff --git a/packages/studio-server/src/test/apply-codemod.test.ts b/packages/studio-server/src/test/apply-codemod.test.tsindex 6eb74cff9e..62835f45a7 100644--- a/packages/studio-server/src/test/apply-codemod.test.ts+++ b/packages/studio-server/src/test/apply-codemod.test.ts@@ -219,7 +219,8 @@ export const Root = () => <Folder name="Before" />;test('metadata codemods do not run Prettier after applying source edits', async () => {const remotionRoot = mkdtempSync(path.join(tmpdir(), 'remotion-codemod-'));const filePath = path.join(remotionRoot, 'Root.tsx');- const input = `const untouched = { value : "keep" };+ const input = `import {Composition} from 'remotion';+const untouched = { value : "keep" };export const Root=()=> <Composition id='Comp' width = { WIDTH }/>;`;@@ -237,7 +238,8 @@ export const Root=()=> <Composition id='Comp' width = { WIDTH }/>;},});- expect(output).toBe(`const untouched = { value : "keep" };+ expect(output).toBe(`import {Composition} from 'remotion';+const untouched = { value : "keep" };export const Root=()=> <Composition id='Comp' width = {1920} durationInFrames={90} height={1080}/>;`);} finally {@@ -631,26 +633,34 @@ test('applyCodemodHandler logs composition renames and pushes them to the undo a});});-test('applyCodemodHandler pushes composition duplications to undo and redo stacks', async () => {- await runCompositionCodemodUndoRedoTest({- codemod: {- type: 'duplicate-composition',- idToDuplicate: 'DeleteMe',- newId: 'Duplicated',- newDurationInFrames: null,- newFps: null,- newHeight: null,- newWidth: null,- tag: 'Composition',- },- assertApplied: (contents) => {- expect(contents).toContain('id="DeleteMe"');- expect(contents).toContain('id="Duplicated"');- expect(contents).toContain('id="KeepMe"');- },- expectedUndoMessage:- '↩️ Duplication of composition "DeleteMe" to "Duplicated"',- });+test('applyCodemodHandler pushes composition and still duplications to undo and redo stacks', async () => {+ for (const tag of ['Composition', 'Still'] as const) {+ await runCompositionCodemodUndoRedoTest({+ codemod: {+ type: 'duplicate-composition',+ idToDuplicate: 'DeleteMe',+ newId: 'Duplicated',+ newDurationInFrames: 120,+ newFps: 30,+ newHeight: null,+ newWidth: null,+ tag,+ },+ assertApplied: (contents) => {+ expect(contents).toContain('id="DeleteMe"');+ expect(contents).toContain('id="Duplicated"');+ expect(contents).toContain('id="KeepMe"');+ if (tag === 'Still') {+ const still = contents.match(/<Still[\s\S]*?\/>/)?.[0];+ expect(still).toContain('id="Duplicated"');+ expect(still).not.toContain('fps=');+ expect(still).not.toContain('durationInFrames=');+ }+ },+ expectedUndoMessage:+ '↩️ Duplication of composition "DeleteMe" to "Duplicated"',+ });+ }});test('applyCodemodHandler pushes folder creations to undo and redo stacks', async () => {diff --git a/packages/studio-server/src/test/delete-jsx-nodes.test.ts b/packages/studio-server/src/test/delete-jsx-nodes.test.tsindex 5f2261a354..23b8f5bd3c 100644--- a/packages/studio-server/src/test/delete-jsx-nodes.test.ts+++ b/packages/studio-server/src/test/delete-jsx-nodes.test.ts@@ -6,7 +6,6 @@ import type {EventSourceEvent,SubscribeToSequencePropsRequest,} from '@remotion/studio-shared';-import {deleteJsxNodes} from '../codemods/delete-jsx-nodes';import {createFileWatcherRegistry,setFileWatcherRegistry,@@ -20,291 +19,7 @@ import {popRedo,popUndo,} from '../preview-server/undo-stack';-import {lineColumnToNodePath, lineContainingToNodePath} from './test-utils';--const sample = `import React from 'react';-import {AbsoluteFill} from 'remotion';--export const X: React.FC = () => {- return (- <AbsoluteFill>- <div />- </AbsoluteFill>- );-};-`;--test('deleteJsxNodes removes a JSX child from a parent element', async () => {- const {output} = await deleteJsxNodes({- input: sample,- nodePaths: [lineColumnToNodePath(sample, 7)],- });-- expect(output).not.toContain('<div');- expect(output).toContain('<AbsoluteFill>');-});--const onlyReturn = `import React from 'react';--export const X: React.FC = () => {- return <div />;-};-`;--test('deleteJsxNodes replaces sole return JSX with null', async () => {- const {output} = await deleteJsxNodes({- input: onlyReturn,- nodePaths: [lineColumnToNodePath(onlyReturn, 4)],- });-- expect(output).toContain('return null');- expect(output).not.toContain('<div');-});--const conditional = `import React from 'react';--export const X: React.FC<{show: boolean}> = ({show}) => {- return <>{show && <div />}</>;-};-`;--test('deleteJsxNodes turns conditional JSX into null', async () => {- const {output} = await deleteJsxNodes({- input: conditional,- nodePaths: [lineColumnToNodePath(conditional, 4)],- });-- expect(output).toContain('&& null');- expect(output).not.toContain('<div');-});--const ternary = `import React from 'react';--export const X: React.FC<{show: boolean}> = ({show}) => {- return <>{show ? <div /> : null}</>;-};-`;--test('deleteJsxNodes replaces JSX in ternary consequent with null', async () => {- const {output} = await deleteJsxNodes({- input: ternary,- nodePaths: [lineColumnToNodePath(ternary, 4)],- });-- expect(output).toMatch(/\?\s*null/);- expect(output).not.toContain('<div');-});--const mapCase = `import React from 'react';--export const X: React.FC = () => {- return (- <>- {[1].map((i) => (- <div key={i} />- ))}- </>- );-};-`;--test('deleteJsxNodes replaces JSX inside map callback', async () => {- const {output} = await deleteJsxNodes({- input: mapCase,- nodePaths: [lineColumnToNodePath(mapCase, 7)],- });-- expect(output).not.toContain('<div');- expect(output).toMatch(/=>\s*\(?\s*null/);-});--const multipleSiblings = `import React from 'react';-import {AbsoluteFill} from 'remotion';--export const X: React.FC = () => {- return (- <AbsoluteFill>- <div />- <span />- <p />- </AbsoluteFill>- );-};-`;--test('deleteJsxNodes removes multiple JSX children in one transform', async () => {- const {output, nodeLabels, logLines} = await deleteJsxNodes({- input: multipleSiblings,- nodePaths: [- lineColumnToNodePath(multipleSiblings, 7),- lineColumnToNodePath(multipleSiblings, 8),- ],- });-- expect(output).not.toContain('<div');- expect(output).not.toContain('<span');- expect(output).toContain('<p');- expect(nodeLabels).toEqual(['<div>', '<span>']);- expect(logLines).toEqual([7, 8]);-});--test('deleteJsxNodes preserves source formatting and removes standalone JSX lines', async () => {- const cases = [- {- input: `export const Comp = () => {- return (- <div>- <Keep />- <RemoveOne />- <RemoveTwo />- <Keep />- </div>- );-};-`,- markers: ['<RemoveOne', '<RemoveTwo'],- expected: `export const Comp = () => {- return (- <div>- <Keep />- <Keep />- </div>- );-};-`,- },- {- input: `export const Comp = () => {- return (- <div>- <Remove />- </div>- )-}-`,- markers: ['<Remove'],- expected: `export const Comp = () => {- return (- <div>- </div>- )-}-`,- },- {- input: `export const Comp = () => {- return [1].map((item) => (- <Remove key={item} />- ));-};-`,- markers: ['<Remove'],- expected: `export const Comp = () => {- return [1].map((item) => null);-};-`,- },- {- input: `const AnimatedBar = () => {- return (- <Remove />- );-};-`,- markers: ['<Remove'],- expected: `const AnimatedBar = () => {- return null;-};-`,- },- {- input: `const AnimatedBar = () => {- return (- // Keep this explanation.- <Remove />- );-};-`,- markers: ['<Remove'],- expected: `const AnimatedBar = () => {- return (- // Keep this explanation.- null- );-};-`,- },- {- input: `export const Comp = () => <div><Keep /><Remove /><Keep /></div>;-`,- markers: ['<Remove'],- expected: `export const Comp = () => <div><Keep /><Keep /></div>;-`,- },- {- input:- 'export const Comp = () => <div><Keep />\t<Remove /><Keep /></div>;\n',- markers: ['<Remove'],- expected: 'export const Comp = () => <div><Keep />\t<Keep /></div>;\n',- },- {- input: `export const Comp = () => (- <div>- <Remove /> {/* keep this comment */}- </div>-);-`,- markers: ['<Remove'],- expected: `export const Comp = () => (- <div>- {/* keep this comment */}- </div>-);-`,- },- {- input: `export const Comp = () => {- return (- <div>- <RemoveParent>- <RemoveChild />- </RemoveParent>- <Keep />- </div>- );-};-`,- markers: ['<RemoveParent', '<RemoveChild'],- expected: `export const Comp = () => {- return (- <div>- <Keep />- </div>- );-};-`,- },- {- input:- 'export const Comp = () => {\r\n\treturn (\r\n\t\t<div>\r\n\t\t\t<Remove />\r\n\t\t</div>\r\n\t);\r\n};\r\n',- markers: ['<Remove'],- expected:- 'export const Comp = () => {\r\n\treturn (\r\n\t\t<div>\r\n\t\t</div>\r\n\t);\r\n};\r\n',- },- ] as const;-- for (const item of cases) {- const {output, formatted} = await deleteJsxNodes({- input: item.input,- nodePaths: item.markers.map((marker) =>- lineContainingToNodePath(item.input, marker),- ),- });-- expect(output).toBe(item.expected);- expect(formatted).toBe(true);- }-});+import {lineColumnToNodePath} from './test-utils';const interactiveSiblings = `import {Interactive} from 'remotion';diff --git a/packages/studio-server/src/test/discriminated-union-update.test.ts b/packages/studio-server/src/test/discriminated-union-update.test.tsindex ce025b2b68..a2060fd0f0 100644--- a/packages/studio-server/src/test/discriminated-union-update.test.ts+++ b/packages/studio-server/src/test/discriminated-union-update.test.ts@@ -5,7 +5,7 @@ import path from 'node:path';import {getFieldsToShow} from '@remotion/studio-shared';import {NoReactInternals} from 'remotion/no-react';import {parseAst} from '../codemods/parse-ast';-import {updateSequencePropsAst} from '../codemods/update-sequence-props/update-sequence-props';+import {updateSequenceProps} from '../codemods/update-sequence-props/update-sequence-props';import {lineColumnToNodePath} from '../preview-server/routes/can-update-sequence-props';import {prettify} from './test-utils';@@ -75,8 +75,9 @@ test('Should be able to update a discriminated union', async () => {const nodePath = lineColumnToNodePath(ast, 3);assert(nodePath, 'No node path found');- const update = updateSequencePropsAst({+ const update = await updateSequenceProps({videoConfigValues: null,+ prettierConfigOverride: null,input: file,nodePath,updates: [@@ -94,7 +95,7 @@ test('Should be able to update a discriminated union', async () => {'utf-8',);- expect(await prettify(update.serialized)).toBe(await prettify(expected));+ expect(await prettify(update.output)).toBe(await prettify(expected));});test('Should remove variant-specific props when switching enum value', async () => {@@ -108,8 +109,9 @@ test('Should remove variant-specific props when switching enum value', async ()const nodePath = lineColumnToNodePath(ast, 3);assert(nodePath, 'No node path found');- const update = updateSequencePropsAst({+ const update = await updateSequenceProps({videoConfigValues: null,+ prettierConfigOverride: null,input: file,nodePath,updates: [@@ -131,7 +133,7 @@ test('Should remove variant-specific props when switching enum value', async ()'utf-8',);- expect(await prettify(update.serialized)).toBe(await prettify(expected));+ expect(await prettify(update.output)).toBe(await prettify(expected));});test('Should remove premountFor and preserve styleWhile* when switching to layout="none"', async () => {@@ -145,8 +147,9 @@ test('Should remove premountFor and preserve styleWhile* when switching to layouconst nodePath = lineColumnToNodePath(ast, 3);assert(nodePath, 'No node path found');- const update = updateSequencePropsAst({+ const update = await updateSequenceProps({videoConfigValues: null,+ prettierConfigOverride: null,input: file,nodePath,updates: [@@ -168,5 +171,5 @@ test('Should remove premountFor and preserve styleWhile* when switching to layou'utf-8',);- expect(await prettify(update.serialized)).toBe(await prettify(expected));+ expect(await prettify(update.output)).toBe(await prettify(expected));});diff --git a/packages/studio-server/src/test/effect-editing-routes.test.ts b/packages/studio-server/src/test/effect-editing-routes.test.tsnew file mode 100644index 0000000000..55be86273a--- /dev/null+++ b/packages/studio-server/src/test/effect-editing-routes.test.ts@@ -0,0 +1,164 @@+import {expect, test} from 'bun:test';+import {mkdtempSync, readFileSync, rmSync, writeFileSync} from 'node:fs';+import {tmpdir} from 'node:os';+import {join} from 'node:path';+import {+ createFileWatcherRegistry,+ setFileWatcherRegistry,+} from '../file-watcher';+import {setLiveEventsListener} from '../preview-server/live-events';+import {addEffectHandler} from '../preview-server/routes/add-effect';+import {deleteEffectHandler} from '../preview-server/routes/delete-effect';+import {duplicateEffectHandler} from '../preview-server/routes/duplicate-effect';+import {reorderEffectHandler} from '../preview-server/routes/reorder-effect';+import {clearUndoStackForTests, popUndo} from '../preview-server/undo-stack';+import {lineContainingToNodePath} from './test-utils';++test('effect routes persist additions, duplication, reordering, deletion, and undo', async () => {+ const remotionRoot = mkdtempSync(join(tmpdir(), 'remotion-effect-routes-'));+ const filePath = join(remotionRoot, 'Comp.tsx');+ const cleanupFileWatcher = setFileWatcherRegistry(+ createFileWatcherRegistry(),+ );+ const cleanupLiveEvents = setLiveEventsListener({+ sendEventToClient: () => undefined,+ sendEventToClientId: () => true,+ router: () => Promise.resolve(),+ closeConnections: () => Promise.resolve(),+ addNewClientListener: () => () => undefined,+ });+ const context = {+ entryPoint: filePath,+ remotionRoot,+ request: {} as never,+ response: {} as never,+ logLevel: 'error' as const,+ methods: {+ removeJob: () => undefined,+ cancelJob: () => undefined,+ addJob: () => undefined,+ },+ publicDir: remotionRoot,+ binariesDirectory: null,+ configFile: null,+ getDefaultCodingAgent: () => null,+ getDefaultEditor: () => null,+ };+ const input = `import {Solid} from 'remotion';+const untouched = { value : 'keep' };+const dimensions = {width: 100, height: 100};+const presets = [];+export const Comp = () => <>+ <Solid {...dimensions} />+ <Solid name="preset" effects={[...presets]} />+ <Solid name="overridden" effects={[...presets]} {...dimensions} />+</>;+`;++ try {+ clearUndoStackForTests();+ writeFileSync(filePath, input);+ const sequenceNodePath = {+ absolutePath: filePath,+ nodePath: lineContainingToNodePath(input, '<Solid'),+ sequenceKeys: [],+ effectKeys: [],+ videoConfigValues: null,+ };+ for (const effectName of ['brightness', 'contrast']) {+ const result = await addEffectHandler({+ ...context,+ input: {+ fileName: filePath,+ sequenceNodePath,+ effectName,+ effectImportPath: `@remotion/effects/${effectName}`,+ effectConfig: {amount: 1.2},+ clientId: 'effect-routes-test',+ },+ });+ expect(result.success).toBe(true);+ }++ const duplicate = await duplicateEffectHandler({+ ...context,+ input: [{fileName: filePath, sequenceNodePath, effectIndex: 0}],+ });+ expect(duplicate.success).toBe(true);+ expect(+ readFileSync(filePath, 'utf-8').match(/brightness\(\{/g),+ ).toHaveLength(2);++ const reorder = await reorderEffectHandler({+ ...context,+ input: {+ fileName: filePath,+ sequenceNodePath,+ fromIndex: 1,+ toIndex: 2,+ clientId: 'effect-routes-test',+ },+ });+ expect(reorder.success).toBe(true);+ const reordered = readFileSync(filePath, 'utf-8');+ expect(reordered.indexOf('brightness({')).toBeLessThan(+ reordered.indexOf('contrast({'),+ );+ expect(reordered.lastIndexOf('brightness({')).toBeGreaterThan(+ reordered.indexOf('contrast({'),+ );+ expect(reordered).toContain("const untouched = { value : 'keep' };");++ const overridden = await addEffectHandler({+ ...context,+ input: {+ fileName: filePath,+ sequenceNodePath: {+ ...sequenceNodePath,+ nodePath: lineContainingToNodePath(+ reordered,+ '<Solid name="overridden"',+ ),+ },+ effectName: 'brightness',+ effectImportPath: '@remotion/effects/brightness',+ effectConfig: {amount: 2},+ clientId: 'effect-routes-test',+ },+ });+ expect(overridden.success).toBe(false);+ expect(readFileSync(filePath, 'utf-8')).toBe(reordered);++ const deleted = await deleteEffectHandler({+ ...context,+ input: [+ {type: 'all-effects', fileName: filePath, sequenceNodePath},+ {+ type: 'all-effects',+ fileName: filePath,+ sequenceNodePath: {+ ...sequenceNodePath,+ nodePath: lineContainingToNodePath(+ reordered,+ '<Solid name="preset"',+ ),+ },+ },+ ],+ });+ expect(deleted.success).toBe(true);+ expect(readFileSync(filePath, 'utf-8')).toContain(+ '<Solid {...dimensions} />',+ );+ expect(readFileSync(filePath, 'utf-8')).toContain(+ '<Solid name="preset" />',+ );+ expect(popUndo().success).toBe(true);+ expect(readFileSync(filePath, 'utf-8')).toBe(reordered);+ } finally {+ clearUndoStackForTests();+ cleanupFileWatcher();+ cleanupLiveEvents();+ rmSync(remotionRoot, {recursive: true, force: true});+ }+});diff --git a/packages/studio-server/src/test/insert-element.test.ts b/packages/studio-server/src/test/insert-element.test.tsindex 9f5f6c04a5..ece1cd26e9 100644--- a/packages/studio-server/src/test/insert-element.test.ts+++ b/packages/studio-server/src/test/insert-element.test.ts@@ -326,6 +326,10 @@ test('invalidates a new-composition install after an external component edit', a);}+ const registration = readFileSync(fixture.compositionFile, 'utf-8');+ expect(registration).toContain('const Target = () => <div>Hello</div>;');+ expect(registration.match(/id="ElementScene"/g)).toHaveLength(1);+const componentFile = path.join(path.dirname(fixture.compositionFile),'ElementScene.tsx',diff --git a/packages/studio-server/src/test/split-jsx-sequence.test.ts b/packages/studio-server/src/test/split-jsx-sequence.test.tsindex cb7adff0da..ab4fd96f5a 100644--- a/packages/studio-server/src/test/split-jsx-sequence.test.ts+++ b/packages/studio-server/src/test/split-jsx-sequence.test.ts@@ -2,8 +2,6 @@ import {expect, test} from 'bun:test';import {mkdtempSync, readFileSync, rmSync, writeFileSync} from 'node:fs';import {tmpdir} from 'node:os';import path from 'node:path';-import {CodemodsInternals} from '@remotion/codemods';-import {splitJsxSequence} from '../codemods/split-jsx-sequence';import {createFileWatcherRegistry,setFileWatcherRegistry,@@ -11,9 +9,7 @@ import {import {setLiveEventsListener} from '../preview-server/live-events';import {splitJsxSequenceHandler} from '../preview-server/routes/split-jsx-sequence';import {getUndoStack} from '../preview-server/undo-stack';-import {lineColumnToNodePath, lineContainingToNodePath} from './test-utils';--const {splitJsxSequence: splitJsxSequenceCodemod} = CodemodsInternals;+import {lineContainingToNodePath} from './test-utils';const wrap = (sequence: string,@@ -29,243 +25,8 @@ export const Comp = () => {};`;-const sequenceLine = 7;const sequenceTimingKeys = ['from', 'durationInFrames', 'trimBefore'];-const split = async (- sequence: string,- splitFrame: number,- sequenceKeys = sequenceTimingKeys,-) => {- const input = wrap(sequence);- const {output} = await splitJsxSequence({- input,- nodePath: lineColumnToNodePath(input, sequenceLine),- sequenceKeys,- splitFrame,- });-- return output;-};--test('splitJsxSequence splits a sequence with no duration', async () => {- const output = await split('<Sequence from={0} />', 30);-- expect(output).toContain('<Sequence from={0} durationInFrames={30} />');- expect(output).toContain('<Sequence from={30} trimBefore={30} />');-});--test('splitJsxSequence remaps following JSX siblings', async () => {- const input = wrap(- '<Sequence name="split" from={0} durationInFrames={50} />\n\t\t\t<Sequence name="following" />',- );- const {output, nodePathRemappings} = await splitJsxSequence({- input,- nodePath: lineContainingToNodePath(input, 'name="split"'),- sequenceKeys: sequenceTimingKeys,- splitFrame: 30,- });-- expect(nodePathRemappings).toEqual([- {- oldNodePath: lineContainingToNodePath(input, 'name="split"'),- newNodePath: lineContainingToNodePath(output, 'name="split"'),- },- {- oldNodePath: lineContainingToNodePath(input, 'name="following"'),- newNodePath: lineContainingToNodePath(output, 'name="following"'),- },- {- oldNodePath: null,- newNodePath: lineContainingToNodePath(output, 'from={30}'),- },- ]);-});--test('splitJsxSequence omits right Infinity duration', async () => {- const output = await split(- '<Sequence from={0} durationInFrames={Infinity} />',- 30,- );-- expect(output).toContain('<Sequence from={0} durationInFrames={30} />');- expect(output).toContain('<Sequence from={30} trimBefore={30} />');- expect(output).not.toContain('durationInFrames={Infinity}');-});--test('splitJsxSequence keeps missing left from omitted', async () => {- const output = await split('<Sequence durationInFrames={50} />', 30);-- expect(output).toContain('<Sequence durationInFrames={30} />');- expect(output).toContain(- '<Sequence from={30} durationInFrames={20} trimBefore={30} />',- );-});--test('splitJsxSequence splits finite duration and trimBefore', async () => {- const output = await split(- '<Sequence from={10} durationInFrames={50} trimBefore={5} />',- 30,- );-- expect(output).toContain(- '<Sequence from={10} durationInFrames={20} trimBefore={5} />',- );- expect(output).toContain(- '<Sequence from={30} durationInFrames={30} trimBefore={25} />',- );-});--test('splitJsxSequence preserves surrounding formatting without calling Prettier', async () => {- const input = `const deliberatelyUnformatted = {value : true}--export const Comp = () => {- return (- <>- <Sequence- name="clip"- from={0}- durationInFrames={50}- >- <div>Child</div>- </Sequence>- <Keep prop = {1}/>- </>- )-}-`;- const {output} = await splitJsxSequenceCodemod({- input,- nodePath: lineContainingToNodePath(input, '<Sequence'),- sequenceKeys: sequenceTimingKeys,- splitFrame: 30,- });-- expect(output).toStartWith(- 'const deliberatelyUnformatted = {value : true}\n',- );- expect(output).toContain(- '<Sequence name="clip" from={0} durationInFrames={30}>\n',- );- expect(output).toContain(- '<Sequence name="clip" from={30} durationInFrames={20} trimBefore={30}>\n',- );- expect(output).toContain(' <Keep prop = {1}/>');- expect(output).toEndWith(' )\n}\n');-});--test('splitJsxSequence formats a split component root as a fragment', async () => {- const input = `export const Comp = () => <Sequence from={0} durationInFrames={50}><span>Hi</span></Sequence>;--const keep = { value : true }-`;- const {output} = await splitJsxSequenceCodemod({- input,- nodePath: lineContainingToNodePath(input, '<Sequence'),- sequenceKeys: sequenceTimingKeys,- splitFrame: 30,- });-- expect(output).toBe(`export const Comp = () => <>- <Sequence from={0} durationInFrames={30}>- <span>Hi</span>- </Sequence>- <Sequence from={30} durationInFrames={20} trimBefore={30}>- <span>Hi</span>- </Sequence>-</>;--const keep = { value : true }-`);-});--test('splitJsxSequence splits a video with a negative from', async () => {- const output = await split(- '<Video src="video.mov" from={-2644} trimBefore={272} />',- 100,- );-- expect(output).toContain('from={-2644}');- expect(output).toContain('durationInFrames={2744}');- expect(output).toContain('trimBefore={272}');- expect(output).toContain(- '<Video src="video.mov" from={100} trimBefore={3016} />',- );-});--test('splitJsxSequence splits from-only sequence', async () => {- const output = await split('<Sequence from={10} />', 30);-- expect(output).toContain('<Sequence from={10} durationInFrames={20} />');- expect(output).toContain('<Sequence from={30} trimBefore={20} />');-});--test('splitJsxSequence splits sequence-backed components', async () => {- expect(- await split('<AbsoluteFill from={0} durationInFrames={50} />', 30),- ).toContain(- '<AbsoluteFill from={30} durationInFrames={20} trimBefore={30} />',- );- expect(- await split('<Img src="image.png" from={0} durationInFrames={50} />', 30),- ).toContain(- '<Img src="image.png" from={30} durationInFrames={20} trimBefore={30} />',- );- expect(- await split('<Gif src="anim.gif" from={0} durationInFrames={50} />', 30),- ).toContain(- '<Gif src="anim.gif" from={30} durationInFrames={20} trimBefore={30} />',- );- const solidOutput = await split(- '<Solid width={100} height={100} from={0} durationInFrames={50} />',- 30,- );- expect(solidOutput).toContain(- '<Solid width={100} height={100} from={0} durationInFrames={30} />',- );- expect(solidOutput).toContain('from={30}');- expect(solidOutput).toContain('durationInFrames={20}');- expect(solidOutput).toContain('trimBefore={30}');- expect(- await split('<Interactive.Div from={0} durationInFrames={50} />', 30),- ).toContain(- '<Interactive.Div from={30} durationInFrames={20} trimBefore={30} />',- );-});--test('splitJsxSequence rejects boundary and dynamic splits', async () => {- await expect(- split('<Sequence from={10} durationInFrames={20} />', 10),- ).rejects.toThrow(/sequence start/);- await expect(- split('<Sequence from={10} durationInFrames={20} />', 30),- ).rejects.toThrow(/sequence end/);- await expect(- split('<Sequence from={10} durationInFrames={20} />', 8),- ).rejects.toThrow(/sequence start/);- await expect(- split('<Sequence from={10} durationInFrames={20} />', 10.5),- ).rejects.toThrow(/integer/);- await expect(- split('<Sequence from={start} durationInFrames={20} />', 15),- ).rejects.toThrow(/dynamic from/);-});--test('splitJsxSequence rejects Series.Sequence', async () => {- await expect(- split('<Series.Sequence durationInFrames={50} />', 30, [- 'durationInFrames',- 'trimBefore',- ]),- ).rejects.toThrow('<Series.Sequence> cannot be split');-});--test('splitJsxSequence rejects regular DOM elements', async () => {- await expect(- split('<div from={0} durationInFrames={50} />', 30, []),- ).rejects.toThrow('<div> cannot be split');-});-const clearUndoStack = () => {(getUndoStack() as unknown as unknown[]).length = 0;};diff --git a/packages/studio-server/src/test/split-video-from-audio.test.ts b/packages/studio-server/src/test/split-video-from-audio.test.tsindex 97e206d193..0aaa2a34e0 100644--- a/packages/studio-server/src/test/split-video-from-audio.test.ts+++ b/packages/studio-server/src/test/split-video-from-audio.test.ts@@ -2,7 +2,6 @@ import {expect, test} from 'bun:test';import {mkdtempSync, readFileSync, rmSync, writeFileSync} from 'node:fs';import {tmpdir} from 'node:os';import path from 'node:path';-import {CodemodsInternals} from '@remotion/codemods';import {createFileWatcherRegistry,setFileWatcherRegistry,@@ -12,8 +11,6 @@ import {splitVideoFromAudioHandler} from '../preview-server/routes/split-video-fimport {getUndoStack} from '../preview-server/undo-stack';import {lineColumnToNodePath, lineContainingToNodePath} from './test-utils';-const {splitVideoFromAudio} = CodemodsInternals;-const wrap = (element: string,imports = `import {Video} from '@remotion/media';`,@@ -30,255 +27,6 @@ export const Comp = () => {const elementLine = 6;-const split = async (element: string, imports?: string) => {- const input = wrap(element, imports);- const {output} = await splitVideoFromAudio({- input,- nodePath: lineContainingToNodePath(input, element),- });-- return output;-};--test('splitVideoFromAudio mutes the video and adds an Audio with the same timing', async () => {- const output = await split(- '<Video src="video.mp4" from={10} durationInFrames={50} trimBefore={5} playbackRate={2} volume={0.5} style={{opacity: 0.5}} />',- );-- const singleLine = output.replace(/\s+/g, ' ');-- expect(output).toContain(`import {Video, Audio} from '@remotion/media';`);- expect(singleLine).toContain(- '<Video src="video.mp4" from={10} durationInFrames={50} trimBefore={5} playbackRate={2} volume={0.5} style={{opacity: 0.5}} muted />',- );- expect(singleLine).toContain(- '<Audio src="video.mp4" from={10} durationInFrames={50} trimBefore={5} playbackRate={2} volume={0.5} />',- );-});--test('splitVideoFromAudio preserves unrelated source formatting without calling the formatter', async () => {- const input = `import{Video}from"@remotion/media"--const untouched = {keep : "spacing"}-export const Comp=()=>(- <>- <Video- src = {"video.mp4"}- from = {10}- style = {{opacity:.5}}- />- <div data-value = "unchanged"/>- </>-)-`;- let formatCalls = 0;- const {formatted, nodePathRemappings, output} = await splitVideoFromAudio({- input,- nodePath: lineContainingToNodePath(input, '<Video'),- formatFile: () => {- formatCalls++;- throw new Error('Prettier must not be called');- },- });-- expect(formatCalls).toBe(0);- expect(formatted).toBe(true);- expect(output).toBe(`import{Video, Audio}from"@remotion/media"--const untouched = {keep : "spacing"}-export const Comp=()=>(- <>- <Video- src = {"video.mp4"}- from = {10}- style = {{opacity:.5}}- muted- />- <Audio src={"video.mp4"} from={10} />- <div data-value = "unchanged"/>- </>-)-`);- expect(nodePathRemappings).toEqual([- {- oldNodePath: lineContainingToNodePath(input, '<Video'),- newNodePath: lineContainingToNodePath(output, '<Video'),- },- {- oldNodePath: lineContainingToNodePath(input, '<div'),- newNodePath: lineContainingToNodePath(output, '<div'),- },- {- oldNodePath: null,- newNodePath: lineContainingToNodePath(output, '<Audio'),- },- ]);-});--test('splitVideoFromAudio does not copy non-audio props', async () => {- const output = await split(- '<Video src="video.mp4" name="my video" freeze={20} crop={{x: 0, y: 0, width: 100, height: 100}} />',- );-- expect(output).toContain('<Audio src="video.mp4" />');-});--test('splitVideoFromAudio wraps a root video in a fragment', async () => {- const input = `import {Video} from '@remotion/media';--export const Comp = () => <Video src="video.mp4" />;-`;- const {output} = await splitVideoFromAudio({- input,- nodePath: lineContainingToNodePath(input, '<Video'),- });-- expect(output).toBe(`import {Video, Audio} from '@remotion/media';--export const Comp = () => <>- <Video src="video.mp4" muted />- <Audio src="video.mp4" />-</>;-`);-});--test('splitVideoFromAudio separates siblings with one space on a shared line', async () => {- const input = `import {Video} from '@remotion/media';--export const Comp = () => (- <div>- <Video src="video.mp4" /></div>-);-`;- const {output} = await splitVideoFromAudio({- input,- nodePath: lineContainingToNodePath(input, '<Video'),- });-- expect(output).toBe(`import {Video, Audio} from '@remotion/media';--export const Comp = () => (- <div>- <Video src="video.mp4" muted /> <Audio src="video.mp4" /></div>-);-`);-});--test('splitVideoFromAudio preserves CRLF and tab indentation', async () => {- const input = [- `import {Video} from '@remotion/media';`,- '',- 'export const Comp = () => {',- '\treturn (',- '\t\t<>',- '\t\t\t<Video',- '\t\t\t\tsrc="video.mp4"',- '\t\t\t\ttrimBefore={10}',- '\t\t\t/>',- '\t\t</>',- '\t);',- '};',- '',- ].join('\r\n');- const {output} = await splitVideoFromAudio({- input,- nodePath: lineContainingToNodePath(input, '<Video'),- });-- expect(output).toBe(- [- `import {Video, Audio} from '@remotion/media';`,- '',- 'export const Comp = () => {',- '\treturn (',- '\t\t<>',- '\t\t\t<Video',- '\t\t\t\tsrc="video.mp4"',- '\t\t\t\ttrimBefore={10}',- '\t\t\t\tmuted',- '\t\t\t/>',- '\t\t\t<Audio src="video.mp4" trimBefore={10} />',- '\t\t</>',- '\t);',- '};',- '',- ].join('\r\n'),- );-});--test('splitVideoFromAudio replaces an existing muted prop', async () => {- const output = await split('<Video src="video.mp4" muted={false} />');-- expect(output).toContain('<Video src="video.mp4" muted />');- expect(output).not.toContain('muted={false}');-});--test('splitVideoFromAudio reuses an existing Audio import', async () => {- const output = await split(- '<Video src="video.mp4" />',- `import {Audio, Video} from '@remotion/media';`,- );-- expect(output).toContain(`import {Audio, Video} from '@remotion/media';`);- expect(output.match(/from '@remotion\/media'/g)?.length).toBe(1);-});--test('splitVideoFromAudio uses an aliased Audio import', async () => {- const output = await split(- '<Video src="video.mp4" />',- `import {Audio as Sound, Video} from '@remotion/media';`,- );-- expect(output).toContain(- `import {Audio as Sound, Video} from '@remotion/media';`,- );- expect(output).toContain('<Sound src="video.mp4" />');-});--test('splitVideoFromAudio imports Audio from the same module as the tag', async () => {- const output = await split(- '<OffthreadVideo src="video.mp4" from={5} />',- `import {OffthreadVideo} from 'remotion';`,- );-- expect(output).toContain(`import {OffthreadVideo, Audio} from 'remotion';`);- expect(output).toContain('<OffthreadVideo src="video.mp4" from={5} muted />');- expect(output).toContain('<Audio src="video.mp4" from={5} />');-});--test('splitVideoFromAudio follows import aliases', async () => {- const output = await split(- '<V src="video.mp4" />',- `import {Video as V} from '@remotion/media';`,- );-- expect(output).toContain(- `import {Video as V, Audio} from '@remotion/media';`,- );- expect(output).toContain('<Audio src="video.mp4" />');-});--test('splitVideoFromAudio rejects elements without a src attribute', async () => {- await expect(split('<Video from={0} />')).rejects.toThrow(- '<Video> has no src attribute',- );-});--test('splitVideoFromAudio rejects unimported tags', async () => {- await expect(split('<video src="video.mp4" />')).rejects.toThrow(- 'Could not find the import of <video>',- );-});--test('splitVideoFromAudio rejects an Audio import from another module', async () => {- await expect(- split(- '<Video src="video.mp4" />',- `import {Video} from '@remotion/media';\nimport {Audio} from 'remotion';`,- ),- ).rejects.toThrow('Audio is already imported from "remotion"');-});-const clearUndoStack = () => {(getUndoStack() as unknown as unknown[]).length = 0;};diff --git a/packages/studio-server/src/test/update-keyframes.test.ts b/packages/studio-server/src/test/update-keyframes.test.tsindex 45e6cf1736..87a19099e3 100644--- a/packages/studio-server/src/test/update-keyframes.test.ts+++ b/packages/studio-server/src/test/update-keyframes.test.ts@@ -2,7 +2,7 @@ import {expect, test} from 'bun:test';import type {InteractivitySchema} from 'remotion';import {NoReactInternals} from 'remotion/no-react';import {- updateEffectKeyframesAst,+ updateEffectKeyframes,updateSequenceKeyframes,} from '../codemods/update-keyframes/update-keyframes';import {computeSequencePropsStatusFromContent} from '../preview-server/routes/can-update-sequence-props';@@ -1849,12 +1849,12 @@ test('updateSequenceKeyframes keeps a color interpolation when one keyframe remaexpect(output).toContain("color={interpolateColors(frame, [100], ['blue'])}");});-test('updateEffectKeyframes converts a static value to a clamped interpolation', () => {+test('updateEffectKeyframes converts a static value to a clamped interpolation', async () => {const input = effectInput.replace('interpolate(frame, [0, 50, 100], [0.2, 0.5, 0.8])','0.2',);- const {serialized, oldValueStrings} = updateEffectKeyframesAst({+ const {output: serialized, oldValueStrings} = await updateEffectKeyframes({videoConfigValues: null,input,sequenceNodePath: lineColumnToNodePath(@@ -1877,8 +1877,8 @@ test('updateEffectKeyframes converts a static value to a clamped interpolation',expect(serialized).not.toContain('perceptual-scale');});-test('updateEffectKeyframes uses the schema keyframe output default', () => {- const {serialized} = updateEffectKeyframesAst({+test('updateEffectKeyframes uses the schema keyframe output default', async () => {+ const {output: serialized} = await updateEffectKeyframes({videoConfigValues: null,input: scaleEffectInput,sequenceNodePath: lineColumnToNodePath(@@ -1899,8 +1899,8 @@ test('updateEffectKeyframes uses the schema keyframe output default', () => {expect(serialized).toContain("output: 'perceptual-scale'");});-test('updateEffectKeyframes adds a missing prop before keyframing it', () => {- const {serialized, oldValueStrings} = updateEffectKeyframesAst({+test('updateEffectKeyframes adds a missing prop before keyframing it', async () => {+ const {output: serialized, oldValueStrings} = await updateEffectKeyframes({videoConfigValues: null,input: waveEffectInput,sequenceNodePath: lineColumnToNodePath(@@ -1925,9 +1925,9 @@ test('updateEffectKeyframes adds a missing prop before keyframing it', () => {expect(serialized).toContain("extrapolateRight: 'clamp'");});-test('updateEffectKeyframes adds props to a zero-argument effect', () => {+test('updateEffectKeyframes adds props to a zero-argument effect', async () => {const input = waveEffectInput.replace('wave({})', 'wave()');- const {serialized, oldValueStrings} = updateEffectKeyframesAst({+ const {output: serialized, oldValueStrings} = await updateEffectKeyframes({videoConfigValues: null,input,sequenceNodePath: lineColumnToNodePath(input, getLine(input, '<Solid')),@@ -1946,8 +1946,8 @@ test('updateEffectKeyframes adds props to a zero-argument effect', () => {expect(serialized).toContain('phase: interpolate(frame, [15], [45], {');});-test('updateEffectKeyframes sets one easing segment and fills linear segments', () => {- const {serialized} = updateEffectKeyframesAst({+test('updateEffectKeyframes sets one easing segment and fills linear segments', async () => {+ const {output: serialized} = await updateEffectKeyframes({videoConfigValues: null,input: effectInput,sequenceNodePath: lineColumnToNodePath(@@ -2013,8 +2013,12 @@ test('updateSequenceKeyframes converts the last color keyframe to a static value});});-test('updateEffectKeyframes removes a keyframe from an effect prop interpolation', () => {- const {serialized, oldValueStrings, effectCallee} = updateEffectKeyframesAst({+test('updateEffectKeyframes removes a keyframe from an effect prop interpolation', async () => {+ const {+ output: serialized,+ oldValueStrings,+ effectCallee,+ } = await updateEffectKeyframes({videoConfigValues: null,input: effectInput,sequenceNodePath: lineColumnToNodePath(@@ -2043,8 +2047,8 @@ test('updateEffectKeyframes removes a keyframe from an effect prop interpolation);});-test('updateEffectKeyframes allows moving keyframes outside the sequence range', () => {- const {serialized, newValueStrings} = updateEffectKeyframesAst({+test('updateEffectKeyframes allows moving keyframes outside the sequence range', async () => {+ const {output: serialized, newValueStrings} = await updateEffectKeyframes({videoConfigValues: null,input: effectInput,sequenceNodePath: lineColumnToNodePath(@@ -2074,8 +2078,8 @@ test('updateEffectKeyframes allows moving keyframes outside the sequence range',);});-test('updateEffectKeyframes replaces an existing keyframe when moving onto it', () => {- const {serialized, newValueStrings} = updateEffectKeyframesAst({+test('updateEffectKeyframes replaces an existing keyframe when moving onto it', async () => {+ const {output: serialized, newValueStrings} = await updateEffectKeyframes({videoConfigValues: null,input: effectInput,sequenceNodePath: lineColumnToNodePath(@@ -2102,12 +2106,12 @@ test('updateEffectKeyframes replaces an existing keyframe when moving onto it',);});-test('updateEffectKeyframes keeps an effect prop interpolation with one keyframe', () => {+test('updateEffectKeyframes keeps an effect prop interpolation with one keyframe', async () => {const input = effectInput.replace('interpolate(frame, [0, 50, 100], [0.2, 0.5, 0.8])','interpolate(frame, [0, 100], [0.2, 0.8])',);- const {serialized} = updateEffectKeyframesAst({+ const {output: serialized} = await updateEffectKeyframes({videoConfigValues: null,input,sequenceNodePath: lineColumnToNodePath(@@ -2130,31 +2134,35 @@ test('updateEffectKeyframes keeps an effect prop interpolation with one keyframeexpect(serialized).toContain('amount: interpolate(frame, [0], [0.2])');});-test('updateEffectKeyframes converts the last effect keyframe to a static value', () => {+test('updateEffectKeyframes converts the last effect keyframe to a static value', async () => {const input = effectInput.replace('interpolate(frame, [0, 50, 100], [0.2, 0.5, 0.8])','interpolate(frame, [40], [0.6])',);- const {serialized, oldValueStrings, newValueStrings, effectCallee} =- updateEffectKeyframesAst({- videoConfigValues: null,+ const {+ output: serialized,+ oldValueStrings,+ newValueStrings,+ effectCallee,+ } = await updateEffectKeyframes({+ videoConfigValues: null,+ input,+ sequenceNodePath: lineColumnToNodePath(input,- sequenceNodePath: lineColumnToNodePath(- input,- getLine(input, '<HtmlInCanvas'),- ),- effectIndex: 0,- updates: [- {- key: 'amount',- operation: {- type: 'remove',- frame: 40,- valueWhenLastKeyframeDeleted: null,- },+ getLine(input, '<HtmlInCanvas'),+ ),+ effectIndex: 0,+ updates: [+ {+ key: 'amount',+ operation: {+ type: 'remove',+ frame: 40,+ valueWhenLastKeyframeDeleted: null,},- ],- });+ },+ ],+ });expect(effectCallee).toBe('tint');expect(oldValueStrings).toEqual(['interpolate(frame, [40], [0.6])']);diff --git a/packages/studio-server/src/test/update-sequence-props.test.ts b/packages/studio-server/src/test/update-sequence-props.test.tsindex 689621064d..c437553e89 100644--- a/packages/studio-server/src/test/update-sequence-props.test.ts+++ b/packages/studio-server/src/test/update-sequence-props.test.ts@@ -1,14 +1,9 @@import {expect, test} from 'bun:test';-import * as recast from 'recast';import {NoReactInternals} from 'remotion/no-react';import {updateMultipleSequenceProps,updateSequenceProps,} from '../codemods/update-sequence-props/update-sequence-props';-import {- computeSequencePropsStatusFromContent,- takeCachedSequencePropsStatusAst,-} from '../preview-server/routes/can-update-sequence-props';import {lineColumnToNodePath} from './test-utils';const lightLeakInput = `import {LightLeak} from '@remotion/light-leaks';@@ -726,41 +721,6 @@ test('updateMultipleSequenceProps formats a multiline non-self-closing opening eexpect(formatted).toBe(true);});-test('updateMultipleSequenceProps reuses the status AST across the shared Recast runtime', async () => {- const nodePath = lineColumnToNodePath(lightLeakInput, 8);- computeSequencePropsStatusFromContent({- fileContents: lightLeakInput,- nodePath,- componentIdentity: null,- keys: ['hueShift'],- effects: [],- videoConfigValues: null,- });- expect(takeCachedSequencePropsStatusAst(`${lightLeakInput}\n`)).toBeNull();- const cachedAst = takeCachedSequencePropsStatusAst(lightLeakInput);- if (!cachedAst) {- throw new Error('Expected the status AST to be reusable');- }-- const {ast} = await updateMultipleSequenceProps({- input: lightLeakInput,- changes: [- {- nodePath,- updates: [{key: 'hueShift', value: 90, defaultValue: null}],- schema: NoReactInternals.sequenceSchema,- videoConfigValues: null,- },- ],- prettierConfigOverride: null,- ast: cachedAst,- });-- expect(ast).toBe(cachedAst);- expect(() => recast.print(ast).code).not.toThrow();- expect(takeCachedSequencePropsStatusAst(lightLeakInput)).toBeNull();-});-test('updateSequenceProps should update JSX text children', async () => {const input = `import React from 'react';import {Interactive} from 'remotion';