Skip to content

πŸŽ₯ Make videos programmatically with React

Drop "Jsx" from the public codemods API

JonnyBurger8d3dc97cb134
diff --git a/packages/browser-studio/src/browser-studio-operations.ts b/packages/browser-studio/src/browser-studio-operations.ts
index 7f6f0c7a84..7dfec9ae73 100644
--- a/packages/browser-studio/src/browser-studio-operations.ts
+++ b/packages/browser-studio/src/browser-studio-operations.ts
@@ -9,20 +9,20 @@ import {
createElement,
deleteComposition,
deleteEffects as deleteEffectsCodemod,
- deleteJsxNodes as deleteJsxNodesCodemod,
+ deleteNodes as deleteNodesCodemod,
detachAudio,
duplicateComposition as duplicateCompositionCodemod,
duplicateEffects as duplicateEffectsCodemod,
- duplicateJsxNodes as duplicateJsxNodesCodemod,
- canWrapJsxNode,
- wrapJsxNode as wrapJsxNodeCodemod,
- getJsxNodeProps,
+ duplicateNodes as duplicateNodesCodemod,
+ canWrapNode,
+ wrapNode as wrapNodeCodemod,
+ getNodeProps,
moveComposition,
moveFolder,
renameComposition,
renameFolder,
reorderEffect as reorderEffectCodemod,
- reorderJsxNode,
+ reorderNode,
resolveCompositionComponent,
setCompositionDefaultProps,
splitSequences,
@@ -30,8 +30,8 @@ import {
updateCompositionMetadata,
updateEffectKeyframes,
updateEffectProps as updateEffectPropsCodemod,
- updateJsxNodeKeyframes,
- updateJsxNodeProps,
+ updateNodeKeyframes,
+ updateNodeProps,
type CodemodFileChange,
type CodemodNodeResult,
type CodemodResult,
@@ -831,7 +831,7 @@ export const createBrowserStudioOperations = ({
filePath: mutation.fileName,
project,
});
- const result = await updateJsxNodeKeyframes({
+ const result = await updateNodeKeyframes({
project: nextProject,
node: {filePath: absolutePath, nodePath: mutation.nodePath.nodePath},
updates: mutation.updates,
@@ -909,7 +909,7 @@ export const createBrowserStudioOperations = ({
mutation: AppliedSequenceKeyframeMutation;
project: VirtualProject;
}) => {
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project,
node: {
filePath: mutation.absolutePath,
@@ -943,7 +943,7 @@ export const createBrowserStudioOperations = ({
const effects = Array.from({length: mutation.effectIndex + 1}, (_, index) =>
index === mutation.effectIndex ? getAllSchemaKeys(mutation.schema) : [],
);
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project,
node: {
filePath: mutation.absolutePath,
@@ -1024,7 +1024,7 @@ export const createBrowserStudioOperations = ({
filePath: request.fileName,
project,
});
- const nextStatus = getJsxNodeProps({
+ const nextStatus = getNodeProps({
project,
node: {filePath: absolutePath, nodePath: result.nodePath.nodePath},
componentIdentity: request.componentIdentity,
@@ -1107,7 +1107,7 @@ export const createBrowserStudioOperations = ({
sequenceNodePath: SequencePropsSubscriptionKey;
}) => {
const absolutePath = findProjectFile({filePath: fileName, project});
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project,
node: {filePath: absolutePath, nodePath: sequenceNodePath.nodePath},
componentIdentity: null,
@@ -1470,7 +1470,7 @@ export const createBrowserStudioOperations = ({
}
const project = getProject();
- const result = await deleteJsxNodesCodemod({
+ const result = await deleteNodesCodemod({
project,
nodes: nodes.map((node) => ({
filePath: node.fileName,
@@ -1507,7 +1507,7 @@ export const createBrowserStudioOperations = ({
}
const project = getProject();
- const result = await duplicateJsxNodesCodemod({
+ const result = await duplicateNodesCodemod({
project,
nodes: nodes.map((node) => ({
filePath: node.fileName,
@@ -1541,7 +1541,7 @@ export const createBrowserStudioOperations = ({
try {
const project = getProject();
const filePath = findProjectFile({project, filePath: fileName});
- const eligibility = canWrapJsxNode({
+ const eligibility = canWrapNode({
input: project.files[filePath],
nodePath,
});
@@ -1553,7 +1553,7 @@ export const createBrowserStudioOperations = ({
});
}
- const result = wrapJsxNodeCodemod({
+ const result = wrapNodeCodemod({
project,
node: {filePath, nodePath},
wrapper: createElement({
@@ -1697,7 +1697,7 @@ export const createBrowserStudioOperations = ({
filePath: fileName,
project,
});
- const result = await reorderJsxNode({
+ const result = await reorderNode({
project,
node: {filePath: absolutePath, nodePath: sourceNodePath.nodePath},
target: {filePath: absolutePath, nodePath: targetNodePath.nodePath},
@@ -2155,7 +2155,7 @@ export const createBrowserStudioOperations = ({
try {
const project = getProject();
const absolutePath = findProjectFile({filePath: fileName, project});
- const result = updateJsxNodeProps({
+ const result = updateNodeProps({
project,
node: {filePath: absolutePath, nodePath},
updates: [
diff --git a/packages/browser-studio/src/save-sequence-props.ts b/packages/browser-studio/src/save-sequence-props.ts
index 23cbc68fae..0d25fba845 100644
--- a/packages/browser-studio/src/save-sequence-props.ts
+++ b/packages/browser-studio/src/save-sequence-props.ts
@@ -1,8 +1,8 @@
import {
CodemodsInternals,
applyCodemodChanges,
- getJsxNodeProps,
- updateMultipleJsxNodeProps,
+ getNodeProps,
+ updateMultipleNodeProps,
} from '@remotion/codemods';
import type {
SaveSequencePropEdit,
@@ -56,7 +56,7 @@ export const saveSequencePropsInProject = ({
const updateResult =
request.edits.length > 0
- ? updateMultipleJsxNodeProps({
+ ? updateMultipleNodeProps({
project,
changes: request.edits.map((edit) => ({
node: {filePath: edit.fileName, nodePath: edit.nodePath.nodePath},
@@ -116,7 +116,7 @@ export const saveSequencePropsInProject = ({
filePath: target.fileName,
project: nextProject,
});
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project: nextProject,
keys: getAllSchemaKeys(target.schema),
assetKeys: getAssetSchemaKeys(target.schema),
diff --git a/packages/browser-studio/src/test/browser-studio-operations.test.ts b/packages/browser-studio/src/test/browser-studio-operations.test.ts
index 543505dd07..0dc723c175 100644
--- a/packages/browser-studio/src/test/browser-studio-operations.test.ts
+++ b/packages/browser-studio/src/test/browser-studio-operations.test.ts
@@ -4,7 +4,7 @@ import {
applyCodemodChanges,
CodemodsInternals,
createElement,
- getJsxNodes,
+ getNodes,
} from '@remotion/codemods';
import {createElementPayload} from '@remotion/studio-protocol';
import type {EventSourceEvent} from '@remotion/studio-shared';
@@ -970,7 +970,7 @@ export const Component = () => <AbsoluteFill><div /></AbsoluteFill>;`;
files: {[fileName]: initialContents},
};
const {operations, getProject} = makeOperationsForProject(project);
- const nodePath = getJsxNodes({project, filePath: fileName}).find(
+ const nodePath = getNodes({project, filePath: fileName}).find(
({tagName}) => tagName === 'AbsoluteFill',
)?.nodePath;
if (!nodePath) {
diff --git a/packages/canvas/src/sequence-node-path.ts b/packages/canvas/src/sequence-node-path.ts
index 6523b16635..5fd5acd956 100644
--- a/packages/canvas/src/sequence-node-path.ts
+++ b/packages/canvas/src/sequence-node-path.ts
@@ -14,7 +14,7 @@ export type CanvasSequenceSourceLocation = {
fileName: string;
/** 1-based line of the JSX element. */
line: number;
- /** 0-based column of the JSX element, matching `getJsxNodes()` from @remotion/codemods. */
+ /** 0-based column of the JSX element, matching `getNodes()` from @remotion/codemods. */
column: number;
};
diff --git a/packages/codemods/src/add-effect.ts b/packages/codemods/src/add-effect.ts
index a12a4100ea..84c08ee584 100644
--- a/packages/codemods/src/add-effect.ts
+++ b/packages/codemods/src/add-effect.ts
@@ -6,12 +6,12 @@ import {
getNodeEditResult,
getUnchangedStructureRemappings,
getUpdatedNodeReference,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
export type AddEffectOptions<Project extends CodemodProject> = {
project: Project;
- node: JsxNodeReference;
+ node: NodeReference;
importName: string;
importPath: string;
props?: Record<string, CodemodValue>;
diff --git a/packages/codemods/src/add-element.ts b/packages/codemods/src/add-element.ts
index d91909bc7d..b126dd4e08 100644
--- a/packages/codemods/src/add-element.ts
+++ b/packages/codemods/src/add-element.ts
@@ -21,7 +21,7 @@ import {findProjectFile} from './internals';
import {
getNodeEditResult,
type CodemodInsertionResult,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
import {indentInsertedJsx, printInsertedJsx} from './print-jsx';
import {recastLocToOffset} from './recast-loc-to-offset';
@@ -46,9 +46,9 @@ import {stripParenthesizedExtra} from './strip-parenthesized-extra';
export type AddElementTarget =
| ({type: 'composition'} & CompositionTarget)
| {type: 'component'; filePath: string; exportName: string | 'default'}
- | {type: 'inside'; node: JsxNodeReference}
- | {type: 'before'; node: JsxNodeReference}
- | {type: 'after'; node: JsxNodeReference};
+ | {type: 'inside'; node: NodeReference}
+ | {type: 'before'; node: NodeReference}
+ | {type: 'after'; node: NodeReference};
export type AddElementOptions<Project extends CodemodProject> = {
project: Project;
@@ -97,7 +97,7 @@ const getNodeTargetSourceEdit = ({
prettierConfigOverride,
target,
}: SourceEditInput & {
- target: Extract<AddElementTarget, {node: JsxNodeReference}>;
+ target: Extract<AddElementTarget, {node: NodeReference}>;
}): SourceEdit => {
const targetPath = findJsxElementPathForDeletion(ast, target.node.nodePath);
if (!targetPath) {
diff --git a/packages/codemods/src/codemod-element.ts b/packages/codemods/src/codemod-element.ts
index 7ec4af59a6..29b5b5c408 100644
--- a/packages/codemods/src/codemod-element.ts
+++ b/packages/codemods/src/codemod-element.ts
@@ -175,7 +175,7 @@ export const createElement = (options: CodemodElementOptions): CodemodElement =>
/**
* Returns a value that is written as `staticFile(path)` when inserted into
* source code. Pass it as a prop value to `createElement()` or
- * `updateJsxNodeProps()`.
+ * `updateNodeProps()`.
*/
export const staticFileValue = (path: string): string => {
if (typeof path !== 'string' || path === '' || path.includes('\\')) {
diff --git a/packages/codemods/src/composition-editing.ts b/packages/codemods/src/composition-editing.ts
index 9c66c5459a..a6ef850ae2 100644
--- a/packages/codemods/src/composition-editing.ts
+++ b/packages/codemods/src/composition-editing.ts
@@ -1,7 +1,7 @@
import {Internals} from 'remotion';
import type {CodemodProject} from './codemod-project';
-import {getJsxNodeProps} from './get-jsx-node-props';
-import {getJsxNodes} from './get-jsx-nodes';
+import {getNodeProps} from './get-node-props';
+import {getNodes} from './get-nodes';
import type {ResolveCompositionComponentOptions} from './resolve-composition-component';
export type CompositionTarget = {
@@ -28,14 +28,14 @@ const getCompositionNodes = ({
project: CodemodProject;
compositionFile: string;
}) => {
- return getJsxNodes({project, filePath: compositionFile})
+ return getNodes({project, filePath: compositionFile})
.filter(
(node) =>
node.componentIdentity === 'dev.remotion.remotion.Composition' ||
node.componentIdentity === 'dev.remotion.remotion.Still',
)
.map((node) => {
- const status = getJsxNodeProps({project, node, keys: ['id']}).props.id;
+ const status = getNodeProps({project, node, keys: ['id']}).props.id;
return {
node: {
...node,
diff --git a/packages/codemods/src/delete-jsx-nodes-internal.ts b/packages/codemods/src/delete-jsx-nodes-internal.ts
index 6798ea911d..aff39941c7 100644
--- a/packages/codemods/src/delete-jsx-nodes-internal.ts
+++ b/packages/codemods/src/delete-jsx-nodes-internal.ts
@@ -524,7 +524,7 @@ const applySourceEdits = ({
return output;
};
-export const deleteJsxNodes = ({
+export const deleteNodes = ({
input,
nodePaths,
}: {
diff --git a/packages/codemods/src/delete-jsx-nodes.ts b/packages/codemods/src/delete-nodes.ts
similarity index 71%
rename from packages/codemods/src/delete-jsx-nodes.ts
rename to packages/codemods/src/delete-nodes.ts
index f803c4761e..859b5b02ea 100644
--- a/packages/codemods/src/delete-jsx-nodes.ts
+++ b/packages/codemods/src/delete-nodes.ts
@@ -1,21 +1,21 @@
import type {CodemodProject} from './codemod-project';
-import {deleteJsxNodes as deleteJsxNodesFromSource} from './delete-jsx-nodes-internal';
+import {deleteNodes as deleteJsxNodesFromSource} from './delete-jsx-nodes-internal';
import {
getNodeEditResult,
groupNodeReferencesByFile,
type CodemodNodeResult,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
-export type DeleteJsxNodesOptions<Project extends CodemodProject> = {
+export type DeleteNodesOptions<Project extends CodemodProject> = {
project: Project;
- nodes: JsxNodeReference[];
+ nodes: NodeReference[];
};
-export const deleteJsxNodes = async <Project extends CodemodProject>({
+export const deleteNodes = async <Project extends CodemodProject>({
project,
nodes,
-}: DeleteJsxNodesOptions<Project>): Promise<
+}: DeleteNodesOptions<Project>): Promise<
CodemodNodeResult & {
editDetails: {
filePath: string;
diff --git a/packages/codemods/src/detach-audio.ts b/packages/codemods/src/detach-audio.ts
index 791289cc4e..c9e20eb00d 100644
--- a/packages/codemods/src/detach-audio.ts
+++ b/packages/codemods/src/detach-audio.ts
@@ -1,16 +1,16 @@
import type {CodemodProject} from './codemod-project';
-import {getJsxNodes} from './get-jsx-nodes';
+import {getNodes} from './get-nodes';
import {findProjectFile} from './internals';
import {
getNodeEditResult,
getUpdatedNodeReference,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
import {splitVideoFromAudio} from './split-video-from-audio';
export type DetachAudioOptions<Project extends CodemodProject> = {
project: Project;
- node: JsxNodeReference;
+ node: NodeReference;
};
export const detachAudio = async <Project extends CodemodProject>({
@@ -18,7 +18,7 @@ export const detachAudio = async <Project extends CodemodProject>({
node,
}: DetachAudioOptions<Project>) => {
const filePath = findProjectFile({project, filePath: node.filePath});
- const target = getJsxNodes({project, filePath}).find(
+ const target = getNodes({project, filePath}).find(
(entry) => JSON.stringify(entry.nodePath) === JSON.stringify(node.nodePath),
);
if (
diff --git a/packages/codemods/src/duplicate-jsx-node.ts b/packages/codemods/src/duplicate-jsx-node.ts
index 600b59a558..e762ebf677 100644
--- a/packages/codemods/src/duplicate-jsx-node.ts
+++ b/packages/codemods/src/duplicate-jsx-node.ts
@@ -318,7 +318,7 @@ const getDuplicateSourceEdit = ({
};
};
-export const duplicateJsxNodes = ({
+export const duplicateNodes = ({
input,
nodePaths,
}: {
diff --git a/packages/codemods/src/duplicate-jsx-nodes.ts b/packages/codemods/src/duplicate-nodes.ts
similarity index 65%
rename from packages/codemods/src/duplicate-jsx-nodes.ts
rename to packages/codemods/src/duplicate-nodes.ts
index 29ccbdb0c6..f7db8353ad 100644
--- a/packages/codemods/src/duplicate-jsx-nodes.ts
+++ b/packages/codemods/src/duplicate-nodes.ts
@@ -1,27 +1,27 @@
import type {CodemodProject} from './codemod-project';
-import {duplicateJsxNodes as duplicateNodesInSource} from './duplicate-jsx-node';
+import {duplicateNodes as duplicateNodesInSource} from './duplicate-jsx-node';
import {
getNodeEditResult,
getInsertedNodeReferences,
groupNodeReferencesByFile,
type CodemodNodeResult,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
-export type DuplicateJsxNodesOptions<Project extends CodemodProject> = {
+export type DuplicateNodesOptions<Project extends CodemodProject> = {
project: Project;
- nodes: JsxNodeReference[];
+ nodes: NodeReference[];
};
-export type DuplicateJsxNodesResult = CodemodNodeResult & {
- insertedNodes: JsxNodeReference[];
+export type DuplicateNodesResult = CodemodNodeResult & {
+ insertedNodes: NodeReference[];
editDetails: {filePath: string; nodeLabels: string[]; logLines: number[]}[];
};
-export const duplicateJsxNodes = async <Project extends CodemodProject>({
+export const duplicateNodes = async <Project extends CodemodProject>({
project,
nodes,
-}: DuplicateJsxNodesOptions<Project>): Promise<DuplicateJsxNodesResult> => {
+}: DuplicateNodesOptions<Project>): Promise<DuplicateNodesResult> => {
const groups = groupNodeReferencesByFile({project, nodes});
const edits = await Promise.all(
[...groups].map(async ([filePath, nodePaths]) => ({
diff --git a/packages/codemods/src/effect-references.ts b/packages/codemods/src/effect-references.ts
index 163c0e1c2c..07e24b7e4c 100644
--- a/packages/codemods/src/effect-references.ts
+++ b/packages/codemods/src/effect-references.ts
@@ -1,18 +1,18 @@
import type {CodemodProject} from './codemod-project';
import {findProjectFile} from './internals';
-import {type JsxNodeReference} from './node-references';
+import {type NodeReference} from './node-references';
import {findJsxElementAtNodePath} from './sequence-props';
import {findEffectsAttr} from './sequence-props/can-update-effect-props';
import {parseAst} from './sequence-props/parse-ast';
-export type EffectReference = JsxNodeReference & {effectIndex: number};
+export type EffectReference = NodeReference & {effectIndex: number};
export const getEffectSource = ({
project,
node,
}: {
project: CodemodProject;
- node: JsxNodeReference;
+ node: NodeReference;
}) => {
const filePath = findProjectFile({project, filePath: node.filePath});
const input = project.files[filePath];
@@ -54,7 +54,7 @@ export const getEffectSource = ({
};
export const groupEffects = <
- Effect extends JsxNodeReference & {effectIndex: number | null},
+ Effect extends NodeReference & {effectIndex: number | null},
>({
project,
effects,
diff --git a/packages/codemods/src/get-jsx-node-props.ts b/packages/codemods/src/get-node-props.ts
similarity index 89%
rename from packages/codemods/src/get-jsx-node-props.ts
rename to packages/codemods/src/get-node-props.ts
index e36d63925b..f34e017dde 100644
--- a/packages/codemods/src/get-jsx-node-props.ts
+++ b/packages/codemods/src/get-node-props.ts
@@ -5,7 +5,7 @@ import type {
} from 'remotion';
import type {CodemodProject} from './codemod-project';
import {findProjectFile} from './internals';
-import {type JsxNodeReference} from './node-references';
+import {type NodeReference} from './node-references';
import {
computeSequencePropsStatusFromContent,
findJsxElementAtNodePath,
@@ -13,9 +13,9 @@ import {
import {getReadOnlySourceSnapshot} from './sequence-props-snapshot';
import {findEffectsAttr} from './sequence-props/can-update-effect-props';
-export type GetJsxNodePropsOptions = {
+export type GetNodePropsOptions = {
project: CodemodProject;
- node: JsxNodeReference;
+ node: NodeReference;
keys: string[];
effectKeys?: string[][];
assetKeys?: string[];
@@ -23,12 +23,12 @@ export type GetJsxNodePropsOptions = {
videoConfig?: VideoConfigValues;
};
-export type JsxNodeProps = Pick<
+export type NodeProps = Pick<
CanUpdateSequencePropsResponseTrue,
'canUpdate' | 'props' | 'effects'
>;
-export const getJsxNodeProps = ({
+export const getNodeProps = ({
project,
node,
keys,
@@ -36,7 +36,7 @@ export const getJsxNodeProps = ({
assetKeys,
componentIdentity,
videoConfig,
-}: GetJsxNodePropsOptions): JsxNodeProps => {
+}: GetNodePropsOptions): NodeProps => {
const filePath = findProjectFile({project, filePath: node.filePath});
let effects = effectKeys;
if (effects === undefined) {
diff --git a/packages/codemods/src/get-jsx-nodes.ts b/packages/codemods/src/get-nodes.ts
similarity index 88%
rename from packages/codemods/src/get-jsx-nodes.ts
rename to packages/codemods/src/get-nodes.ts
index 9943cb2c21..36c0f3a00b 100644
--- a/packages/codemods/src/get-jsx-nodes.ts
+++ b/packages/codemods/src/get-nodes.ts
@@ -3,27 +3,27 @@ import type {JsxComponentIdentity, SequenceNodePath} from 'remotion';
import type {CodemodProject} from './codemod-project';
import {captureJsxNodePaths} from './get-node-path-remappings';
import {findProjectFile} from './internals';
-import type {JsxNodeReference} from './node-references';
+import type {NodeReference} from './node-references';
import {recastLocToOffset} from './recast-loc-to-offset';
import {getReadOnlySourceSnapshot} from './sequence-props-snapshot';
import {getJsxComponentIdentity} from './sequence-props/jsx-component-identity';
-export type JsxNode = JsxNodeReference & {
+export type CodemodNode = NodeReference & {
tagName: string;
componentIdentity: JsxComponentIdentity | null;
location: {line: number; column: number} | null;
parentNodePath: SequenceNodePath | null;
};
-export type GetJsxNodesOptions = {
+export type GetNodesOptions = {
project: CodemodProject;
filePath: string;
};
-export const getJsxNodes = ({
+export const getNodes = ({
project,
filePath,
-}: GetJsxNodesOptions): JsxNode[] => {
+}: GetNodesOptions): CodemodNode[] => {
const resolvedFilePath = findProjectFile({project, filePath});
const input = project.files[resolvedFilePath];
const {ast} = getReadOnlySourceSnapshot(input);
diff --git a/packages/codemods/src/index.ts b/packages/codemods/src/index.ts
index 92c11dff00..b5f84124b6 100644
--- a/packages/codemods/src/index.ts
+++ b/packages/codemods/src/index.ts
@@ -41,34 +41,30 @@ export {
type AddElementTarget,
} from './add-element';
export {type CodemodValue} from './codemod-value';
-export {
- getJsxNodes,
- type GetJsxNodesOptions,
- type JsxNode,
-} from './get-jsx-nodes';
-export {
- getJsxNodeProps,
- type GetJsxNodePropsOptions,
- type JsxNodeProps,
-} from './get-jsx-node-props';
-export {
- updateJsxNodeProps,
- updateMultipleJsxNodeProps,
- type JsxNodePropChange,
- type UpdateMultipleJsxNodePropsOptions,
- type UpdateJsxNodePropsOptions,
-} from './update-jsx-node-props';
-export {
- duplicateJsxNodes,
- type DuplicateJsxNodesOptions,
- type DuplicateJsxNodesResult,
-} from './duplicate-jsx-nodes';
-export {reorderJsxNode, type ReorderJsxNodeOptions} from './reorder-jsx-node';
+export {getNodes, type GetNodesOptions, type CodemodNode} from './get-nodes';
+export {
+ getNodeProps,
+ type GetNodePropsOptions,
+ type NodeProps,
+} from './get-node-props';
+export {
+ updateNodeProps,
+ updateMultipleNodeProps,
+ type NodePropChange,
+ type UpdateMultipleNodePropsOptions,
+ type UpdateNodePropsOptions,
+} from './update-node-props';
+export {
+ duplicateNodes,
+ type DuplicateNodesOptions,
+ type DuplicateNodesResult,
+} from './duplicate-nodes';
+export {reorderNode, type ReorderNodeOptions} from './reorder-node';
export {splitSequences, type SplitSequencesOptions} from './split-sequences';
export {detachAudio, type DetachAudioOptions} from './detach-audio';
export type {
- JsxNodeReference,
- JsxNodePathRemapping,
+ NodeReference,
+ NodePathRemapping,
CodemodNodeResult,
CodemodInsertionResult,
} from './node-references';
@@ -124,10 +120,10 @@ export {
export {reorderEffect, type ReorderEffectOptions} from './reorder-effect';
export {type EffectReference} from './effect-references';
export {
- updateJsxNodeKeyframes,
- type JsxNodeKeyframeUpdate,
- type UpdateJsxNodeKeyframesOptions,
-} from './update-jsx-node-keyframes';
+ updateNodeKeyframes,
+ type NodeKeyframeUpdate,
+ type UpdateNodeKeyframesOptions,
+} from './update-node-keyframes';
export {
updateEffectKeyframes,
type UpdateEffectKeyframesOptions,
@@ -138,12 +134,8 @@ export type {
CodemodResult,
} from './codemod-project';
export {applyCodemodChanges} from './codemod-project';
-export {deleteJsxNodes, type DeleteJsxNodesOptions} from './delete-jsx-nodes';
-export {
- canWrapJsxNode,
- wrapJsxNode,
- type WrapJsxNodeOptions,
-} from './wrap-jsx-node';
+export {deleteNodes, type DeleteNodesOptions} from './delete-nodes';
+export {canWrapNode, wrapNode, type WrapNodeOptions} from './wrap-node';
export type {
EffectArrayElement,
EffectDeletionTarget,
@@ -161,7 +153,7 @@ export type {
SequenceKeyframeUpdate,
} from './update-keyframes';
export type {
- InsertJsxElementCodemodEnvironment,
+ CodemodEnvironment,
PipelineInsertableElement,
ResolvedCompositionComponent,
ResolvedCompositionComponentWithFile,
diff --git a/packages/codemods/src/insert-jsx-element.ts b/packages/codemods/src/insert-jsx-element.ts
index d0e16dce36..c6c0c6b683 100644
--- a/packages/codemods/src/insert-jsx-element.ts
+++ b/packages/codemods/src/insert-jsx-element.ts
@@ -48,7 +48,7 @@ import {getEndOfLine, getIndentationUnit, getLineIndent} from './source-style';
import {stripParenthesizedExtra} from './strip-parenthesized-extra';
import {parseValueExpression} from './update-nested-prop';
-export type InsertJsxElementCodemodEnvironment = {
+export type CodemodEnvironment = {
rootDir: string;
dirname: (fileName: string) => string;
extname: (fileName: string) => string;
@@ -122,13 +122,13 @@ const relativeVirtualPath = (from: string, to: string) => {
].join('/');
};
-export const makeInMemoryInsertJsxElementCodemodEnvironment = ({
+export const makeInMemoryCodemodEnvironment = ({
project,
svgMarkupToJsx,
}: {
project: {files: Record<string, string>; rootDir: string};
- svgMarkupToJsx: InsertJsxElementCodemodEnvironment['svgMarkupToJsx'];
-}): InsertJsxElementCodemodEnvironment => {
+ svgMarkupToJsx: CodemodEnvironment['svgMarkupToJsx'];
+}): CodemodEnvironment => {
const filesByNormalizedPath = new Map(
Object.entries(project.files).map(([fileName, contents]) => [
resolveVirtualPath(project.rootDir, fileName),
@@ -209,7 +209,7 @@ const isInRemotionRoot = ({
environment,
fileName,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
fileName: string;
}) => {
const relativePath = environment.relative(environment.rootDir, fileName);
@@ -222,7 +222,7 @@ const readSourceFile = ({
environment,
fileName,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
fileName: string;
}) => {
const resolved = environment.resolve(environment.rootDir, fileName);
@@ -552,7 +552,7 @@ const resolveImportPath = ({
importPath,
fromFile,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
importPath: string;
fromFile: string;
}) => {
@@ -1007,7 +1007,7 @@ const createSvgElement = async ({
markup,
position,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
from: number | null;
interactiveLocalName: string;
markup: string;
@@ -1252,7 +1252,7 @@ const getImportPathBetweenFiles = ({
fromFile,
toFile,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
fromFile: string;
toFile: string;
}) => {
@@ -1777,7 +1777,7 @@ const getComponentLocationInFile = async ({
exportName,
ast: providedAst,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
fileName: string;
exportName: string | 'default';
ast?: File;
@@ -1809,7 +1809,7 @@ const getComponentLocationRecursively = async ({
exportName,
visited,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
fileName: string;
exportName: string | 'default';
visited: Set<string>;
@@ -1883,7 +1883,7 @@ export async function resolveCompositionComponentWithFile({
compositionFile,
compositionId,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
compositionFile: string;
compositionId: string;
}): Promise<ResolvedCompositionComponentWithFile> {
@@ -1951,7 +1951,7 @@ export const resolveCompositionComponent = async ({
compositionFile,
compositionId,
}: {
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
compositionFile: string;
compositionId: string;
}): Promise<ResolvedCompositionComponent> => {
@@ -1981,7 +1981,7 @@ const ensureCompositionComponentImport = async ({
compositionFile: string;
compositionId: string;
destinationFileName: string;
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
}) => {
const sourceLocation = await resolveCompositionComponentWithFile({
environment,
@@ -2093,7 +2093,7 @@ const createInsertableJsxElement = ({
ast: File;
destinationFileName: string;
element: PipelineInsertableElement;
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
from: number | null;
}): Promise<namedTypes.JSXElement> => {
if (element.type === 'svg') {
@@ -2136,7 +2136,7 @@ export const insertJsxElementIntoComposition = async ({
compositionFile: string;
compositionId: string;
element: InsertableCompositionElement;
- environment: InsertJsxElementCodemodEnvironment;
+ environment: CodemodEnvironment;
from: number | null;
prettierConfigOverride: Record<string, unknown> | null;
wrapInSequence: {
@@ -2297,7 +2297,7 @@ export const insertJsxElementIntoProjectWithNodePathRemappings = async ({
}: {
project: {files: Record<string, string>; rootDir: string};
request: InsertJsxElementRequest;
- svgMarkupToJsx: InsertJsxElementCodemodEnvironment['svgMarkupToJsx'];
+ svgMarkupToJsx: CodemodEnvironment['svgMarkupToJsx'];
wrapInSequence: {
dimensions: {width: number; height: number} | null;
durationInFrames: number | null;
@@ -2315,7 +2315,7 @@ export const insertJsxElementIntoProjectWithNodePathRemappings = async ({
compositionFile: request.compositionFile,
compositionId: request.compositionId,
element: request.element,
- environment: makeInMemoryInsertJsxElementCodemodEnvironment({
+ environment: makeInMemoryCodemodEnvironment({
project,
svgMarkupToJsx,
}),
diff --git a/packages/codemods/src/node-references.ts b/packages/codemods/src/node-references.ts
index 6590a52ae8..81415804e6 100644
--- a/packages/codemods/src/node-references.ts
+++ b/packages/codemods/src/node-references.ts
@@ -5,23 +5,23 @@ import {captureJsxNodePaths} from './get-node-path-remappings';
import {findProjectFile} from './internals';
import {parseAst} from './sequence-props/parse-ast';
-export type JsxNodeReference = {
+export type NodeReference = {
filePath: string;
nodePath: SequenceNodePath;
};
-export type JsxNodePathRemapping = {
+export type NodePathRemapping = {
filePath: string;
oldNodePath: SequenceNodePath | null;
newNodePath: SequenceNodePath | null;
};
export type CodemodNodeResult = CodemodResult & {
- nodePathRemappings: JsxNodePathRemapping[];
+ nodePathRemappings: NodePathRemapping[];
};
export type CodemodInsertionResult = CodemodNodeResult & {
- insertedNode: JsxNodeReference;
+ insertedNode: NodeReference;
};
export type NodeSourceEdit = {
@@ -34,8 +34,8 @@ export type NodeSourceEdit = {
};
export const getInsertedNodeReferences = (
- remappings: JsxNodePathRemapping[],
-): JsxNodeReference[] => {
+ remappings: NodePathRemapping[],
+): NodeReference[] => {
const inserted = remappings.flatMap(({filePath, oldNodePath, newNodePath}) =>
oldNodePath === null && newNodePath !== null
? [{filePath, nodePath: newNodePath}]
@@ -109,9 +109,9 @@ export const getUpdatedNodeReference = ({
nodePathRemappings,
}: {
project: CodemodProject;
- node: JsxNodeReference;
- nodePathRemappings: JsxNodePathRemapping[];
-}): JsxNodeReference => {
+ node: NodeReference;
+ nodePathRemappings: NodePathRemapping[];
+}): NodeReference => {
const filePath = findProjectFile({project, filePath: node.filePath});
const remapping = nodePathRemappings.find(
(entry) =>
@@ -130,7 +130,7 @@ export const groupNodeReferencesByFile = ({
nodes,
}: {
project: CodemodProject;
- nodes: JsxNodeReference[];
+ nodes: NodeReference[];
}) => {
if (nodes.length === 0) {
throw new Error('Expected at least one JSX node');
diff --git a/packages/codemods/src/reorder-jsx-node.ts b/packages/codemods/src/reorder-node.ts
similarity index 80%
rename from packages/codemods/src/reorder-jsx-node.ts
rename to packages/codemods/src/reorder-node.ts
index a68d994d03..cb9fd03f32 100644
--- a/packages/codemods/src/reorder-jsx-node.ts
+++ b/packages/codemods/src/reorder-node.ts
@@ -3,23 +3,23 @@ import {findProjectFile} from './internals';
import {
getNodeEditResult,
getUpdatedNodeReference,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
import {reorderSequence} from './reorder-sequence';
-export type ReorderJsxNodeOptions<Project extends CodemodProject> = {
+export type ReorderNodeOptions<Project extends CodemodProject> = {
project: Project;
- node: JsxNodeReference;
- target: JsxNodeReference;
+ node: NodeReference;
+ target: NodeReference;
position: 'before' | 'after';
};
-export const reorderJsxNode = async <Project extends CodemodProject>({
+export const reorderNode = async <Project extends CodemodProject>({
project,
node,
target,
position,
-}: ReorderJsxNodeOptions<Project>) => {
+}: ReorderNodeOptions<Project>) => {
const filePath = findProjectFile({project, filePath: node.filePath});
if (filePath !== findProjectFile({project, filePath: target.filePath})) {
throw new Error(
diff --git a/packages/codemods/src/set-composition-default-props.ts b/packages/codemods/src/set-composition-default-props.ts
index 4a49b59931..bfb523e9b2 100644
--- a/packages/codemods/src/set-composition-default-props.ts
+++ b/packages/codemods/src/set-composition-default-props.ts
@@ -8,7 +8,7 @@ import {
} from './composition-editing';
import {findJsxElementPathForDeletion} from './delete-jsx-nodes-internal';
import {formatSerializedValue} from './format-serialized-value';
-import {getJsxNodeProps} from './get-jsx-node-props';
+import {getNodeProps} from './get-node-props';
import {
getNodeEditResult,
getUnchangedStructureRemappings,
@@ -16,7 +16,7 @@ import {
} from './node-references';
import {recastLocToOffset} from './recast-loc-to-offset';
import {parseAst} from './sequence-props/parse-ast';
-import {updateJsxNodeProps} from './update-jsx-node-props';
+import {updateNodeProps} from './update-node-props';
export type SetCompositionDefaultPropsOptions<Project extends CodemodProject> =
CompositionTarget & {
@@ -33,7 +33,7 @@ export const setCompositionDefaultProps = <Project extends CodemodProject>({
enumPaths,
}: SetCompositionDefaultPropsOptions<Project>) => {
const node = requireComposition({project, compositionFile, compositionId});
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project,
node,
keys: ['defaultProps'],
@@ -54,7 +54,7 @@ export const setCompositionDefaultProps = <Project extends CodemodProject>({
attr.name.name === 'defaultProps',
);
if (!attribute || (attribute.type === 'JSXAttribute' && !attribute.value)) {
- const inserted = updateJsxNodeProps({
+ const inserted = updateNodeProps({
project,
node,
props: {defaultProps: {}},
diff --git a/packages/codemods/src/split-sequences.ts b/packages/codemods/src/split-sequences.ts
index aade4fe751..b800ba9097 100644
--- a/packages/codemods/src/split-sequences.ts
+++ b/packages/codemods/src/split-sequences.ts
@@ -1,24 +1,24 @@
import type {CodemodProject} from './codemod-project';
-import type {DuplicateJsxNodesResult} from './duplicate-jsx-nodes';
-import {getJsxNodeProps} from './get-jsx-node-props';
-import {getJsxNodes} from './get-jsx-nodes';
+import type {DuplicateNodesResult} from './duplicate-nodes';
+import {getNodeProps} from './get-node-props';
+import {getNodes} from './get-nodes';
import {findProjectFile} from './internals';
import {
getNodeEditResult,
getInsertedNodeReferences,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
import {splitJsxSequences} from './split-jsx-sequence';
export type SplitSequencesOptions<Project extends CodemodProject> = {
project: Project;
- splits: {node: JsxNodeReference; frame: number; sequenceKeys?: string[]}[];
+ splits: {node: NodeReference; frame: number; sequenceKeys?: string[]}[];
};
export const splitSequences = async <Project extends CodemodProject>({
project,
splits,
-}: SplitSequencesOptions<Project>): Promise<DuplicateJsxNodesResult> => {
+}: SplitSequencesOptions<Project>): Promise<DuplicateNodesResult> => {
if (splits.length === 0) {
throw new Error('Expected at least one sequence to split');
}
@@ -27,7 +27,7 @@ export const splitSequences = async <Project extends CodemodProject>({
for (const split of splits) {
const filePath = findProjectFile({project, filePath: split.node.filePath});
if (split.sequenceKeys === undefined) {
- const target = getJsxNodes({project, filePath}).find(
+ const target = getNodes({project, filePath}).find(
(node) =>
JSON.stringify(node.nodePath) === JSON.stringify(split.node.nodePath),
);
@@ -42,7 +42,7 @@ export const splitSequences = async <Project extends CodemodProject>({
);
}
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project,
node: split.node,
keys: ['from', 'durationInFrames', 'trimBefore'],
diff --git a/packages/codemods/src/test/delete-jsx-nodes.test.ts b/packages/codemods/src/test/delete-jsx-nodes.test.ts
index 3e0b8d63ec..c86c5ca43a 100644
--- a/packages/codemods/src/test/delete-jsx-nodes.test.ts
+++ b/packages/codemods/src/test/delete-jsx-nodes.test.ts
@@ -1,5 +1,5 @@
import {expect, test} from 'bun:test';
-import {deleteJsxNodes} from '../delete-jsx-nodes-internal';
+import {deleteNodes} from '../delete-jsx-nodes-internal';
import {
lineColumnToNodePath,
lineContainingToNodePath,
@@ -17,8 +17,8 @@ export const X: React.FC = () => {
};
`;
-test('deleteJsxNodes removes a JSX child from a parent element', async () => {
- const {output} = await deleteJsxNodes({
+test('deleteNodes removes a JSX child from a parent element', async () => {
+ const {output} = await deleteNodes({
input: sample,
nodePaths: [lineColumnToNodePath(sample, 7)],
});
@@ -34,8 +34,8 @@ export const X: React.FC = () => {
};
`;
-test('deleteJsxNodes replaces sole return JSX with null', async () => {
- const {output} = await deleteJsxNodes({
+test('deleteNodes replaces sole return JSX with null', async () => {
+ const {output} = await deleteNodes({
input: onlyReturn,
nodePaths: [lineColumnToNodePath(onlyReturn, 4)],
});
@@ -51,8 +51,8 @@ export const X: React.FC<{show: boolean}> = ({show}) => {
};
`;
-test('deleteJsxNodes turns conditional JSX into null', async () => {
- const {output} = await deleteJsxNodes({
+test('deleteNodes turns conditional JSX into null', async () => {
+ const {output} = await deleteNodes({
input: conditional,
nodePaths: [lineColumnToNodePath(conditional, 4)],
});
@@ -68,8 +68,8 @@ export const X: React.FC<{show: boolean}> = ({show}) => {
};
`;
-test('deleteJsxNodes replaces JSX in ternary consequent with null', async () => {
- const {output} = await deleteJsxNodes({
+test('deleteNodes replaces JSX in ternary consequent with null', async () => {
+ const {output} = await deleteNodes({
input: ternary,
nodePaths: [lineColumnToNodePath(ternary, 4)],
});
@@ -91,8 +91,8 @@ export const X: React.FC = () => {
};
`;
-test('deleteJsxNodes replaces JSX inside map callback', async () => {
- const {output} = await deleteJsxNodes({
+test('deleteNodes replaces JSX inside map callback', async () => {
+ const {output} = await deleteNodes({
input: mapCase,
nodePaths: [lineColumnToNodePath(mapCase, 7)],
});
@@ -115,8 +115,8 @@ export const X: React.FC = () => {
};
`;
-test('deleteJsxNodes removes multiple JSX children in one transform', async () => {
- const {output, nodeLabels, logLines} = await deleteJsxNodes({
+test('deleteNodes removes multiple JSX children in one transform', async () => {
+ const {output, nodeLabels, logLines} = await deleteNodes({
input: multipleSiblings,
nodePaths: [
lineColumnToNodePath(multipleSiblings, 7),
@@ -131,7 +131,7 @@ test('deleteJsxNodes removes multiple JSX children in one transform', async () =
expect(logLines).toEqual([7, 8]);
});
-test('deleteJsxNodes preserves source formatting and removes standalone JSX lines', async () => {
+test('deleteNodes preserves source formatting and removes standalone JSX lines', async () => {
const cases = [
{
input: `export const Comp = () => {
@@ -277,7 +277,7 @@ test('deleteJsxNodes preserves source formatting and removes standalone JSX line
] as const;
for (const item of cases) {
- const {output, formatted} = await deleteJsxNodes({
+ const {output, formatted} = await deleteNodes({
input: item.input,
nodePaths: item.markers.map((marker) =>
lineContainingToNodePath(item.input, marker),
diff --git a/packages/codemods/src/test/duplicate-jsx-node.test.ts b/packages/codemods/src/test/duplicate-jsx-node.test.ts
index 5457d96fb6..0c4aa15cc6 100644
--- a/packages/codemods/src/test/duplicate-jsx-node.test.ts
+++ b/packages/codemods/src/test/duplicate-jsx-node.test.ts
@@ -1,5 +1,5 @@
import {expect, test} from 'bun:test';
-import {duplicateJsxNodes} from '../duplicate-jsx-node';
+import {duplicateNodes} from '../duplicate-jsx-node';
import {
lineColumnToNodePath,
lineContainingToNodePath,
@@ -17,8 +17,8 @@ export const X: React.FC = () => {
};
`;
-test('duplicateJsxNodes inserts a sibling JSX element', async () => {
- const {output} = await duplicateJsxNodes({
+test('duplicateNodes inserts a sibling JSX element', async () => {
+ const {output} = await duplicateNodes({
input: sample,
nodePaths: [lineColumnToNodePath(sample, 7)],
});
@@ -28,7 +28,7 @@ test('duplicateJsxNodes inserts a sibling JSX element', async () => {
expect(output).toContain('<AbsoluteFill>');
});
-test('duplicateJsxNodes remaps following JSX siblings', async () => {
+test('duplicateNodes remaps following JSX siblings', async () => {
const input = `export const X = () => (
<div>
<span name="duplicate" />
@@ -36,7 +36,7 @@ test('duplicateJsxNodes remaps following JSX siblings', async () => {
</div>
);
`;
- const {output, nodePathRemappings} = await duplicateJsxNodes({
+ const {output, nodePathRemappings} = await duplicateNodes({
input,
nodePaths: [lineContainingToNodePath(input, 'name="duplicate"')],
});
@@ -53,7 +53,7 @@ test('duplicateJsxNodes remaps following JSX siblings', async () => {
]);
});
-test('duplicateJsxNodes duplicates each requested JSX element once', async () => {
+test('duplicateNodes duplicates each requested JSX element once', async () => {
const input = `export const X = () => (
<div>
<span name="first" />
@@ -62,7 +62,7 @@ test('duplicateJsxNodes duplicates each requested JSX element once', async () =>
</div>
);
`;
- const {output} = await duplicateJsxNodes({
+ const {output} = await duplicateNodes({
input,
nodePaths: [
lineContainingToNodePath(input, 'name="first"'),
@@ -83,8 +83,8 @@ export const X: React.FC = () => {
};
`;
-test('duplicateJsxNodes wraps sole return JSX in a fragment with two elements', async () => {
- const {output} = await duplicateJsxNodes({
+test('duplicateNodes wraps sole return JSX in a fragment with two elements', async () => {
+ const {output} = await duplicateNodes({
input: onlyReturn,
nodePaths: [lineColumnToNodePath(onlyReturn, 4)],
});
@@ -113,8 +113,8 @@ export const X: React.FC = () => {
};
`;
-test('duplicateJsxNodes duplicates JSX inside map callback', async () => {
- const {output} = await duplicateJsxNodes({
+test('duplicateNodes duplicates JSX inside map callback', async () => {
+ const {output} = await duplicateNodes({
input: mapCase,
nodePaths: [lineColumnToNodePath(mapCase, 7)],
});
@@ -123,7 +123,7 @@ test('duplicateJsxNodes duplicates JSX inside map callback', async () => {
expect(divOpens?.length).toBe(2);
});
-test('duplicateJsxNodes preserves surrounding source formatting', async () => {
+test('duplicateNodes preserves surrounding source formatting', async () => {
const input = `export const X=()=>(
<div data={{value:1}}>
<span name='first' data-value = {1}/>
@@ -131,7 +131,7 @@ test('duplicateJsxNodes preserves surrounding source formatting', async () => {
</div>
)
`;
- const {output} = await duplicateJsxNodes({
+ const {output} = await duplicateNodes({
input,
nodePaths: [lineContainingToNodePath(input, "name='first'")],
});
@@ -146,7 +146,7 @@ test('duplicateJsxNodes preserves surrounding source formatting', async () => {
`);
});
-test('duplicateJsxNodes preserves CRLF line endings', async () => {
+test('duplicateNodes preserves CRLF line endings', async () => {
const input = [
'export const X = () => (',
' <div>',
@@ -155,7 +155,7 @@ test('duplicateJsxNodes preserves CRLF line endings', async () => {
');',
'',
].join('\r\n');
- const {output} = await duplicateJsxNodes({
+ const {output} = await duplicateNodes({
input,
nodePaths: [lineContainingToNodePath(input, 'name="first"')],
});
@@ -173,10 +173,10 @@ test('duplicateJsxNodes preserves CRLF line endings', async () => {
);
});
-test('duplicateJsxNodes preserves inline JSX spacing', async () => {
+test('duplicateNodes preserves inline JSX spacing', async () => {
const input =
'export const X = () => <div><Keep /> <Copy name="item" /><Keep /></div>;\n';
- const {output} = await duplicateJsxNodes({
+ const {output} = await duplicateNodes({
input,
nodePaths: [lineContainingToNodePath(input, '<Copy name="item"')],
});
@@ -186,7 +186,7 @@ test('duplicateJsxNodes preserves inline JSX spacing', async () => {
);
});
-test('duplicateJsxNodes preserves multiline JSX formatting', async () => {
+test('duplicateNodes preserves multiline JSX formatting', async () => {
const input = `export const X = () => (
<div>
<Item
@@ -196,7 +196,7 @@ test('duplicateJsxNodes preserves multiline JSX formatting', async () => {
</div>
);
`;
- const {output} = await duplicateJsxNodes({
+ const {output} = await duplicateNodes({
input,
nodePaths: [lineContainingToNodePath(input, '<Item')],
});
diff --git a/packages/codemods/src/test/formatting.test.ts b/packages/codemods/src/test/formatting.test.ts
index c436dd8504..e19d75d2bf 100644
--- a/packages/codemods/src/test/formatting.test.ts
+++ b/packages/codemods/src/test/formatting.test.ts
@@ -1,9 +1,9 @@
import {expect, test} from 'bun:test';
import {
applyCodemodChanges,
- getJsxNodes,
- updateJsxNodeKeyframes,
- updateJsxNodeProps,
+ getNodes,
+ updateNodeKeyframes,
+ updateNodeProps,
} from '../index';
import {getChangedContents} from './get-changed-contents';
@@ -38,8 +38,8 @@ export const Video = () => {
`);
const filePath = 'src/Video.tsx';
const project = {rootDir: '/', files: {[filePath]: input}};
- const [node] = getJsxNodes({project, filePath});
- const changed = updateJsxNodeProps({
+ const [node] = getNodes({project, filePath});
+ const changed = updateNodeProps({
project,
node,
props: {title: 'Hello'},
@@ -50,7 +50,7 @@ export const Video = () => {
expect(getChangedContents(changed, filePath)).toBe(expected);
const afterChange = applyCodemodChanges(project, changed.changes);
- const repeated = updateJsxNodeProps({
+ const repeated = updateNodeProps({
project: afterChange,
node: changed.updatedNode,
props: {title: 'Hello'},
@@ -58,7 +58,7 @@ export const Video = () => {
const afterRepeat = applyCodemodChanges(afterChange, repeated.changes);
expect(afterRepeat.files[filePath]).toBe(expected);
- const animated = await updateJsxNodeKeyframes({
+ const animated = await updateNodeKeyframes({
project: afterRepeat,
node: repeated.updatedNode,
updates: [
diff --git a/packages/codemods/src/test/get-jsx-nodes.test.ts b/packages/codemods/src/test/get-nodes.test.ts
similarity index 88%
rename from packages/codemods/src/test/get-jsx-nodes.test.ts
rename to packages/codemods/src/test/get-nodes.test.ts
index 63edb1cac3..952417429a 100644
--- a/packages/codemods/src/test/get-jsx-nodes.test.ts
+++ b/packages/codemods/src/test/get-nodes.test.ts
@@ -1,8 +1,8 @@
import {expect, test} from 'bun:test';
-import {getJsxNodes} from '../index';
+import {getNodes} from '../index';
test('lists JSX nodes with their deletion paths in source order', () => {
- const elements = getJsxNodes({
+ const elements = getNodes({
filePath: 'Video.tsx',
project: {
rootDir: '/',
diff --git a/packages/codemods/src/test/node-path-test-utils.ts b/packages/codemods/src/test/node-path-test-utils.ts
index 6809ba3544..18b5522d45 100644
--- a/packages/codemods/src/test/node-path-test-utils.ts
+++ b/packages/codemods/src/test/node-path-test-utils.ts
@@ -1,5 +1,5 @@
import type {SequenceNodePath} from 'remotion';
-import {getJsxNodes} from '../get-jsx-nodes';
+import {getNodes} from '../get-nodes';
import {lineColumnToNodePath as _lineColumnToNodePath} from '../sequence-props';
import {parseAst} from '../sequence-props/parse-ast';
@@ -29,7 +29,7 @@ export const lineContainingToNodePath = (
}
const column = sourceLines[line].indexOf(search);
- const result = getJsxNodes({
+ const result = getNodes({
project: {rootDir: '/', files: {'/test.tsx': input}},
filePath: '/test.tsx',
}).findLast(
diff --git a/packages/codemods/src/test/public-api.test.ts b/packages/codemods/src/test/public-api.test.ts
index 0ac6c93d9f..863ec5d91e 100644
--- a/packages/codemods/src/test/public-api.test.ts
+++ b/packages/codemods/src/test/public-api.test.ts
@@ -3,7 +3,7 @@ import {
addElement,
applyCodemodChanges,
createElement,
- deleteJsxNodes,
+ deleteNodes,
type CodemodProject,
} from '../index';
@@ -89,7 +89,7 @@ test('addElement() immutably updates a virtual project', () => {
]);
});
-test('deleteJsxNodes() deletes nodes from multiple files', async () => {
+test('deleteNodes() deletes nodes from multiple files', async () => {
const project = makeProject();
const first = addSolid({
compositionFile: 'src/Root.tsx',
@@ -103,7 +103,7 @@ test('deleteJsxNodes() deletes nodes from multiple files', async () => {
project: afterFirst,
});
const afterSecond = applyCodemodChanges(afterFirst, second.changes);
- const result = await deleteJsxNodes({
+ const result = await deleteNodes({
nodes: [first.insertedNode, second.insertedNode],
project: afterSecond,
});
@@ -117,7 +117,7 @@ test('deleteJsxNodes() deletes nodes from multiple files', async () => {
]);
});
-test('deleteJsxNodes() deletes the Sequence wrapper identified by a node path', async () => {
+test('deleteNodes() deletes the Sequence wrapper identified by a node path', async () => {
const project = makeProject();
const added = addSolid({
compositionFile: 'src/Root.tsx',
@@ -128,7 +128,7 @@ test('deleteJsxNodes() deletes the Sequence wrapper identified by a node path',
const afterAdd = applyCodemodChanges(project, added.changes);
const sourceWithSolid = afterAdd.files['src/Video.tsx'];
expect(sourceWithSolid).toContain('<Sequence from={10}');
- const result = await deleteJsxNodes({
+ const result = await deleteNodes({
nodes: [
{
filePath: `/${added.insertedNode.filePath}`,
diff --git a/packages/codemods/src/test/public-editing.test.ts b/packages/codemods/src/test/public-editing.test.ts
index 13e5a23524..0151593687 100644
--- a/packages/codemods/src/test/public-editing.test.ts
+++ b/packages/codemods/src/test/public-editing.test.ts
@@ -8,19 +8,19 @@ import {
createElement,
deleteComposition,
deleteEffects,
- deleteJsxNodes,
+ deleteNodes,
detachAudio,
duplicateComposition,
duplicateEffects,
- duplicateJsxNodes,
- getJsxNodeProps,
- getJsxNodes,
+ duplicateNodes,
+ getNodeProps,
+ getNodes,
moveComposition,
moveFolder,
renameComposition,
renameFolder,
reorderEffect,
- reorderJsxNode,
+ reorderNode,
resolveCompositionComponent,
setCompositionDefaultProps,
splitSequences,
@@ -29,10 +29,10 @@ import {
updateCompositionMetadata,
updateEffectKeyframes,
updateEffectProps,
- updateJsxNodeKeyframes,
- updateJsxNodeProps,
- updateMultipleJsxNodeProps,
- wrapJsxNode,
+ updateNodeKeyframes,
+ updateNodeProps,
+ updateMultipleNodeProps,
+ wrapNode,
type CodemodProject,
} from '../index';
import {getChangedContents} from './get-changed-contents';
@@ -69,7 +69,7 @@ const findNode = (
tagName: string,
sourceFile = filePath,
) => {
- const node = getJsxNodes({project, filePath: sourceFile}).find(
+ const node = getNodes({project, filePath: sourceFile}).find(
(item) => item.tagName === tagName,
);
if (!node) throw new Error(`No ${tagName} in ${sourceFile}`);
@@ -88,9 +88,9 @@ test('discover, inspect, edit, animate, and remove JSX through the public API',
const node = findNode(project, 'div');
expect(node.location?.line).toBe(4);
expect(
- getJsxNodeProps({project, node, keys: ['children']}).props.children,
+ getNodeProps({project, node, keys: ['children']}).props.children,
).toMatchObject({status: 'static', codeValue: 'Hello'});
- const changed = updateJsxNodeProps({
+ const changed = updateNodeProps({
project,
node,
props: {children: 'Goodbye', 'style.opacity': 0.75, title: 'Example'},
@@ -102,7 +102,7 @@ test('discover, inspect, edit, animate, and remove JSX through the public API',
expect(getChangedContents(changed, filePath)).toContain(
'const unrelated = {value:"keep"};',
);
- const animated = await updateJsxNodeKeyframes({
+ const animated = await updateNodeKeyframes({
project: afterChange,
node: changed.updatedNode,
updates: [
@@ -119,7 +119,7 @@ test('discover, inspect, edit, animate, and remove JSX through the public API',
),
).toBe(true);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterAnimation,
node: animated.updatedNode,
keys: ['style.opacity'],
@@ -131,7 +131,7 @@ test('discover, inspect, edit, animate, and remove JSX through the public API',
{frame: 30, value: 1},
],
});
- const withoutTitle = updateJsxNodeProps({
+ const withoutTitle = updateNodeProps({
project: afterAnimation,
node: animated.updatedNode,
props: {title: undefined},
@@ -141,12 +141,12 @@ test('discover, inspect, edit, animate, and remove JSX through the public API',
afterAnimation,
withoutTitle.changes,
);
- const deleted = await deleteJsxNodes({
+ const deleted = await deleteNodes({
project: afterRemoveTitle,
nodes: [withoutTitle.updatedNode],
});
expect(
- getJsxNodes({
+ getNodes({
project: applyCodemodChanges(afterRemoveTitle, deleted.changes),
filePath,
}).map((entry) => entry.tagName),
@@ -183,13 +183,13 @@ test('insert media and components, reorder copies, and delete nodes across files
);
const afterMedia = applyCodemodChanges(project, media.changes);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterMedia,
node: media.insertedNode,
keys: ['from'],
}).props.from,
).toMatchObject({codeValue: 10});
- const imageNode = getJsxNodes({project: afterMedia, filePath}).find(
+ const imageNode = getNodes({project: afterMedia, filePath}).find(
(node) => node.tagName === 'Img',
)!;
expect(imageNode.parentNodePath).toEqual(media.insertedNode.nodePath);
@@ -207,7 +207,7 @@ test('insert media and components, reorder copies, and delete nodes across files
'<Title text="A title" />',
);
const afterAdd = applyCodemodChanges(afterMedia, added.changes);
- const duplicated = await duplicateJsxNodes({
+ const duplicated = await duplicateNodes({
project: afterAdd,
nodes: [added.insertedNode, findNode(afterAdd, 'div', 'src/Title.tsx')],
});
@@ -220,14 +220,14 @@ test('insert media and components, reorder copies, and delete nodes across files
(node) => node.filePath === filePath,
)!;
const afterDuplicate = applyCodemodChanges(afterAdd, duplicated.changes);
- const reordered = await reorderJsxNode({
+ const reordered = await reorderNode({
project: afterDuplicate,
node: copiedTitle,
target: added.insertedNode,
position: 'before',
});
const afterReorder = applyCodemodChanges(afterDuplicate, reordered.changes);
- const updatedCopy = updateJsxNodeProps({
+ const updatedCopy = updateNodeProps({
project: afterReorder,
node: reordered.updatedNode,
props: {text: 'Copied title'},
@@ -236,7 +236,7 @@ test('insert media and components, reorder copies, and delete nodes across files
getChangedContents(updatedCopy, filePath).indexOf('Copied title'),
).toBeLessThan(getChangedContents(updatedCopy, filePath).indexOf('A title'));
const afterUpdate = applyCodemodChanges(afterReorder, updatedCopy.changes);
- const deleted = await deleteJsxNodes({
+ const deleted = await deleteNodes({
project: afterUpdate,
nodes: [
updatedCopy.updatedNode,
@@ -247,7 +247,7 @@ test('insert media and components, reorder copies, and delete nodes across files
});
const afterDelete = applyCodemodChanges(afterUpdate, deleted.changes);
expect(
- getJsxNodes({project: afterDelete, filePath}).filter(
+ getNodes({project: afterDelete, filePath}).filter(
(node) => node.tagName === 'Title',
),
).toHaveLength(1);
@@ -270,7 +270,7 @@ export const VideoComposition = () => <><Video src="video.mp4" from={10} duratio
const secondVideo = split.insertedNodes[0];
const afterSplit = applyCodemodChanges(project, split.changes);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterSplit,
node: secondVideo,
keys: ['from', 'durationInFrames', 'trimBefore'],
@@ -286,14 +286,14 @@ export const VideoComposition = () => <><Video src="video.mp4" from={10} duratio
});
const afterDetach = applyCodemodChanges(afterSplit, detached.changes);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterDetach,
node: detached.updatedNode,
keys: ['muted'],
}).props.muted,
).toMatchObject({codeValue: true});
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterDetach,
node: detached.insertedNode,
keys: ['src', 'trimBefore'],
@@ -424,14 +424,14 @@ test('manage composition registrations and nested folders without changing compo
);
expect(project.files[compositionFile]).not.toContain('name="Social"');
expect(project.files[compositionFile]).toContain('name="Published"');
- const composition = getJsxNodes({project, filePath: compositionFile}).find(
+ const composition = getNodes({project, filePath: compositionFile}).find(
(node) => {
- const status = getJsxNodeProps({project, node, keys: ['id']}).props.id;
+ const status = getNodeProps({project, node, keys: ['id']}).props.id;
return status.status === 'static' && status.codeValue === 'Vertical';
},
)!;
expect(
- getJsxNodeProps({
+ getNodeProps({
project,
node: composition,
keys: ['width', 'height', 'fps', 'durationInFrames', 'defaultProps'],
@@ -505,7 +505,7 @@ test('add, duplicate, reorder, edit, animate, and delete effects', async () => {
],
});
const afterAnimation = applyCodemodChanges(afterEdit, animated.changes);
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project: afterAnimation,
node: animated.updatedEffect,
keys: [],
@@ -525,7 +525,7 @@ test('add, duplicate, reorder, edit, animate, and delete effects', async () => {
});
const afterDelete = applyCodemodChanges(afterAnimation, deleted.changes);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterDelete,
node: animated.updatedEffect,
keys: [],
@@ -545,13 +545,13 @@ test('reject unsupported expressions and invalid edits atomically', async () =>
const original = {...project.files};
const node = findNode(project, 'div');
expect(
- getJsxNodeProps({project, node, keys: ['from', 'style.opacity']}).props,
+ getNodeProps({project, node, keys: ['from', 'style.opacity']}).props,
).toEqual({
from: {status: 'computed'},
'style.opacity': {status: 'computed'},
});
expect(() =>
- updateJsxNodeProps({project, node, props: {'style.opacity': 1}}),
+ updateNodeProps({project, node, props: {'style.opacity': 1}}),
).toThrow('computed');
expect(() =>
duplicateComposition({
@@ -570,13 +570,13 @@ test('reject unsupported expressions and invalid edits atomically', async () =>
}),
).toThrow('positive');
await expect(
- deleteJsxNodes({
+ deleteNodes({
project,
nodes: [node, {filePath: 'missing.tsx', nodePath: []}],
}),
).rejects.toThrow();
await expect(
- reorderJsxNode({
+ reorderNode({
project,
node,
target: findNode(project, 'Composition', compositionFile),
@@ -613,14 +613,14 @@ test('addElement returns remappings usable by public discovery and targets nodes
),
).toBe(true);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterInsert,
node: inserted.insertedNode,
keys: ['from'],
}).props.from,
).toMatchObject({status: 'static', codeValue: 15});
- const nodes = getJsxNodes({project: afterInsert, filePath});
+ const nodes = getNodes({project: afterInsert, filePath});
const sequence = nodes.find((node) => node.tagName === 'Sequence')!;
const div = nodes.find((node) => node.tagName === 'div')!;
const caption = createElement({
@@ -641,7 +641,7 @@ test('addElement returns remappings usable by public discovery and targets nodes
);
const afterInside = applyCodemodChanges(afterInsert, inside.changes);
expect(
- getJsxNodes({project: afterInside, filePath})
+ getNodes({project: afterInside, filePath})
.filter(
(node) =>
JSON.stringify(node.parentNodePath) ===
@@ -654,19 +654,19 @@ test('addElement returns remappings usable by public discovery and targets nodes
element: createElement({component: 'span', children: ['first']}),
target: {
type: 'before',
- node: getJsxNodes({project: afterInside, filePath}).find(
+ node: getNodes({project: afterInside, filePath}).find(
(node) => node.tagName === 'div',
)!,
},
});
const afterBefore = applyCodemodChanges(afterInside, before.changes);
expect(
- getJsxNodes({project: afterBefore, filePath}).map((node) => node.tagName),
+ getNodes({project: afterBefore, filePath}).map((node) => node.tagName),
).toEqual(['AbsoluteFill', 'span', 'div', 'Sequence', 'Solid', 'p', 'br']);
expect(afterBefore.files[filePath]).toContain('<span>first</span>');
- const wrapped = wrapJsxNode({
+ const wrapped = wrapNode({
project: afterBefore,
- node: getJsxNodes({project: afterBefore, filePath}).find(
+ node: getNodes({project: afterBefore, filePath}).find(
(node) => node.tagName === 'div',
)!,
wrapper: createElement({
@@ -679,7 +679,7 @@ test('addElement returns remappings usable by public discovery and targets nodes
'<Sequence from={5} name="Wrapped">',
);
expect(() =>
- wrapJsxNode({
+ wrapNode({
project: afterBefore,
node: div,
wrapper: createElement({component: 'div', children: ['x']}),
@@ -687,7 +687,7 @@ test('addElement returns remappings usable by public discovery and targets nodes
).toThrow('cannot have children');
// Canvas wrappers are validated even when they reuse an existing import.
expect(() =>
- wrapJsxNode({
+ wrapNode({
project: afterBefore,
node: div,
wrapper: createElement({
@@ -710,7 +710,7 @@ test('addElement returns remappings usable by public discovery and targets nodes
}),
target: {
type: 'inside',
- node: getJsxNodes({project: conflicting, filePath: 'svg.tsx'})[0],
+ node: getNodes({project: conflicting, filePath: 'svg.tsx'})[0],
},
});
expect(getChangedContents(escaped, 'svg.tsx')).toContain(
@@ -720,9 +720,9 @@ test('addElement returns remappings usable by public discovery and targets nodes
"import {staticFile as staticFile2} from 'remotion';",
);
expect(() =>
- updateJsxNodeProps({
+ updateNodeProps({
project: conflicting,
- node: getJsxNodes({project: conflicting, filePath: 'svg.tsx'})[0],
+ node: getNodes({project: conflicting, filePath: 'svg.tsx'})[0],
props: {href: staticFileValue('x.png')},
}),
).toThrow('already bound');
@@ -782,7 +782,7 @@ test('nested copies return root references and insertion preserves relative keys
expect(media.insertedNode.filePath).toBe(filePath);
const afterMedia = applyCodemodChanges(original, media.changes);
expect(Object.keys(afterMedia.files)).toEqual(Object.keys(original.files));
- const copy = await duplicateJsxNodes({
+ const copy = await duplicateNodes({
project: afterMedia,
nodes: [media.insertedNode],
});
@@ -797,12 +797,12 @@ test('nested copies return root references and insertion preserves relative keys
});
expect(split.insertedNodes).toHaveLength(1);
const afterSplit = applyCodemodChanges(afterCopy, split.changes);
- const deleted = await deleteJsxNodes({
+ const deleted = await deleteNodes({
project: afterSplit,
nodes: split.insertedNodes,
});
expect(
- getJsxNodes({
+ getNodes({
project: applyCodemodChanges(afterSplit, deleted.changes),
filePath,
}).filter((node) => node.tagName === 'Sequence'),
@@ -835,7 +835,7 @@ test('node discovery and edits use original source locations with tabs and CRLF'
'\uFEFFexport const Video = () => (\r\n\t<div style={{opacity: 1}}>Hello</div>\r\n);\r\n';
const node = findNode(project, 'div');
expect(node.location).toEqual({line: 2, column: 1});
- const edited = updateJsxNodeProps({
+ const edited = updateNodeProps({
project,
node,
props: {'style.opacity': 0.25},
@@ -854,9 +854,9 @@ test('batch structured prop edits across files and preserve edit results in requ
'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({
+ const first = getNodes({project, filePath: 'first.tsx'})[0];
+ const second = getNodes({project, filePath: 'second.tsx'})[0];
+ const result = updateMultipleNodeProps({
project,
changes: [
{
@@ -877,7 +877,7 @@ test('batch structured prop edits across files and preserve edit results in requ
]);
const updated = applyCodemodChanges(project, result.changes);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: updated,
node: result.updatedNodes[0],
keys: ['style.opacity', 'title'],
@@ -887,7 +887,7 @@ test('batch structured prop edits across files and preserve edit results in requ
title: {codeValue: 'updated first'},
});
expect(
- getJsxNodeProps({
+ getNodeProps({
project: updated,
node: result.updatedNodes[1],
keys: ['title'],
@@ -948,7 +948,7 @@ test('default prop enum serialization shares node lookup, insertion, and spread
});
const afterUpdate = applyCodemodChanges(afterInsert, updated.changes);
expect(
- getJsxNodeProps({
+ getNodeProps({
project: afterUpdate,
node: updated.updatedNode,
keys: ['defaultProps'],
diff --git a/packages/codemods/src/test/reorder-sequence.test.ts b/packages/codemods/src/test/reorder-sequence.test.ts
index ec163cc939..ed6d569a6f 100644
--- a/packages/codemods/src/test/reorder-sequence.test.ts
+++ b/packages/codemods/src/test/reorder-sequence.test.ts
@@ -1,5 +1,5 @@
import {expect, test} from 'bun:test';
-import {getJsxNodes} from '../get-jsx-nodes';
+import {getNodes} from '../get-nodes';
import {reorderSequence} from '../reorder-sequence';
import {lineColumnToNodePath} from './node-path-test-utils';
@@ -17,7 +17,7 @@ const sequenceContaining = (input: string, search: string) => {
}
const sourceBeforeOpening = input.slice(0, openingOffset).split('\n');
- const nodePath = getJsxNodes({
+ const nodePath = getNodes({
project: {rootDir: '/', files: {'/test.tsx': input}},
filePath: '/test.tsx',
}).find(
diff --git a/packages/codemods/src/update-effect-keyframes.ts b/packages/codemods/src/update-effect-keyframes.ts
index 5597b2de04..d976315e6b 100644
--- a/packages/codemods/src/update-effect-keyframes.ts
+++ b/packages/codemods/src/update-effect-keyframes.ts
@@ -5,11 +5,11 @@ import {
getUnchangedStructureRemappings,
getUpdatedNodeReference,
} from './node-references';
-import type {UpdateJsxNodeKeyframesOptions} from './update-jsx-node-keyframes';
import {updateEffectKeyframes as updateEffectKeyframesInSource} from './update-keyframes';
+import type {UpdateNodeKeyframesOptions} from './update-node-keyframes';
export type UpdateEffectKeyframesOptions<Project extends CodemodProject> = Omit<
- UpdateJsxNodeKeyframesOptions<Project>,
+ UpdateNodeKeyframesOptions<Project>,
'node'
> & {effect: EffectReference};
diff --git a/packages/codemods/src/update-effect-props.ts b/packages/codemods/src/update-effect-props.ts
index 1654e54795..47dae63cf0 100644
--- a/packages/codemods/src/update-effect-props.ts
+++ b/packages/codemods/src/update-effect-props.ts
@@ -7,7 +7,7 @@ import {
type UpdateEffectPropsResult,
} from './effect-operations';
import {type EffectReference, getEffectSource} from './effect-references';
-import {getJsxNodeProps} from './get-jsx-node-props';
+import {getNodeProps} from './get-node-props';
import {
getNodeEditResult,
getUnchangedStructureRemappings,
@@ -51,7 +51,7 @@ export const updateEffectProps = async <Project extends CodemodProject>({
throw new Error('Expected at least one effect prop');
}
- const status = getJsxNodeProps({
+ const status = getNodeProps({
project,
node: effect,
keys: [],
diff --git a/packages/codemods/src/update-jsx-node-keyframes.ts b/packages/codemods/src/update-node-keyframes.ts
similarity index 78%
rename from packages/codemods/src/update-jsx-node-keyframes.ts
rename to packages/codemods/src/update-node-keyframes.ts
index e6af988252..712e9615b9 100644
--- a/packages/codemods/src/update-jsx-node-keyframes.ts
+++ b/packages/codemods/src/update-node-keyframes.ts
@@ -5,32 +5,32 @@ import {
getNodeEditResult,
getUnchangedStructureRemappings,
getUpdatedNodeReference,
- type JsxNodeReference,
+ type NodeReference,
} from './node-references';
import {
updateSequenceKeyframes,
type SequenceKeyframeUpdate,
} from './update-keyframes';
-export type JsxNodeKeyframeUpdate = SequenceKeyframeUpdate;
+export type NodeKeyframeUpdate = SequenceKeyframeUpdate;
-export type UpdateJsxNodeKeyframesOptions<Project extends CodemodProject> = {
+export type UpdateNodeKeyframesOptions<Project extends CodemodProject> = {
project: Project;
- node: JsxNodeReference;
- updates: JsxNodeKeyframeUpdate[];
+ node: NodeReference;
+ updates: NodeKeyframeUpdate[];
schema?: InteractivitySchema;
videoConfig?: VideoConfigValues;
prettierConfigOverride?: Record<string, unknown> | null;
};
-export const updateJsxNodeKeyframes = async <Project extends CodemodProject>({
+export const updateNodeKeyframes = async <Project extends CodemodProject>({
project,
node,
updates,
schema,
videoConfig,
prettierConfigOverride,
-}: UpdateJsxNodeKeyframesOptions<Project>) => {
+}: UpdateNodeKeyframesOptions<Project>) => {
if (updates.length === 0) {
throw new Error('Expected at least one keyframe update');
}
diff --git a/packages/codemods/src/update-jsx-node-props.ts b/packages/codemods/src/update-node-props.ts
similarity index 80%
rename from packages/codemods/src/update-jsx-node-props.ts
rename to packages/codemods/src/update-node-props.ts
index 5f0a4ada83..6d28e75af7 100644
--- a/packages/codemods/src/update-jsx-node-props.ts
+++ b/packages/codemods/src/update-node-props.ts
@@ -1,16 +1,16 @@
import type {InteractivitySchema, VideoConfigValues} from 'remotion';
import type {CodemodProject} from './codemod-project';
import type {CodemodValue} from './codemod-value';
-import {getJsxNodeProps} from './get-jsx-node-props';
import {
captureJsxNodePaths,
getNodePathRemappings,
} from './get-node-path-remappings';
+import {getNodeProps} from './get-node-props';
import {findProjectFile} from './internals';
import {
getNodeEditResult,
getUpdatedNodeReference,
- type JsxNodeReference,
+ type NodeReference,
type NodeSourceEdit,
} from './node-references';
import {takeSourceSnapshotForEdit} from './sequence-props-snapshot';
@@ -24,38 +24,34 @@ type JsxNodePropValues =
| {props: Record<string, CodemodValue | undefined>; updates?: never}
| {updates: SequencePropUpdate[]; props?: never};
-export type JsxNodePropChange = JsxNodePropValues & {
- node: JsxNodeReference;
+export type NodePropChange = JsxNodePropValues & {
+ node: NodeReference;
schema?: InteractivitySchema;
videoConfig?: VideoConfigValues;
};
-export type UpdateJsxNodePropsOptions<Project extends CodemodProject> =
- JsxNodePropChange & {
+export type UpdateNodePropsOptions<Project extends CodemodProject> =
+ NodePropChange & {
project: Project;
prettierConfigOverride?: Record<string, unknown> | null;
};
-export type UpdateMultipleJsxNodePropsOptions<Project extends CodemodProject> =
- {
- project: Project;
- changes: JsxNodePropChange[];
- prettierConfigOverride?: Record<string, unknown> | null;
- };
+export type UpdateMultipleNodePropsOptions<Project extends CodemodProject> = {
+ project: Project;
+ changes: NodePropChange[];
+ prettierConfigOverride?: Record<string, unknown> | null;
+};
-export const updateMultipleJsxNodeProps = <Project extends CodemodProject>({
+export const updateMultipleNodeProps = <Project extends CodemodProject>({
project,
changes,
prettierConfigOverride,
-}: UpdateMultipleJsxNodePropsOptions<Project>) => {
+}: UpdateMultipleNodePropsOptions<Project>) => {
if (changes.length === 0) {
throw new Error('Expected at least one node to update');
}
- const groups = new Map<
- string,
- {change: JsxNodePropChange; index: number}[]
- >();
+ const groups = new Map<string, {change: NodePropChange; index: number}[]>();
for (const [index, change] of changes.entries()) {
const filePath = findProjectFile({project, filePath: change.node.filePath});
const group = groups.get(filePath) ?? [];
@@ -82,7 +78,7 @@ export const updateMultipleJsxNodeProps = <Project extends CodemodProject>({
const keys = updates.map(({key}) => key);
const status = change.updates
? null
- : getJsxNodeProps({
+ : getNodeProps({
project,
node: change.node,
keys,
@@ -141,12 +137,12 @@ export const updateMultipleJsxNodeProps = <Project extends CodemodProject>({
};
};
-export const updateJsxNodeProps = <Project extends CodemodProject>({
+export const updateNodeProps = <Project extends CodemodProject>({
project,
prettierConfigOverride,
...change
-}: UpdateJsxNodePropsOptions<Project>) => {
- const result = updateMultipleJsxNodeProps({
+}: UpdateNodePropsOptions<Project>) => {
+ const result = updateMultipleNodeProps({
project,
changes: [change],
prettierConfigOverride,
diff --git a/packages/codemods/src/wrap-jsx-node.ts b/packages/codemods/src/wrap-node.ts
similarity index 96%
rename from packages/codemods/src/wrap-jsx-node.ts
rename to packages/codemods/src/wrap-node.ts
index d81fb481db..4863fe3743 100644
--- a/packages/codemods/src/wrap-jsx-node.ts
+++ b/packages/codemods/src/wrap-node.ts
@@ -10,7 +10,7 @@ import {
getNodePathRemappings,
} from './get-node-path-remappings';
import {findProjectFile} from './internals';
-import {getNodeEditResult, type JsxNodeReference} from './node-references';
+import {getNodeEditResult, type NodeReference} from './node-references';
import {printJsxOpeningElement} from './print-jsx';
import {recastLocToOffset} from './recast-loc-to-offset';
import {getImportedName} from './sequence-props/imports';
@@ -23,9 +23,9 @@ import {
import {getEndOfLine, getIndentationUnit, getLineIndent} from './source-style';
import {stripParenthesizedExtra} from './strip-parenthesized-extra';
-export type WrapJsxNodeOptions<Project extends CodemodProject> = {
+export type WrapNodeOptions<Project extends CodemodProject> = {
project: Project;
- node: JsxNodeReference;
+ node: NodeReference;
wrapper: CodemodElement;
};
@@ -51,7 +51,7 @@ const getHtmlInCanvasWrapperName = (wrapper: CodemodElement) => {
return null;
};
-export const canWrapJsxNode = ({
+export const canWrapNode = ({
input,
nodePath,
}: {
@@ -120,11 +120,11 @@ export const canWrapJsxNode = ({
return {canWrap: true, canWrapHtmlInCanvas: !containsHtmlInCanvas};
};
-export const wrapJsxNode = <Project extends CodemodProject>({
+export const wrapNode = <Project extends CodemodProject>({
project,
node,
wrapper,
-}: WrapJsxNodeOptions<Project>) => {
+}: WrapNodeOptions<Project>) => {
if (!(wrapper instanceof CodemodElement)) {
throw new Error('wrapper must be created with createElement()');
}
@@ -137,7 +137,7 @@ export const wrapJsxNode = <Project extends CodemodProject>({
const filePath = findProjectFile({project, filePath: node.filePath});
const input = project.files[filePath];
- const eligibility = canWrapJsxNode({input, nodePath: node.nodePath});
+ const eligibility = canWrapNode({input, nodePath: node.nodePath});
const htmlInCanvasWrapper = getHtmlInCanvasWrapperName(wrapper);
if (
!eligibility.canWrap ||
diff --git a/packages/docs/docs/canvas/create-canvas-controller.mdx b/packages/docs/docs/canvas/create-canvas-controller.mdx
index 5ae9147bb5..e8966d9b77 100644
--- a/packages/docs/docs/canvas/create-canvas-controller.mdx
+++ b/packages/docs/docs/canvas/create-canvas-controller.mdx
@@ -62,7 +62,7 @@ A `CanvasHoverController` with `getSnapshot()`, `subscribe(listener)`, `setHover
### setSequenceNodePaths()<AvailableFrom v="4.0.529" />
-`setSequenceNodePaths(nodePaths)` tells the Canvas which source node each mounted sequence was created from. `nodePaths` is a `Record<string, SequencePropsSubscriptionKey>` keyed by `track.sequence.controls.overrideId`. Import the `SequencePropsSubscriptionKey` type from `remotion`; its `absolutePath` and `nodePath` identify the JSX node, as returned by [`getJsxNodes()`](/docs/codemods/get-jsx-nodes). Pass empty arrays for `sequenceKeys` and `effectKeys`, and `track.sequence.controls.videoConfigValues` or `null` for `videoConfigValues`.
+`setSequenceNodePaths(nodePaths)` tells the Canvas which source node each mounted sequence was created from. `nodePaths` is a `Record<string, SequencePropsSubscriptionKey>` keyed by `track.sequence.controls.overrideId`. Import the `SequencePropsSubscriptionKey` type from `remotion`; its `absolutePath` and `nodePath` identify the JSX node, as returned by [`getNodes()`](/docs/codemods/get-nodes). Pass empty arrays for `sequenceKeys` and `effectKeys`, and `track.sequence.controls.videoConfigValues` or `null` for `videoConfigValues`.
Afterwards, the affected tracks carry a `nodePathInfo` with that `sequenceSubscriptionKey`. Tracks rendered from the same source node are numbered through `index` and `numberOfSequencesWithThisNodePath`. [`getCanvasSequenceNodePathInfo()`](/docs/canvas/get-canvas-sequence-node-path-info) returns the registered identity, so selection and hover stay attached to the source node across remounts.
@@ -70,13 +70,13 @@ Passing an unchanged mapping is a no-op, so the function may be called from a `t
### overrides<AvailableFrom v="4.0.529" />
-Preview prop values on mounted sequences without changing the source. Overrides are applied to sequences that have a `nodePathInfo`, so register node paths first. They are kept while the composition stays mounted and are not persisted; write the final value to the source, for example with [`updateJsxNodeProps()`](/docs/codemods/update-jsx-node-props), and clear the override once the update has been applied.
+Preview prop values on mounted sequences without changing the source. Overrides are applied to sequences that have a `nodePathInfo`, so register node paths first. They are kept while the composition stays mounted and are not persisted; write the final value to the source, for example with [`updateNodeProps()`](/docs/codemods/update-node-props), and clear the override once the update has been applied.
#### set()
`set(nodePathInfo, key, value)` overrides one prop of the sequence identified by `nodePathInfo`, a `SequenceNodePathInfo` from a track or a selection item. `key` is a key of the element's interactivity schema in dot notation, such as `'style.translate'`, `'from'` or `'durationInFrames'`.
-`value` is either `{type: 'static', value}` to show a fixed value, or `{type: 'keyframed', status}` where `status` is a keyframed prop status as returned by [`getJsxNodeProps()`](/docs/codemods/get-jsx-node-props) with the keyframes you want to preview. A keyframed override is evaluated at the current frame.
+`value` is either `{type: 'static', value}` to show a fixed value, or `{type: 'keyframed', status}` where `status` is a keyframed prop status as returned by [`getNodeProps()`](/docs/codemods/get-node-props) with the keyframes you want to preview. A keyframed override is evaluated at the current frame.
```tsx twoslash title="Scrubbing a value"
// @moduleResolution: bundler
diff --git a/packages/docs/docs/canvas/get-canvas-sequence-source-location.mdx b/packages/docs/docs/canvas/get-canvas-sequence-source-location.mdx
index 21f9ead57a..3512d5ec94 100644
--- a/packages/docs/docs/canvas/get-canvas-sequence-source-location.mdx
+++ b/packages/docs/docs/canvas/get-canvas-sequence-source-location.mdx
@@ -6,7 +6,7 @@ crumb: '@remotion/canvas'
# getCanvasSequenceSourceLocation()<AvailableFrom v="4.0.529" />
-Returns where the JSX element of a timeline track was written, if the bundler recorded it. Use it to look up the source node of a mounted sequence, for example with [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) from [`@remotion/codemods`](/docs/codemods), and pass the result to [`controller.setSequenceNodePaths()`](/docs/canvas/create-canvas-controller#setsequencenodepaths).
+Returns where the JSX element of a timeline track was written, if the bundler recorded it. Use it to look up the source node of a mounted sequence, for example with [`getNodes()`](/docs/codemods/get-nodes) from [`@remotion/codemods`](/docs/codemods), and pass the result to [`controller.setSequenceNodePaths()`](/docs/canvas/create-canvas-controller#setsequencenodepaths).
:::warning
@@ -22,7 +22,7 @@ declare const controller: CanvasController;
declare const project: CodemodProject;
// ---cut---
import {getCanvasSequenceSourceLocation} from '@remotion/canvas';
-import {getJsxNodes} from '@remotion/codemods';
+import {getNodes} from '@remotion/codemods';
import type {SequencePropsSubscriptionKey} from 'remotion';
export const resolveNodePaths = () => {
@@ -34,7 +34,7 @@ export const resolveNodePaths = () => {
continue;
}
- const node = getJsxNodes({project, filePath: location.fileName}).find(
+ const node = getNodes({project, filePath: location.fileName}).find(
(candidate) =>
candidate.location?.line === location.line &&
candidate.location.column === location.column,
@@ -78,7 +78,7 @@ The 1-based line of the JSX element.
### column
-The 0-based column of the JSX element. This matches the `location` of [`getJsxNodes()`](/docs/codemods/get-jsx-nodes).
+The 0-based column of the JSX element. This matches the `location` of [`getNodes()`](/docs/codemods/get-nodes).
## Compatibility
@@ -88,4 +88,4 @@ The 0-based column of the JSX element. This matches the `location` of [`getJsxNo
- [`createCanvasController()`](/docs/canvas/create-canvas-controller)
- [`getCanvasSequenceNodePathInfo()`](/docs/canvas/get-canvas-sequence-node-path-info)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/canvas/index.mdx b/packages/docs/docs/canvas/index.mdx
index 3ff9b95bc3..3449e6a48f 100644
--- a/packages/docs/docs/canvas/index.mdx
+++ b/packages/docs/docs/canvas/index.mdx
@@ -122,7 +122,7 @@ The timeline contains registered [`<Sequence>`](/docs/sequence) and other sequen
The built-in [`getCanvasSequenceNodePathInfo()`](/docs/canvas/get-canvas-sequence-node-path-info) uses a source identity when available. Otherwise it falls back to a mounted sequence ID, which can change after a remount.
-If your editor has the source code, register the source node of each sequence with [`setSequenceNodePaths()`](/docs/canvas/create-canvas-controller#setsequencenodepaths). For projects compiled with [`@remotion/browser-bundler`](/docs/browser-bundler), [`getCanvasSequenceSourceLocation()`](/docs/canvas/get-canvas-sequence-source-location) returns the file and position of each sequence's JSX element, which [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) maps to a node path. Alternatively, pass a custom `resolveSequenceNodePathInfo` to `<Canvas>` and use the same resolver for layer items. Return `null` for tracks that should not be selectable.
+If your editor has the source code, register the source node of each sequence with [`setSequenceNodePaths()`](/docs/canvas/create-canvas-controller#setsequencenodepaths). For projects compiled with [`@remotion/browser-bundler`](/docs/browser-bundler), [`getCanvasSequenceSourceLocation()`](/docs/canvas/get-canvas-sequence-source-location) returns the file and position of each sequence's JSX element, which [`getNodes()`](/docs/codemods/get-nodes) maps to a node path. Alternatively, pass a custom `resolveSequenceNodePathInfo` to `<Canvas>` and use the same resolver for layer items. Return `null` for tracks that should not be selectable.
An outline requires a registered DOM element. A `<Sequence layout="none">` has no outline of its own.
diff --git a/packages/docs/docs/codemods/add-composition.mdx b/packages/docs/docs/codemods/add-composition.mdx
index 5fcecbddc9..1dab5b0b20 100644
--- a/packages/docs/docs/codemods/add-composition.mdx
+++ b/packages/docs/docs/codemods/add-composition.mdx
@@ -42,7 +42,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
The project file containing the composition registrations. Registration edits support [`<Composition>`](/docs/composition), [`<Still>`](/docs/still), and [`<Folder>`](/docs/folder) with static IDs or folder names. Aliased and namespace imports from `remotion` are supported.
-When `folder` is omitted, the file must have one component containing registrations, or a single JSX component if no registrations exist yet. The first JSX return in the selected component is used; returns in nested functions are ignored.
+When `folder` is omitted, the file must have one component containing registrations, or a single component if no registrations exist yet. The first JSX return in the selected component is used; returns in nested functions are ignored.
### compositionId
@@ -104,4 +104,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/add-composition.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/add-effect.mdx b/packages/docs/docs/codemods/add-effect.mdx
index 4df25dfa75..4cdc477d47 100644
--- a/packages/docs/docs/codemods/add-effect.mdx
+++ b/packages/docs/docs/codemods/add-effect.mdx
@@ -15,10 +15,10 @@ _Draft API_: This API is experimental and may change.
:::
```ts twoslash title="add-effect.ts"
-import {addEffect, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+import {addEffect, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
const result = await addEffect({
project,
@@ -31,7 +31,7 @@ const result = await addEffect({
console.log(result);
```
-Creates the `effects` attribute if missing. The JSX component must support effects at runtime. Computed effects arrays and potentially overriding spreads are rejected; packages are not installed.
+Creates the `effects` attribute if missing. The component must support effects at runtime. Computed effects arrays and potentially overriding spreads are rejected; packages are not installed.
## Options
@@ -41,7 +41,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-A [`JsxNodeReference`](/docs/codemods#node-references) from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous operation. It contains `filePath` and `nodePath`.
+A [`NodeReference`](/docs/codemods#node-references) from [`getNodes()`](/docs/codemods/get-nodes) or a previous operation. It contains `filePath` and `nodePath`.
### importName
@@ -83,4 +83,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/add-effect.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/add-element.mdx b/packages/docs/docs/codemods/add-element.mdx
index 208feaf517..5dd102aab4 100644
--- a/packages/docs/docs/codemods/add-element.mdx
+++ b/packages/docs/docs/codemods/add-element.mdx
@@ -6,7 +6,7 @@ crumb: '@remotion/codemods'
# addElement()<AvailableFrom v="4.0.530" />
-Inserts an element created with [`createElement()`](/docs/codemods/create-element) into a composition component or relative to an existing JSX node, and adds the imports it needs.
+Inserts an element created with [`createElement()`](/docs/codemods/create-element) into a composition component or relative to an existing node, and adds the imports it needs.
:::warning
@@ -88,21 +88,21 @@ Appends the element to the component of the composition with the static ID `comp
#### `{type: 'component', filePath, exportName}`
-Appends the element to the JSX returned by the component that `filePath` exports as `exportName`, or as its default export when `exportName` is `'default'`. Use it when the component is already known, for example from [`resolveCompositionComponent()`](/docs/codemods/resolve-composition-component). Follows the same rules as the `composition` target.
+Appends the element to the root returned by the component that `filePath` exports as `exportName`, or as its default export when `exportName` is `'default'`. Use it when the component is already known, for example from [`resolveCompositionComponent()`](/docs/codemods/resolve-composition-component). Follows the same rules as the `composition` target.
#### `{type: 'inside', node}`
-Appends the element as the last child of the JSX element referenced by `node`. Self-closing elements are expanded.
+Appends the element as the last child of `node`. Self-closing elements are expanded.
#### `{type: 'before', node}`
-Inserts the element before the JSX element referenced by `node`. If the node has no JSX parent, for example because it is returned directly, both are grouped in a fragment.
+Inserts the element before `node`. If the node has no parent element, for example because it is returned directly, both are grouped in a fragment.
#### `{type: 'after', node}`
-Inserts the element after the JSX element referenced by `node`, following the same rules as `before`.
+Inserts the element after `node`, following the same rules as `before`.
-Obtain a `node` from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous result. See [node references](/docs/codemods#node-references).
+Obtain a `node` from [`getNodes()`](/docs/codemods/get-nodes) or a previous result. See [node references](/docs/codemods#node-references).
### prettierConfigOverride?
@@ -122,7 +122,7 @@ An array of `{filePath, oldNodePath, newNodePath}` mappings. A `null` old path i
### insertedNode
-The reference of the outermost inserted element. Use [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) and its `parentNodePath` to find inserted children.
+The reference of the outermost inserted element. Use [`getNodes()`](/docs/codemods/get-nodes) and its `parentNodePath` to find inserted children.
## Errors
@@ -136,5 +136,5 @@ Throws when the target cannot be resolved, the composition component cannot rece
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/add-element.ts)
- [`createElement()`](/docs/codemods/create-element)
-- [`deleteJsxNodes()`](/docs/codemods/delete-jsx-nodes)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`deleteNodes()`](/docs/codemods/delete-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/add-folder.mdx b/packages/docs/docs/codemods/add-folder.mdx
index 41e781a303..9d7ea9e768 100644
--- a/packages/docs/docs/codemods/add-folder.mdx
+++ b/packages/docs/docs/codemods/add-folder.mdx
@@ -72,4 +72,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/add-folder.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/apply-codemod-changes.mdx b/packages/docs/docs/codemods/apply-codemod-changes.mdx
index 1426b540eb..675c36034e 100644
--- a/packages/docs/docs/codemods/apply-codemod-changes.mdx
+++ b/packages/docs/docs/codemods/apply-codemod-changes.mdx
@@ -9,12 +9,12 @@ crumb: '@remotion/codemods'
Applies the file changes returned by a codemod to an in-memory project. The input project remains unchanged.
```ts twoslash title="apply-changes.ts"
-import {applyCodemodChanges, updateJsxNodeProps, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+import {applyCodemodChanges, updateNodeProps, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
-const result = updateJsxNodeProps({
+const result = updateNodeProps({
project,
node,
props: {'style.opacity': 0.5},
diff --git a/packages/docs/docs/codemods/create-element.mdx b/packages/docs/docs/codemods/create-element.mdx
index aef91087d7..4db51ea581 100644
--- a/packages/docs/docs/codemods/create-element.mdx
+++ b/packages/docs/docs/codemods/create-element.mdx
@@ -6,7 +6,7 @@ crumb: '@remotion/codemods'
# createElement()<AvailableFrom v="4.0.530" />
-Describes a JSX element to insert into source code. Pass the result to [`addElement()`](/docs/codemods/add-element) to add it to a composition or next to an existing node, or to [`wrapJsxNode()`](/docs/codemods/wrap-jsx-node) to wrap an existing node.
+Describes an element to insert into source code. Pass the result to [`addElement()`](/docs/codemods/add-element) to add it to a composition or next to an existing node, or to [`wrapNode()`](/docs/codemods/wrap-node) to wrap an existing node.
:::warning
@@ -46,7 +46,7 @@ Pass an object with the following properties.
### component
-The JSX tag name. Use a component name such as `Solid`, a member expression such as `Interactive.Div`, or an HTML tag such as `div`.
+The tag name. Use a component name such as `Solid`, a member expression such as `Interactive.Div`, or an HTML tag such as `div`.
### importPath?
@@ -58,7 +58,7 @@ The named export to import when it differs from `component`. For example, `{comp
### props?
-A record of prop values. Strings become string attributes, other values become JSX expressions. Values must be strings, finite numbers, booleans, `null`, arrays, or plain objects. Use [`staticFileValue()`](/docs/codemods/static-file-value) to reference a file in the public folder. Defaults to `{}`.
+A record of prop values. Strings become string attributes, other values become expressions. Values must be strings, finite numbers, booleans, `null`, arrays, or plain objects. Use [`staticFileValue()`](/docs/codemods/static-file-value) to reference a file in the public folder. Defaults to `{}`.
### children?
@@ -104,5 +104,5 @@ Throws when the tag name, a prop name, or a prop value is invalid, or when `impo
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/codemod-element.ts)
- [`addElement()`](/docs/codemods/add-element)
-- [`wrapJsxNode()`](/docs/codemods/wrap-jsx-node)
+- [`wrapNode()`](/docs/codemods/wrap-node)
- [`staticFileValue()`](/docs/codemods/static-file-value)
diff --git a/packages/docs/docs/codemods/delete-composition.mdx b/packages/docs/docs/codemods/delete-composition.mdx
index 0d1f79049c..f898f93d7a 100644
--- a/packages/docs/docs/codemods/delete-composition.mdx
+++ b/packages/docs/docs/codemods/delete-composition.mdx
@@ -64,4 +64,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/delete-composition.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/delete-effects.mdx b/packages/docs/docs/codemods/delete-effects.mdx
index 56b66fe420..d612d03bea 100644
--- a/packages/docs/docs/codemods/delete-effects.mdx
+++ b/packages/docs/docs/codemods/delete-effects.mdx
@@ -6,7 +6,7 @@ crumb: '@remotion/codemods'
# deleteEffects()<AvailableFrom v="4.0.528" />
-Deletes selected effects from one or more JSX nodes.
+Deletes selected effects from one or more nodes.
:::warning
@@ -28,7 +28,7 @@ const result = await deleteEffects({
console.log(result);
```
-Indices of later effects shift after deletion. Read effects again with [`getJsxNodeProps()`](/docs/codemods/get-jsx-node-props) before using old effect indices. Imports are preserved.
+Indices of later effects shift after deletion. Read effects again with [`getNodeProps()`](/docs/codemods/get-node-props) before using old effect indices. Imports are preserved.
The `effects` attribute must contain an inline array. An attribute followed by a JSX spread is rejected because the spread may override it.
@@ -45,10 +45,10 @@ A non-empty array of effect references to remove. References may span files and
Set `effectIndex: null` to remove the entire `effects` attribute from a node, including spread entries in its inline array. The node must have at least one effect. Selecting every effect individually also removes the attribute when its array becomes empty.
```ts twoslash title="delete-all-effects.ts"
-import {deleteEffects, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+import {deleteEffects, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
// ---cut---
const result = await deleteEffects({
project,
@@ -100,4 +100,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/delete-effects.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/delete-jsx-nodes.mdx b/packages/docs/docs/codemods/delete-nodes.mdx
similarity index 57%
rename from packages/docs/docs/codemods/delete-jsx-nodes.mdx
rename to packages/docs/docs/codemods/delete-nodes.mdx
index 9116f35f2d..39845fbcfe 100644
--- a/packages/docs/docs/codemods/delete-jsx-nodes.mdx
+++ b/packages/docs/docs/codemods/delete-nodes.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-delete-jsx-nodes.png
-title: 'deleteJsxNodes()'
+image: /generated/articles-docs-codemods-delete-nodes.png
+title: 'deleteNodes()'
crumb: '@remotion/codemods'
---
-# deleteJsxNodes()<AvailableFrom v="4.0.527" />
+# deleteNodes()<AvailableFrom v="4.0.530" />
-Deletes one or more JSX elements identified by source node references. It works with any JSX layer, including [`<Sequence>`](/docs/sequence) and [`<Solid>`](/docs/solid).
+Deletes one or more nodes identified by their references. It works with any element, including [`<Sequence>`](/docs/sequence) and [`<Solid>`](/docs/solid).
:::warning
@@ -14,14 +14,14 @@ _Draft API_: This API is not yet stable. We are in the experimental phase of thi
:::
-```ts twoslash title="delete-jsx-nodes.ts"
-import {deleteJsxNodes, type CodemodProject} from '@remotion/codemods';
+```ts twoslash title="delete-nodes.ts"
+import {deleteNodes, type CodemodProject} from '@remotion/codemods';
import type {SequenceNodePath} from 'remotion';
declare const project: CodemodProject;
declare const nodePath: SequenceNodePath;
-const result = await deleteJsxNodes({
+const result = await deleteNodes({
project,
nodes: [{filePath: 'src/Video.tsx', nodePath}],
});
@@ -41,15 +41,15 @@ An in-memory Remotion project containing `rootDir` and a `files` record.
### nodes
-The JSX elements to delete. Nodes may belong to different project files.
+The nodes to delete. Nodes may belong to different project files.
#### filePath
-The source file containing the JSX element. Absolute paths emitted by a mounted layer and project-relative paths are both accepted.
+The source file containing the node. Absolute paths emitted by a mounted layer and project-relative paths are both accepted.
#### nodePath
-The `SequenceNodePath` identifying the JSX element to delete. Obtain it from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes), an insertion result, or a mounted layer. Canvas layers expose it as `nodePathInfo.sequenceSubscriptionKey.nodePath`.
+The `SequenceNodePath` identifying the node to delete. Obtain it from [`getNodes()`](/docs/codemods/get-nodes), an insertion result, or a mounted layer. Canvas layers expose it as `nodePathInfo.sequenceSubscriptionKey.nodePath`.
## Return value
@@ -59,7 +59,7 @@ A promise resolving to an object with the following properties.
An array describing each changed file with its `filePath`, `previousContents`, and `nextContents`.
-### nodePathRemappings<AvailableFrom v="4.0.528" />
+### nodePathRemappings
File-qualified `{filePath, oldNodePath, newNodePath}` mappings for keeping node references after the edit. A `null` old path indicates an insertion; a `null` new path indicates removal. See [node references](/docs/codemods#node-references).
@@ -69,6 +69,6 @@ File-qualified `{filePath, oldNodePath, newNodePath}` mappings for keeping node
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/delete-jsx-nodes.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/delete-nodes.ts)
- [`addElement()`](/docs/codemods/add-element)
- [`<Sequence>`](/docs/sequence)
diff --git a/packages/docs/docs/codemods/detach-audio.mdx b/packages/docs/docs/codemods/detach-audio.mdx
index 4bfaecc155..d7b7865969 100644
--- a/packages/docs/docs/codemods/detach-audio.mdx
+++ b/packages/docs/docs/codemods/detach-audio.mdx
@@ -15,10 +15,10 @@ _Draft API_: This API is experimental and may change.
:::
```ts twoslash title="detach-audio.ts"
-import {detachAudio, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+import {detachAudio, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
const result = await detachAudio({
project,
@@ -28,7 +28,7 @@ const result = await detachAudio({
console.log(result);
```
-Supports recognized Remotion video imports. The audio element uses the same source and copies supported playback and timing props. This edits JSX; it does not extract or write an audio file.
+Supports recognized Remotion video imports. The audio element uses the same source and copies supported playback and timing props. This edits source code; it does not extract or write an audio file.
## Options
@@ -38,7 +38,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-A [`JsxNodeReference`](/docs/codemods#node-references) from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous operation. It contains `filePath` and `nodePath`.
+A [`NodeReference`](/docs/codemods#node-references) from [`getNodes()`](/docs/codemods/get-nodes) or a previous operation. It contains `filePath` and `nodePath`.
## Return value
@@ -72,4 +72,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/detach-audio.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/duplicate-composition.mdx b/packages/docs/docs/codemods/duplicate-composition.mdx
index 45a0baaf5c..be56257fba 100644
--- a/packages/docs/docs/codemods/duplicate-composition.mdx
+++ b/packages/docs/docs/codemods/duplicate-composition.mdx
@@ -80,4 +80,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/duplicate-composition.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/duplicate-effects.mdx b/packages/docs/docs/codemods/duplicate-effects.mdx
index 4cd6392918..93a513ab51 100644
--- a/packages/docs/docs/codemods/duplicate-effects.mdx
+++ b/packages/docs/docs/codemods/duplicate-effects.mdx
@@ -68,4 +68,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/duplicate-effects.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/duplicate-jsx-nodes.mdx b/packages/docs/docs/codemods/duplicate-nodes.mdx
similarity index 69%
rename from packages/docs/docs/codemods/duplicate-jsx-nodes.mdx
rename to packages/docs/docs/codemods/duplicate-nodes.mdx
index 6be9600039..a6567c34fa 100644
--- a/packages/docs/docs/codemods/duplicate-jsx-nodes.mdx
+++ b/packages/docs/docs/codemods/duplicate-nodes.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-duplicate-jsx-nodes.png
-title: 'duplicateJsxNodes()'
+image: /generated/articles-docs-codemods-duplicate-nodes.png
+title: 'duplicateNodes()'
crumb: '@remotion/codemods'
---
-# duplicateJsxNodes()<AvailableFrom v="4.0.528" />
+# duplicateNodes()<AvailableFrom v="4.0.530" />
-Duplicates one or more JSX elements beside their originals.
+Duplicates one or more nodes beside their originals.
:::warning
@@ -14,13 +14,13 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="duplicate-jsx-nodes.ts"
-import {duplicateJsxNodes, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+```ts twoslash title="duplicate-nodes.ts"
+import {duplicateNodes, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
-const result = await duplicateJsxNodes({
+const result = await duplicateNodes({
project,
nodes: [node],
});
@@ -28,7 +28,7 @@ const result = await duplicateJsxNodes({
console.log(result);
```
-Copies JSX source, including props and children. Imported component implementations remain shared. Overlapping ancestor/descendant selections are unsupported.
+Copies the node's source, including props and children. Imported component implementations remain shared. Overlapping ancestor/descendant selections are unsupported.
## Options
@@ -66,6 +66,6 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/duplicate-jsx-nodes.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/duplicate-nodes.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/get-jsx-node-props.mdx b/packages/docs/docs/codemods/get-node-props.mdx
similarity index 79%
rename from packages/docs/docs/codemods/get-jsx-node-props.mdx
rename to packages/docs/docs/codemods/get-node-props.mdx
index 5cf97b5d51..3a02d11f49 100644
--- a/packages/docs/docs/codemods/get-jsx-node-props.mdx
+++ b/packages/docs/docs/codemods/get-node-props.mdx
@@ -1,10 +1,10 @@
---
-image: /generated/articles-docs-codemods-get-jsx-node-props.png
-title: 'getJsxNodeProps()'
+image: /generated/articles-docs-codemods-get-node-props.png
+title: 'getNodeProps()'
crumb: '@remotion/codemods'
---
-# getJsxNodeProps()<AvailableFrom v="4.0.528" />
+# getNodeProps()<AvailableFrom v="4.0.530" />
Inspects props and inline effects without executing the project.
@@ -14,13 +14,13 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="get-jsx-node-props.ts"
-import {getJsxNodeProps, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+```ts twoslash title="get-node-props.ts"
+import {getNodeProps, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
-const result = getJsxNodeProps({
+const result = getNodeProps({
project,
node,
keys: ['children', 'style.opacity'],
@@ -39,11 +39,11 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-A [`JsxNodeReference`](/docs/codemods#node-references) from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous operation. It contains `filePath` and `nodePath`.
+A [`NodeReference`](/docs/codemods#node-references) from [`getNodes()`](/docs/codemods/get-nodes) or a previous operation. It contains `filePath` and `nodePath`.
### keys
-The JSX props to inspect. Use `children` for static text or a one-level path such as `style.opacity`.
+The props to inspect. Use `children` for static text or a one-level path such as `style.opacity`.
### effectKeys?
@@ -87,6 +87,6 @@ Throws when the target cannot be resolved, its component identity does not match
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/get-jsx-node-props.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/get-node-props.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/get-jsx-nodes.mdx b/packages/docs/docs/codemods/get-nodes.mdx
similarity index 57%
rename from packages/docs/docs/codemods/get-jsx-nodes.mdx
rename to packages/docs/docs/codemods/get-nodes.mdx
index f5c9908c5a..fbd16755a2 100644
--- a/packages/docs/docs/codemods/get-jsx-nodes.mdx
+++ b/packages/docs/docs/codemods/get-nodes.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-get-jsx-nodes.png
-title: 'getJsxNodes()'
+image: /generated/articles-docs-codemods-get-nodes.png
+title: 'getNodes()'
crumb: '@remotion/codemods'
---
-# getJsxNodes()<AvailableFrom v="4.0.528" />
+# getNodes()<AvailableFrom v="4.0.530" />
-Lists the JSX elements in a project file in source order.
+Lists the nodes of a project file in source order. A node is an element in the source code, identified by its file and node path.
:::warning
@@ -14,12 +14,12 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="get-jsx-nodes.ts"
-import {getJsxNodes, type CodemodProject} from '@remotion/codemods';
+```ts twoslash title="get-nodes.ts"
+import {getNodes, type CodemodProject} from '@remotion/codemods';
declare const project: CodemodProject;
-const result = getJsxNodes({
+const result = getNodes({
project,
filePath: 'src/Video.tsx',
});
@@ -41,7 +41,7 @@ The project-relative or absolute source file path.
## Return value
-Returns an array. Each entry has the following properties.
+Returns an array of `CodemodNode` objects. Each entry has the following properties.
### filePath
@@ -49,11 +49,11 @@ The matching key in `project.files`.
### nodePath
-An opaque path identifying this JSX element in the current source snapshot.
+An opaque path identifying this node in the current source snapshot.
### tagName
-The JSX tag name, such as `Sequence`, `div`, or `Interactive.Div`.
+The tag name, such as `Sequence`, `div`, or `Interactive.Div`.
### componentIdentity
@@ -63,9 +63,9 @@ The recognized component identity, or `null` when it cannot be determined. Impor
The opening tag's `{line, column}` location, or `null`. Lines are one-based; columns are zero-based.
-### parentNodePath<AvailableFrom v="4.0.530" />
+### parentNodePath
-The `nodePath` of the closest enclosing JSX element in the same file, or `null` for top-level elements. Elements rendered through expressions, such as `{condition && <div />}` or a `.map()` callback, report the enclosing element. Compare it with the `nodePath` of other entries to build a tree or to find the children of a node.
+The `nodePath` of the closest enclosing node in the same file, or `null` for top-level elements. Elements rendered through expressions, such as `{condition && <div />}` or a `.map()` callback, report the enclosing element. Compare it with the `nodePath` of other entries to build a tree or to find the children of a node.
## Errors
@@ -77,6 +77,6 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/get-jsx-nodes.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/get-nodes.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/index.mdx b/packages/docs/docs/codemods/index.mdx
index 03575c8779..bba52c63db 100644
--- a/packages/docs/docs/codemods/index.mdx
+++ b/packages/docs/docs/codemods/index.mdx
@@ -7,7 +7,7 @@ crumb: '@remotion/codemods'
# @remotion/codemods<AvailableFrom v="4.0.527" />
-Edit Remotion source in memory. Discover JSX nodes, insert content, edit props and animations, and manage composition registrations.
+Edit Remotion source in memory. Discover nodes, insert elements, edit props and animations, and manage composition registrations.
:::warning
@@ -49,11 +49,11 @@ export const Root = () => <Composition id="Demo" component={Video} width={1920}
};
```
-Include the files needed for the edit. A JSX prop edit needs its target file; resolving an imported composition component also needs the files along the import path. Mutations leave the input project unchanged.
+Include the files needed for the edit. A prop edit needs its target file; resolving an imported composition component also needs the files along the import path. Mutations leave the input project unchanged.
## Creating elements<AvailableFrom v="4.0.530" />
-Describe JSX with [`createElement()`](/docs/codemods/create-element) and insert it with [`addElement()`](/docs/codemods/add-element). Elements are immutable descriptions: methods such as `withProp()` and `withChild()` return new elements. Imports and local names are resolved when the element is inserted.
+Describe elements with [`createElement()`](/docs/codemods/create-element) and insert it with [`addElement()`](/docs/codemods/add-element). Elements are immutable descriptions: methods such as `withProp()` and `withChild()` return new elements. Imports and local names are resolved when the element is inserted.
```ts twoslash title="insert.ts"
import {addElement, applyCodemodChanges, createElement, type CodemodProject} from '@remotion/codemods';
@@ -80,23 +80,23 @@ const nextProject = applyCodemodChanges(project, result.changes);
console.log(nextProject.files, result.insertedNode);
```
-Elements can also be inserted `inside`, `before`, or `after` an existing node, and [`wrapJsxNode()`](/docs/codemods/wrap-jsx-node) wraps an existing node in an element.
+Elements can also be inserted `inside`, `before`, or `after` an existing node, and [`wrapNode()`](/docs/codemods/wrap-node) wraps an existing node in an element.
## Editing a node<AvailableFrom v="4.0.528" />
Find a node, inspect the properties you want to edit, and pass its reference to a mutation.
```ts twoslash title="edit.ts"
-import {applyCodemodChanges, getJsxNodes, getJsxNodeProps, updateJsxNodeProps, type CodemodProject} from '@remotion/codemods';
+import {applyCodemodChanges, getNodes, getNodeProps, updateNodeProps, type CodemodProject} from '@remotion/codemods';
declare const project: CodemodProject;
-const node = getJsxNodes({project, filePath: 'src/Video.tsx'}).find((candidate) => candidate.tagName === 'div');
+const node = getNodes({project, filePath: 'src/Video.tsx'}).find((candidate) => candidate.tagName === 'div');
if (node) {
- const {props} = getJsxNodeProps({project, node, keys: ['style.opacity']});
+ const {props} = getNodeProps({project, node, keys: ['style.opacity']});
if (props['style.opacity'].status === 'static') {
- const result = updateJsxNodeProps({
+ const result = updateNodeProps({
project,
node,
props: {'style.opacity': 0.5},
@@ -109,27 +109,27 @@ if (node) {
## Node references<AvailableFrom v="4.0.528" />
-A `JsxNodeReference` contains the following properties.
+A `NodeReference` contains the following properties.
### filePath
-The file containing the JSX element.
+The file containing the node.
### nodePath
-The `SequenceNodePath` identifying the element in the current source snapshot. Obtain it from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes), an insertion result, or a mounted layer's `nodePathInfo.sequenceSubscriptionKey.nodePath`. Treat its contents as opaque. To traverse the tree, compare it with the `parentNodePath` that [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) returns for each node.
+The `SequenceNodePath` identifying the element in the current source snapshot. Obtain it from [`getNodes()`](/docs/codemods/get-nodes), an insertion result, or a mounted layer's `nodePathInfo.sequenceSubscriptionKey.nodePath`. Treat its contents as opaque. To traverse the tree, compare it with the `parentNodePath` that [`getNodes()`](/docs/codemods/get-nodes) returns for each node.
A reference identifies source, not a particular rendered instance. Editing a component used by several compositions changes that shared component. Editing a node inside a loop changes the source used by every iteration.
### Keeping references after edits
-JSX mutations return `nodePathRemappings`. Each entry contains `filePath`, `oldNodePath`, and `newNodePath`. Apply a mapping once to references from the input project, matching both the file and old path. A `null` old path means insertion; a `null` new path means removal. An omitted reference keeps its path.
+Node mutations return `nodePathRemappings`. Each entry contains `filePath`, `oldNodePath`, and `newNodePath`. Apply a mapping once to references from the input project, matching both the file and old path. A `null` old path means insertion; a `null` new path means removal. An omitted reference keeps its path.
Use `insertedNode`, `insertedNodes`, or `updatedNode` when returned instead of trying to reconstruct a path. Adding hooks, duplicating elements, or changing wrappers can move other nodes as well. After manual source changes or composition-tree edits, discover nodes again.
## Effect references<AvailableFrom v="4.0.528" />
-An `EffectReference` extends a node reference with `effectIndex`, the zero-based position in its inline `effects` array. [`getJsxNodeProps()`](/docs/codemods/get-jsx-node-props) inspects effects, and effect mutations return `insertedEffect`, `insertedEffects`, or `updatedEffect` where applicable.
+An `EffectReference` extends a node reference with `effectIndex`, the zero-based position in its inline `effects` array. [`getNodeProps()`](/docs/codemods/get-node-props) inspects effects, and effect mutations return `insertedEffect`, `insertedEffects`, or `updatedEffect` where applicable.
Adding, deleting, duplicating, or reordering effects can shift effect indices. Node-path remappings do not remap effect indices. Inspect the updated effects before reusing other effect references.
@@ -155,7 +155,7 @@ The next source, or `null` if the file was deleted.
### nodePathRemappings<AvailableFrom v="4.0.528" />
-JSX, effect, and keyframe mutations return these mappings in addition to the shared result. See [node references](#node-references).
+Node, effect, and keyframe mutations return these mappings in addition to the shared result. See [node references](#node-references).
## Applying changes
@@ -165,11 +165,11 @@ For undo and redo, store the file changes as one transaction. Swap `previousCont
## Supported edits
-Code must be valid JavaScript or TypeScript with supported JSX structures. Prop inspection distinguishes static values, recognized keyframes, and computed expressions. The package does not evaluate arbitrary JavaScript. The `props` form of prop updates rejects computed values; [structured `updates`](/docs/codemods/update-jsx-node-props#updates) permit explicit replacement. Setting a recognized keyframed prop to a static value replaces its animation.
+Code must be valid JavaScript or TypeScript with supported JSX structures. Prop inspection distinguishes static values, recognized keyframes, and computed expressions. The package does not evaluate arbitrary JavaScript. The `props` form of prop updates rejects computed values; [structured `updates`](/docs/codemods/update-node-props#updates) permit explicit replacement. Setting a recognized keyframed prop to a static value replaces its animation.
Registration edits use explicit composition files and static IDs. They support `Composition`, `Still`, and `Folder` from `remotion`, including aliased and namespace imports. Component insertion and resolution support additional import patterns, as documented on their pages.
-`CodemodValue` represents serializable strings, numbers, booleans, `null`, arrays, and objects. Strings are values, not executable expressions; use [`staticFileValue()`](/docs/codemods/static-file-value) to reference a file in the public folder. [`updateJsxNodeProps()`](/docs/codemods/update-jsx-node-props) also accepts `undefined` to remove a property.
+`CodemodValue` represents serializable strings, numbers, booleans, `null`, arrays, and objects. Strings are values, not executable expressions; use [`staticFileValue()`](/docs/codemods/static-file-value) to reference a file in the public folder. [`updateNodeProps()`](/docs/codemods/update-node-props) also accepts `undefined` to remove a property.
Unsupported edits throw or reject without mutating the input project. Batch operations resolve their references against the same input snapshot. Unrelated source formatting and comments are preserved; edited regions use the surrounding source style.
diff --git a/packages/docs/docs/codemods/move-composition.mdx b/packages/docs/docs/codemods/move-composition.mdx
index 8708f81f4d..2f863031c6 100644
--- a/packages/docs/docs/codemods/move-composition.mdx
+++ b/packages/docs/docs/codemods/move-composition.mdx
@@ -29,7 +29,7 @@ const result = moveComposition({
console.log(result);
```
-The composition and destination must be in the same registration file. Their source must allow a direct JSX-child move. The component implementation and composition ID stay unchanged.
+The composition and destination must be in the same registration file. Their source must allow a direct child move. The component implementation and composition ID stay unchanged.
## Options
@@ -69,4 +69,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/move-composition.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/move-folder.mdx b/packages/docs/docs/codemods/move-folder.mdx
index 6b6c9d367c..14ac0d5488 100644
--- a/packages/docs/docs/codemods/move-folder.mdx
+++ b/packages/docs/docs/codemods/move-folder.mdx
@@ -77,4 +77,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/move-folder.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/rename-composition.mdx b/packages/docs/docs/codemods/rename-composition.mdx
index 859a4b5e9e..dddee2556d 100644
--- a/packages/docs/docs/codemods/rename-composition.mdx
+++ b/packages/docs/docs/codemods/rename-composition.mdx
@@ -69,4 +69,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/rename-composition.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/rename-folder.mdx b/packages/docs/docs/codemods/rename-folder.mdx
index ac4c13c2fa..3f400d682e 100644
--- a/packages/docs/docs/codemods/rename-folder.mdx
+++ b/packages/docs/docs/codemods/rename-folder.mdx
@@ -77,4 +77,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/rename-folder.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/reorder-effect.mdx b/packages/docs/docs/codemods/reorder-effect.mdx
index 0436f9b48b..9d90c8de2c 100644
--- a/packages/docs/docs/codemods/reorder-effect.mdx
+++ b/packages/docs/docs/codemods/reorder-effect.mdx
@@ -73,4 +73,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/reorder-effect.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/reorder-jsx-node.mdx b/packages/docs/docs/codemods/reorder-node.mdx
similarity index 62%
rename from packages/docs/docs/codemods/reorder-jsx-node.mdx
rename to packages/docs/docs/codemods/reorder-node.mdx
index 0824d9d528..052f040c54 100644
--- a/packages/docs/docs/codemods/reorder-jsx-node.mdx
+++ b/packages/docs/docs/codemods/reorder-node.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-reorder-jsx-node.png
-title: 'reorderJsxNode()'
+image: /generated/articles-docs-codemods-reorder-node.png
+title: 'reorderNode()'
crumb: '@remotion/codemods'
---
-# reorderJsxNode()<AvailableFrom v="4.0.528" />
+# reorderNode()<AvailableFrom v="4.0.530" />
-Moves a JSX element before or after a sibling.
+Moves a node before or after a sibling.
:::warning
@@ -14,14 +14,14 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="reorder-jsx-node.ts"
-import {reorderJsxNode, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+```ts twoslash title="reorder-node.ts"
+import {reorderNode, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
-declare const target: JsxNodeReference;
+declare const node: NodeReference;
+declare const target: NodeReference;
-const result = await reorderJsxNode({
+const result = await reorderNode({
project,
node,
target,
@@ -31,7 +31,7 @@ const result = await reorderJsxNode({
console.log(result);
```
-Both nodes must be direct JSX siblings in the same file. This changes source order and stacking order, not timeline timing. Moving into a different parent or file is unsupported.
+Both nodes must be direct siblings in the same file. This changes source order and stacking order, not timeline timing. Moving into a different parent or file is unsupported.
## Options
@@ -41,7 +41,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-A [`JsxNodeReference`](/docs/codemods#node-references) from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous operation. It contains `filePath` and `nodePath`.
+A [`NodeReference`](/docs/codemods#node-references) from [`getNodes()`](/docs/codemods/get-nodes) or a previous operation. It contains `filePath` and `nodePath`.
### target
@@ -77,6 +77,6 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/reorder-jsx-node.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/reorder-node.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/resolve-composition-component.mdx b/packages/docs/docs/codemods/resolve-composition-component.mdx
index 922a29bf6d..2a9b97f40f 100644
--- a/packages/docs/docs/codemods/resolve-composition-component.mdx
+++ b/packages/docs/docs/codemods/resolve-composition-component.mdx
@@ -62,7 +62,7 @@ The declaration's `{line, column}` location. Lines are one-based; columns are ze
### canAddContent
-Whether the component's returned JSX structure supports content insertion. Pass `filePath` and `exportName` as a `{type: 'component'}` target to [`addElement()`](/docs/codemods/add-element) to insert into the resolved component.
+Whether the component's return value supports content insertion. Pass `filePath` and `exportName` as a `{type: 'component'}` target to [`addElement()`](/docs/codemods/add-element) to insert into the resolved component.
## Errors
@@ -77,4 +77,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/resolve-composition-component.ts)
- [`@remotion/codemods`](/docs/codemods)
- [`addElement()`](/docs/codemods/add-element)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/set-composition-default-props.mdx b/packages/docs/docs/codemods/set-composition-default-props.mdx
index 096960e4bb..6dddbc3d6f 100644
--- a/packages/docs/docs/codemods/set-composition-default-props.mdx
+++ b/packages/docs/docs/codemods/set-composition-default-props.mdx
@@ -85,4 +85,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/set-composition-default-props.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/split-sequences.mdx b/packages/docs/docs/codemods/split-sequences.mdx
index 9f5bbc0b16..36023df209 100644
--- a/packages/docs/docs/codemods/split-sequences.mdx
+++ b/packages/docs/docs/codemods/split-sequences.mdx
@@ -6,7 +6,7 @@ crumb: '@remotion/codemods'
# splitSequences()<AvailableFrom v="4.0.528" />
-Splits supported timing elements into two adjacent JSX elements.
+Splits supported timing elements into two adjacent nodes.
:::warning
@@ -15,10 +15,10 @@ _Draft API_: This API is experimental and may change.
:::
```ts twoslash title="split-sequences.ts"
-import {splitSequences, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+import {splitSequences, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
const result = await splitSequences({
project,
@@ -76,4 +76,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/split-sequences.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/static-file-value.mdx b/packages/docs/docs/codemods/static-file-value.mdx
index 2cca396972..d8474e71fb 100644
--- a/packages/docs/docs/codemods/static-file-value.mdx
+++ b/packages/docs/docs/codemods/static-file-value.mdx
@@ -26,7 +26,7 @@ const image = createElement({
Inserting `image` produces `<Img src={staticFile('photo.png')} />`.
-The value is also accepted by [`updateJsxNodeProps()`](/docs/codemods/update-jsx-node-props) and [`setCompositionDefaultProps()`](/docs/codemods/set-composition-default-props), and it can be nested inside arrays and objects.
+The value is also accepted by [`updateNodeProps()`](/docs/codemods/update-node-props) and [`setCompositionDefaultProps()`](/docs/codemods/set-composition-default-props), and it can be nested inside arrays and objects.
## Arguments
diff --git a/packages/docs/docs/codemods/table-of-contents.tsx b/packages/docs/docs/codemods/table-of-contents.tsx
index 7df474cd23..cd39664ea2 100644
--- a/packages/docs/docs/codemods/table-of-contents.tsx
+++ b/packages/docs/docs/codemods/table-of-contents.tsx
@@ -43,7 +43,7 @@ export const TableOfContents: React.FC = () => {
<TOCItem link="/docs/codemods/create-element">
<strong>createElement()</strong>
<div>
- Describes a JSX element with props and children to insert into source
+ Describes an element with props and children to insert into source
code.
</div>
</TOCItem>
@@ -53,11 +53,11 @@ export const TableOfContents: React.FC = () => {
</TOCItem>
<TOCItem link="/docs/codemods/delete-effects">
<strong>deleteEffects()</strong>
- <div>Deletes selected effects from one or more JSX nodes.</div>
+ <div>Deletes selected effects from one or more nodes.</div>
</TOCItem>
- <TOCItem link="/docs/codemods/delete-jsx-nodes">
- <strong>deleteJsxNodes()</strong>
- <div>Delete JSX nodes across project files.</div>
+ <TOCItem link="/docs/codemods/delete-nodes">
+ <strong>deleteNodes()</strong>
+ <div>Deletes nodes across project files.</div>
</TOCItem>
<TOCItem link="/docs/codemods/detach-audio">
<strong>detachAudio()</strong>
@@ -74,19 +74,19 @@ export const TableOfContents: React.FC = () => {
<strong>duplicateEffects()</strong>
<div>Copies selected effects immediately after their originals.</div>
</TOCItem>
- <TOCItem link="/docs/codemods/duplicate-jsx-nodes">
- <strong>duplicateJsxNodes()</strong>
- <div>Duplicates one or more JSX elements beside their originals.</div>
+ <TOCItem link="/docs/codemods/duplicate-nodes">
+ <strong>duplicateNodes()</strong>
+ <div>Duplicates one or more nodes beside their originals.</div>
</TOCItem>
- <TOCItem link="/docs/codemods/get-jsx-node-props">
- <strong>getJsxNodeProps()</strong>
+ <TOCItem link="/docs/codemods/get-node-props">
+ <strong>getNodeProps()</strong>
<div>
Inspects props and inline effects without executing the project.
</div>
</TOCItem>
- <TOCItem link="/docs/codemods/get-jsx-nodes">
- <strong>getJsxNodes()</strong>
- <div>Lists the JSX elements in a project file in source order.</div>
+ <TOCItem link="/docs/codemods/get-nodes">
+ <strong>getNodes()</strong>
+ <div>Lists the nodes in a project file in source order.</div>
</TOCItem>
<TOCItem link="/docs/codemods/move-composition">
<strong>moveComposition()</strong>
@@ -111,9 +111,9 @@ export const TableOfContents: React.FC = () => {
<strong>reorderEffect()</strong>
<div>Moves an effect to another index in the same effects array.</div>
</TOCItem>
- <TOCItem link="/docs/codemods/reorder-jsx-node">
- <strong>reorderJsxNode()</strong>
- <div>Moves a JSX element before or after a sibling.</div>
+ <TOCItem link="/docs/codemods/reorder-node">
+ <strong>reorderNode()</strong>
+ <div>Moves a node before or after a sibling.</div>
</TOCItem>
<TOCItem link="/docs/codemods/resolve-composition-component">
<strong>resolveCompositionComponent()</strong>
@@ -131,9 +131,7 @@ export const TableOfContents: React.FC = () => {
</TOCItem>
<TOCItem link="/docs/codemods/split-sequences">
<strong>splitSequences()</strong>
- <div>
- Splits supported timing elements into two adjacent JSX elements.
- </div>
+ <div>Splits supported timing elements into two adjacent nodes.</div>
</TOCItem>
<TOCItem link="/docs/codemods/static-file-value">
<strong>staticFileValue()</strong>
@@ -164,30 +162,30 @@ export const TableOfContents: React.FC = () => {
Updates explicit properties in an inline effect configuration.
</div>
</TOCItem>
- <TOCItem link="/docs/codemods/update-jsx-node-keyframes">
- <strong>updateJsxNodeKeyframes()</strong>
- <div>Adds, removes, moves, or configures keyframes on a JSX prop.</div>
+ <TOCItem link="/docs/codemods/update-multiple-node-props">
+ <strong>updateMultipleNodeProps()</strong>
+ <div>Updates props on multiple nodes in one operation.</div>
</TOCItem>
- <TOCItem link="/docs/codemods/update-jsx-node-props">
- <strong>updateJsxNodeProps()</strong>
+ <TOCItem link="/docs/codemods/update-node-keyframes">
+ <strong>updateNodeKeyframes()</strong>
+ <div>Adds, removes, moves, or configures keyframes on a node prop.</div>
+ </TOCItem>
+ <TOCItem link="/docs/codemods/update-node-props">
+ <strong>updateNodeProps()</strong>
<div>
- Updates JSX props, nested object properties, and supported text
+ Updates node props, nested object properties, and supported text
children.
</div>
</TOCItem>
- <TOCItem link="/docs/codemods/update-multiple-jsx-node-props">
- <strong>updateMultipleJsxNodeProps()</strong>
- <div>Updates props on multiple JSX nodes in one operation.</div>
- </TOCItem>
<TOCItem link="/docs/codemods/update-visual-controls">
<strong>updateVisualControls()</strong>
<div>
Updates visual control defaults while preserving surrounding source.
</div>
</TOCItem>
- <TOCItem link="/docs/codemods/wrap-jsx-node">
- <strong>wrapJsxNode()</strong>
- <div>Wraps an existing JSX element in a new element.</div>
+ <TOCItem link="/docs/codemods/wrap-node">
+ <strong>wrapNode()</strong>
+ <div>Wraps an existing node in a new element.</div>
</TOCItem>
</Grid>
);
diff --git a/packages/docs/docs/codemods/unwrap-folder.mdx b/packages/docs/docs/codemods/unwrap-folder.mdx
index 2402f91c8d..c9cb8a4492 100644
--- a/packages/docs/docs/codemods/unwrap-folder.mdx
+++ b/packages/docs/docs/codemods/unwrap-folder.mdx
@@ -88,4 +88,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/unwrap-folder.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/update-composition-metadata.mdx b/packages/docs/docs/codemods/update-composition-metadata.mdx
index dd93bf3c77..a577c05da6 100644
--- a/packages/docs/docs/codemods/update-composition-metadata.mdx
+++ b/packages/docs/docs/codemods/update-composition-metadata.mdx
@@ -87,4 +87,4 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-composition-metadata.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/update-effect-keyframes.mdx b/packages/docs/docs/codemods/update-effect-keyframes.mdx
index 97c749a534..4a16df985f 100644
--- a/packages/docs/docs/codemods/update-effect-keyframes.mdx
+++ b/packages/docs/docs/codemods/update-effect-keyframes.mdx
@@ -48,7 +48,7 @@ An [`EffectReference`](/docs/codemods#effect-references): `filePath`, `nodePath`
### updates
-An array of `{key, operation}` objects, applied in order. JSX prop keys may use paths such as `style.opacity`. Effect keys name configuration properties.
+An array of `{key, operation}` objects, applied in order. Node prop keys may use paths such as `style.opacity`. Effect keys name configuration properties.
#### operation
@@ -90,4 +90,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-effect-keyframes.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/update-effect-props.mdx b/packages/docs/docs/codemods/update-effect-props.mdx
index c9666543db..345f440430 100644
--- a/packages/docs/docs/codemods/update-effect-props.mdx
+++ b/packages/docs/docs/codemods/update-effect-props.mdx
@@ -129,4 +129,4 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-effect-props.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/update-multiple-jsx-node-props.mdx b/packages/docs/docs/codemods/update-multiple-node-props.mdx
similarity index 68%
rename from packages/docs/docs/codemods/update-multiple-jsx-node-props.mdx
rename to packages/docs/docs/codemods/update-multiple-node-props.mdx
index 49b604bd3e..e579d3e1b0 100644
--- a/packages/docs/docs/codemods/update-multiple-jsx-node-props.mdx
+++ b/packages/docs/docs/codemods/update-multiple-node-props.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-update-multiple-jsx-node-props.png
-title: 'updateMultipleJsxNodeProps()'
+image: /generated/articles-docs-codemods-update-multiple-node-props.png
+title: 'updateMultipleNodeProps()'
crumb: '@remotion/codemods'
---
-# updateMultipleJsxNodeProps()<AvailableFrom v="4.0.528" />
+# updateMultipleNodeProps()<AvailableFrom v="4.0.530" />
-Updates props on multiple JSX nodes across project files in one operation. Node references refer to the input project; the result includes their new paths.
+Updates props on multiple nodes across project files in one operation. Node references refer to the input project; the result includes their new paths.
:::warning
@@ -14,14 +14,14 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="update-multiple-jsx-node-props.ts"
-import {updateMultipleJsxNodeProps, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+```ts twoslash title="update-multiple-node-props.ts"
+import {updateMultipleNodeProps, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const title: JsxNodeReference;
-declare const background: JsxNodeReference;
+declare const title: NodeReference;
+declare const background: NodeReference;
-const result = updateMultipleJsxNodeProps({
+const result = updateMultipleNodeProps({
project,
changes: [
{node: title, props: {children: 'Hello'}},
@@ -44,7 +44,7 @@ A non-empty array of node edits.
#### node
-The [`JsxNodeReference`](/docs/codemods#node-references) to edit, containing `filePath` and `nodePath`.
+The [`NodeReference`](/docs/codemods#node-references) to edit, containing `filePath` and `nodePath`.
#### props?
@@ -52,7 +52,7 @@ A non-empty record of prop values, such as `{from: 30, 'style.opacity': 0.5}`. A
#### updates?
-A non-empty array of [structured prop updates](/docs/codemods/update-jsx-node-props#updates) for edits that need default values or other update metadata. This form permits explicitly replacing computed prop values. Supply this instead of `props`.
+A non-empty array of [structured prop updates](/docs/codemods/update-node-props#updates) for edits that need default values or other update metadata. This form permits explicitly replacing computed prop values. Supply this instead of `props`.
#### schema?
@@ -84,7 +84,7 @@ Updated node references in the same order as the requested edits.
### results
-Per-node edit details in the same order as the requested edits: `oldValueStrings`, `logLine`, `removedProps`, and `newNodePath`. See [`updateJsxNodeProps()`](/docs/codemods/update-jsx-node-props).
+Per-node edit details in the same order as the requested edits: `oldValueStrings`, `logLine`, `removedProps`, and `newNodePath`. See [`updateNodeProps()`](/docs/codemods/update-node-props).
### formatted
@@ -96,5 +96,5 @@ Per-node edit details in the same order as the requested edits: `oldValueStrings
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-jsx-node-props.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-node-props.ts)
- [`@remotion/codemods`](/docs/codemods)
diff --git a/packages/docs/docs/codemods/update-jsx-node-keyframes.mdx b/packages/docs/docs/codemods/update-node-keyframes.mdx
similarity index 72%
rename from packages/docs/docs/codemods/update-jsx-node-keyframes.mdx
rename to packages/docs/docs/codemods/update-node-keyframes.mdx
index ea39ee61f9..5e26a2283a 100644
--- a/packages/docs/docs/codemods/update-jsx-node-keyframes.mdx
+++ b/packages/docs/docs/codemods/update-node-keyframes.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-update-jsx-node-keyframes.png
-title: 'updateJsxNodeKeyframes()'
+image: /generated/articles-docs-codemods-update-node-keyframes.png
+title: 'updateNodeKeyframes()'
crumb: '@remotion/codemods'
---
-# updateJsxNodeKeyframes()<AvailableFrom v="4.0.528" />
+# updateNodeKeyframes()<AvailableFrom v="4.0.530" />
-Adds, removes, moves, or configures keyframes on a JSX prop.
+Adds, removes, moves, or configures keyframes on a node prop.
:::warning
@@ -14,13 +14,13 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="update-jsx-node-keyframes.ts"
-import {updateJsxNodeKeyframes, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+```ts twoslash title="update-node-keyframes.ts"
+import {updateNodeKeyframes, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
-const result = await updateJsxNodeKeyframes({
+const result = await updateNodeKeyframes({
project,
node,
updates: [
@@ -34,7 +34,7 @@ console.log(result);
Adds the required interpolation imports and frame hook. Supports recognized inline interpolation expressions; unsupported dynamic expressions throw. Frame coordinates belong to the interpolation expression's local frame clock.
-Creating an animation that needs a new [`useCurrentFrame()`](/docs/use-current-frame) hook requires an enclosing function. Existing supported interpolation expressions can be edited outside functions. Static prop edits outside functions remain supported by [`updateJsxNodeProps()`](/docs/codemods/update-jsx-node-props).
+Creating an animation that needs a new [`useCurrentFrame()`](/docs/use-current-frame) hook requires an enclosing function. Existing supported interpolation expressions can be edited outside functions. Static prop edits outside functions remain supported by [`updateNodeProps()`](/docs/codemods/update-node-props).
## Options
@@ -44,11 +44,11 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-A [`JsxNodeReference`](/docs/codemods#node-references) from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous operation. It contains `filePath` and `nodePath`.
+A [`NodeReference`](/docs/codemods#node-references) from [`getNodes()`](/docs/codemods/get-nodes) or a previous operation. It contains `filePath` and `nodePath`.
### updates
-An array of `{key, operation}` objects, applied in order. JSX prop keys may use paths such as `style.opacity`. Effect keys name configuration properties.
+An array of `{key, operation}` objects, applied in order. Node prop keys may use paths such as `style.opacity`. Effect keys name configuration properties.
#### operation
@@ -76,7 +76,7 @@ An array of `{filePath, oldNodePath, newNodePath}` mappings. A `null` old path i
### updatedNode
-The edited JSX node reference. Adding a frame hook can change node paths throughout the component.
+The edited node reference. Adding a frame hook can change node paths throughout the component.
## Errors
@@ -88,6 +88,6 @@ Throws or rejects when the target cannot be resolved, the requested edit is unsu
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-jsx-node-keyframes.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-node-keyframes.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/update-jsx-node-props.mdx b/packages/docs/docs/codemods/update-node-props.mdx
similarity index 78%
rename from packages/docs/docs/codemods/update-jsx-node-props.mdx
rename to packages/docs/docs/codemods/update-node-props.mdx
index a94e5034a4..eea8d767de 100644
--- a/packages/docs/docs/codemods/update-jsx-node-props.mdx
+++ b/packages/docs/docs/codemods/update-node-props.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-update-jsx-node-props.png
-title: 'updateJsxNodeProps()'
+image: /generated/articles-docs-codemods-update-node-props.png
+title: 'updateNodeProps()'
crumb: '@remotion/codemods'
---
-# updateJsxNodeProps()<AvailableFrom v="4.0.528" />
+# updateNodeProps()<AvailableFrom v="4.0.530" />
-Updates JSX props, nested object properties, and supported text children.
+Updates node props, nested object properties, and supported text children.
:::warning
@@ -14,13 +14,13 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="update-jsx-node-props.ts"
-import {updateJsxNodeProps, type CodemodProject, type JsxNodeReference} from '@remotion/codemods';
+```ts twoslash title="update-node-props.ts"
+import {updateNodeProps, type CodemodProject, type NodeReference} from '@remotion/codemods';
declare const project: CodemodProject;
-declare const node: JsxNodeReference;
+declare const node: NodeReference;
-const result = updateJsxNodeProps({
+const result = updateNodeProps({
project,
node,
props: {'style.opacity': 0.5, title: 'Preview'},
@@ -29,7 +29,7 @@ const result = updateJsxNodeProps({
console.log(result);
```
-The `props` form rejects computed props, including props potentially overridden by a spread. Setting a keyframed prop replaces the animation with the supplied static value; use [`updateJsxNodeKeyframes()`](/docs/codemods/update-jsx-node-keyframes) to edit its animation. Unchanged surrounding source is preserved.
+The `props` form rejects computed props, including props potentially overridden by a spread. Setting a keyframed prop replaces the animation with the supplied static value; use [`updateNodeKeyframes()`](/docs/codemods/update-node-keyframes) to edit its animation. Unchanged surrounding source is preserved.
## Options
@@ -39,7 +39,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-A [`JsxNodeReference`](/docs/codemods#node-references) from [`getJsxNodes()`](/docs/codemods/get-jsx-nodes) or a previous operation. It contains `filePath` and `nodePath`.
+A [`NodeReference`](/docs/codemods#node-references) from [`getNodes()`](/docs/codemods/get-nodes) or a previous operation. It contains `filePath` and `nodePath`.
### props?
@@ -107,7 +107,7 @@ An array of `{key, valueString}` entries for additional props removed when a sch
### logLine
-The one-based line of the JSX opening tag in the input source.
+The one-based line of the node's opening tag in the input source.
### newNodePath
@@ -119,7 +119,7 @@ The edited node's path in the updated source.
### results
-A one-element array containing `oldValueStrings`, `removedProps`, `logLine`, and `newNodePath`. This matches the per-node results returned by [`updateMultipleJsxNodeProps()`](/docs/codemods/update-multiple-jsx-node-props).
+A one-element array containing `oldValueStrings`, `removedProps`, `logLine`, and `newNodePath`. This matches the per-node results returned by [`updateMultipleNodeProps()`](/docs/codemods/update-multiple-node-props).
### updatedNodes
@@ -135,6 +135,6 @@ Throws when the target cannot be resolved, the requested edit is unsupported, or
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-jsx-node-props.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/update-node-props.ts)
- [`@remotion/codemods`](/docs/codemods)
-- [`getJsxNodes()`](/docs/codemods/get-jsx-nodes)
+- [`getNodes()`](/docs/codemods/get-nodes)
diff --git a/packages/docs/docs/codemods/wrap-jsx-node.mdx b/packages/docs/docs/codemods/wrap-node.mdx
similarity index 71%
rename from packages/docs/docs/codemods/wrap-jsx-node.mdx
rename to packages/docs/docs/codemods/wrap-node.mdx
index 80a7d24076..459160563a 100644
--- a/packages/docs/docs/codemods/wrap-jsx-node.mdx
+++ b/packages/docs/docs/codemods/wrap-node.mdx
@@ -1,12 +1,12 @@
---
-image: /generated/articles-docs-codemods-wrap-jsx-node.png
-title: 'wrapJsxNode()'
+image: /generated/articles-docs-codemods-wrap-node.png
+title: 'wrapNode()'
crumb: '@remotion/codemods'
---
-# wrapJsxNode()<AvailableFrom v="4.0.530" />
+# wrapNode()<AvailableFrom v="4.0.530" />
-Wraps an existing JSX element in an element created with [`createElement()`](/docs/codemods/create-element). The wrapped element becomes the only child of the wrapper, and the wrapper's imports are added.
+Wraps an existing node in an element created with [`createElement()`](/docs/codemods/create-element). The wrapped element becomes the only child of the wrapper, and the wrapper's imports are added.
:::warning
@@ -14,15 +14,15 @@ _Draft API_: This API is experimental and may change.
:::
-```ts twoslash title="wrap-jsx-node.ts"
-import {createElement, getJsxNodes, wrapJsxNode, type CodemodProject} from '@remotion/codemods';
+```ts twoslash title="wrap-node.ts"
+import {createElement, getNodes, wrapNode, type CodemodProject} from '@remotion/codemods';
declare const project: CodemodProject;
-const node = getJsxNodes({project, filePath: 'src/Video.tsx'}).find((candidate) => candidate.tagName === 'div');
+const node = getNodes({project, filePath: 'src/Video.tsx'}).find((candidate) => candidate.tagName === 'div');
if (node) {
- const result = wrapJsxNode({
+ const result = wrapNode({
project,
node,
wrapper: createElement({
@@ -45,7 +45,7 @@ An in-memory [`CodemodProject`](/docs/codemods#project-model). The input project
### node
-The reference of the JSX element to wrap. See [node references](/docs/codemods#node-references).
+The reference of the node to wrap. See [node references](/docs/codemods#node-references).
### wrapper
@@ -77,6 +77,6 @@ Throws when the node cannot be found, cannot be wrapped, or the wrapper is inval
## See also
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/wrap-jsx-node.ts)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/codemods/src/wrap-node.ts)
- [`createElement()`](/docs/codemods/create-element)
- [`addElement()`](/docs/codemods/add-element)
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index e85b7377c4..11e35df202 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -2088,19 +2088,19 @@ const sidebars: SidebarsConfig = {
'codemods/create-element',
'codemods/delete-composition',
'codemods/delete-effects',
- 'codemods/delete-jsx-nodes',
+ 'codemods/delete-nodes',
'codemods/detach-audio',
'codemods/duplicate-composition',
'codemods/duplicate-effects',
- 'codemods/duplicate-jsx-nodes',
- 'codemods/get-jsx-node-props',
- 'codemods/get-jsx-nodes',
+ 'codemods/duplicate-nodes',
+ 'codemods/get-node-props',
+ 'codemods/get-nodes',
'codemods/move-composition',
'codemods/move-folder',
'codemods/rename-composition',
'codemods/rename-folder',
'codemods/reorder-effect',
- 'codemods/reorder-jsx-node',
+ 'codemods/reorder-node',
'codemods/resolve-composition-component',
'codemods/set-composition-default-props',
'codemods/split-sequences',
@@ -2109,11 +2109,11 @@ const sidebars: SidebarsConfig = {
'codemods/update-composition-metadata',
'codemods/update-effect-keyframes',
'codemods/update-effect-props',
- 'codemods/update-jsx-node-keyframes',
- 'codemods/update-jsx-node-props',
- 'codemods/update-multiple-jsx-node-props',
+ 'codemods/update-multiple-node-props',
+ 'codemods/update-node-keyframes',
+ 'codemods/update-node-props',
'codemods/update-visual-controls',
- 'codemods/wrap-jsx-node',
+ 'codemods/wrap-node',
],
},
],
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 816a29cebd..b4c2f9bb61 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1576,13 +1576,13 @@ export const articles = [
slug: 'codemods/delete-effects',
},
{
- id: 'codemods/delete-jsx-nodes',
- title: 'deleteJsxNodes()',
- relativePath: 'docs/codemods/delete-jsx-nodes.mdx',
- compId: 'articles-docs-codemods-delete-jsx-nodes',
+ id: 'codemods/delete-nodes',
+ title: 'deleteNodes()',
+ relativePath: 'docs/codemods/delete-nodes.mdx',
+ compId: 'articles-docs-codemods-delete-nodes',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/delete-jsx-nodes',
+ slug: 'codemods/delete-nodes',
},
{
id: 'codemods/detach-audio',
@@ -1612,31 +1612,31 @@ export const articles = [
slug: 'codemods/duplicate-effects',
},
{
- id: 'codemods/duplicate-jsx-nodes',
- title: 'duplicateJsxNodes()',
- relativePath: 'docs/codemods/duplicate-jsx-nodes.mdx',
- compId: 'articles-docs-codemods-duplicate-jsx-nodes',
+ id: 'codemods/duplicate-nodes',
+ title: 'duplicateNodes()',
+ relativePath: 'docs/codemods/duplicate-nodes.mdx',
+ compId: 'articles-docs-codemods-duplicate-nodes',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/duplicate-jsx-nodes',
+ slug: 'codemods/duplicate-nodes',
},
{
- id: 'codemods/get-jsx-node-props',
- title: 'getJsxNodeProps()',
- relativePath: 'docs/codemods/get-jsx-node-props.mdx',
- compId: 'articles-docs-codemods-get-jsx-node-props',
+ id: 'codemods/get-node-props',
+ title: 'getNodeProps()',
+ relativePath: 'docs/codemods/get-node-props.mdx',
+ compId: 'articles-docs-codemods-get-node-props',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/get-jsx-node-props',
+ slug: 'codemods/get-node-props',
},
{
- id: 'codemods/get-jsx-nodes',
- title: 'getJsxNodes()',
- relativePath: 'docs/codemods/get-jsx-nodes.mdx',
- compId: 'articles-docs-codemods-get-jsx-nodes',
+ id: 'codemods/get-nodes',
+ title: 'getNodes()',
+ relativePath: 'docs/codemods/get-nodes.mdx',
+ compId: 'articles-docs-codemods-get-nodes',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/get-jsx-nodes',
+ slug: 'codemods/get-nodes',
},
{
id: 'codemods/index',
@@ -1693,13 +1693,13 @@ export const articles = [
slug: 'codemods/reorder-effect',
},
{
- id: 'codemods/reorder-jsx-node',
- title: 'reorderJsxNode()',
- relativePath: 'docs/codemods/reorder-jsx-node.mdx',
- compId: 'articles-docs-codemods-reorder-jsx-node',
+ id: 'codemods/reorder-node',
+ title: 'reorderNode()',
+ relativePath: 'docs/codemods/reorder-node.mdx',
+ compId: 'articles-docs-codemods-reorder-node',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/reorder-jsx-node',
+ slug: 'codemods/reorder-node',
},
{
id: 'codemods/resolve-composition-component',
@@ -1774,31 +1774,31 @@ export const articles = [
slug: 'codemods/update-effect-props',
},
{
- id: 'codemods/update-jsx-node-keyframes',
- title: 'updateJsxNodeKeyframes()',
- relativePath: 'docs/codemods/update-jsx-node-keyframes.mdx',
- compId: 'articles-docs-codemods-update-jsx-node-keyframes',
+ id: 'codemods/update-multiple-node-props',
+ title: 'updateMultipleNodeProps()',
+ relativePath: 'docs/codemods/update-multiple-node-props.mdx',
+ compId: 'articles-docs-codemods-update-multiple-node-props',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/update-jsx-node-keyframes',
+ slug: 'codemods/update-multiple-node-props',
},
{
- id: 'codemods/update-jsx-node-props',
- title: 'updateJsxNodeProps()',
- relativePath: 'docs/codemods/update-jsx-node-props.mdx',
- compId: 'articles-docs-codemods-update-jsx-node-props',
+ id: 'codemods/update-node-keyframes',
+ title: 'updateNodeKeyframes()',
+ relativePath: 'docs/codemods/update-node-keyframes.mdx',
+ compId: 'articles-docs-codemods-update-node-keyframes',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/update-jsx-node-props',
+ slug: 'codemods/update-node-keyframes',
},
{
- id: 'codemods/update-multiple-jsx-node-props',
- title: 'updateMultipleJsxNodeProps()',
- relativePath: 'docs/codemods/update-multiple-jsx-node-props.mdx',
- compId: 'articles-docs-codemods-update-multiple-jsx-node-props',
+ id: 'codemods/update-node-props',
+ title: 'updateNodeProps()',
+ relativePath: 'docs/codemods/update-node-props.mdx',
+ compId: 'articles-docs-codemods-update-node-props',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/update-multiple-jsx-node-props',
+ slug: 'codemods/update-node-props',
},
{
id: 'codemods/update-visual-controls',
@@ -1810,13 +1810,13 @@ export const articles = [
slug: 'codemods/update-visual-controls',
},
{
- id: 'codemods/wrap-jsx-node',
- title: 'wrapJsxNode()',
- relativePath: 'docs/codemods/wrap-jsx-node.mdx',
- compId: 'articles-docs-codemods-wrap-jsx-node',
+ id: 'codemods/wrap-node',
+ title: 'wrapNode()',
+ relativePath: 'docs/codemods/wrap-node.mdx',
+ compId: 'articles-docs-codemods-wrap-node',
crumb: '@remotion/codemods',
noAi: false,
- slug: 'codemods/wrap-jsx-node',
+ slug: 'codemods/wrap-node',
},
{
id: 'color-correction',
diff --git a/packages/docs/static/generated/articles-docs-codemods-delete-jsx-nodes.png b/packages/docs/static/generated/articles-docs-codemods-delete-jsx-nodes.png
deleted file mode 100644
index c3287204b3..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-delete-jsx-nodes.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-delete-nodes.png b/packages/docs/static/generated/articles-docs-codemods-delete-nodes.png
new file mode 100644
index 0000000000..e28c167482
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-delete-nodes.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-duplicate-jsx-nodes.png b/packages/docs/static/generated/articles-docs-codemods-duplicate-jsx-nodes.png
deleted file mode 100644
index 1a44407855..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-duplicate-jsx-nodes.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-duplicate-nodes.png b/packages/docs/static/generated/articles-docs-codemods-duplicate-nodes.png
new file mode 100644
index 0000000000..8cdf976619
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-duplicate-nodes.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-get-jsx-node-props.png b/packages/docs/static/generated/articles-docs-codemods-get-jsx-node-props.png
deleted file mode 100644
index c18dd259ee..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-get-jsx-node-props.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-get-jsx-nodes.png b/packages/docs/static/generated/articles-docs-codemods-get-jsx-nodes.png
deleted file mode 100644
index dc0dcf85dd..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-get-jsx-nodes.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-get-node-props.png b/packages/docs/static/generated/articles-docs-codemods-get-node-props.png
new file mode 100644
index 0000000000..5352ecbd14
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-get-node-props.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-get-nodes.png b/packages/docs/static/generated/articles-docs-codemods-get-nodes.png
new file mode 100644
index 0000000000..2c46b6560a
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-get-nodes.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-reorder-jsx-node.png b/packages/docs/static/generated/articles-docs-codemods-reorder-jsx-node.png
deleted file mode 100644
index 1ec5aad962..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-reorder-jsx-node.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-reorder-node.png b/packages/docs/static/generated/articles-docs-codemods-reorder-node.png
new file mode 100644
index 0000000000..bf61c4e086
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-reorder-node.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-update-jsx-node-keyframes.png b/packages/docs/static/generated/articles-docs-codemods-update-jsx-node-keyframes.png
deleted file mode 100644
index 7f9ca5b8eb..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-update-jsx-node-keyframes.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-update-jsx-node-props.png b/packages/docs/static/generated/articles-docs-codemods-update-jsx-node-props.png
deleted file mode 100644
index 4fbeb270d9..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-update-jsx-node-props.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-update-multiple-jsx-node-props.png b/packages/docs/static/generated/articles-docs-codemods-update-multiple-jsx-node-props.png
deleted file mode 100644
index 9e698ccf80..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-update-multiple-jsx-node-props.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-update-multiple-node-props.png b/packages/docs/static/generated/articles-docs-codemods-update-multiple-node-props.png
new file mode 100644
index 0000000000..81f4f3f631
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-update-multiple-node-props.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-update-node-keyframes.png b/packages/docs/static/generated/articles-docs-codemods-update-node-keyframes.png
new file mode 100644
index 0000000000..11e9f774ef
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-update-node-keyframes.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-update-node-props.png b/packages/docs/static/generated/articles-docs-codemods-update-node-props.png
new file mode 100644
index 0000000000..c74a55b3ef
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-update-node-props.png differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-wrap-jsx-node.png b/packages/docs/static/generated/articles-docs-codemods-wrap-jsx-node.png
deleted file mode 100644
index e29254f4df..0000000000
Binary files a/packages/docs/static/generated/articles-docs-codemods-wrap-jsx-node.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-codemods-wrap-node.png b/packages/docs/static/generated/articles-docs-codemods-wrap-node.png
new file mode 100644
index 0000000000..4476d5b32f
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-codemods-wrap-node.png differ
diff --git a/packages/it-tests/src/codemods/codemods.test.ts b/packages/it-tests/src/codemods/codemods.test.ts
index 16f1ca6046..788ed76b93 100644
--- a/packages/it-tests/src/codemods/codemods.test.ts
+++ b/packages/it-tests/src/codemods/codemods.test.ts
@@ -5,8 +5,8 @@ import {
applyCodemodChanges,
deleteComposition,
duplicateComposition,
- getJsxNodeProps,
- getJsxNodes,
+ getNodeProps,
+ getNodes,
renameComposition,
} from '@remotion/codemods';
@@ -57,13 +57,13 @@ test('edits composition registrations through the packaged public API', () => {
}).changes,
);
- const registrations = getJsxNodes({project, filePath: compositionFile})
+ const registrations = getNodes({project, filePath: compositionFile})
.filter(
(node) => node.tagName === 'Composition' || node.tagName === 'Still',
)
.map((node) => ({
tagName: node.tagName,
- props: getJsxNodeProps({
+ props: getNodeProps({
project,
node,
keys: ['id', 'width', 'height', 'fps', 'durationInFrames'],
diff --git a/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts b/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts
index 127aa25798..b78831e2e0 100644
--- a/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts
+++ b/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts
@@ -1,5 +1,5 @@
import {
- updateJsxNodeKeyframes,
+ updateNodeKeyframes,
updateEffectKeyframes as updateEffectKeyframesInProject,
type EffectKeyframeUpdate,
type IntroducedKeyframeIdentifiers,
@@ -33,7 +33,7 @@ export const updateSequenceKeyframes = async ({
videoConfigValues,
...options
}: KeyframeInput & {nodePath: SequenceNodePath}) => {
- const result = await updateJsxNodeKeyframes({
+ const result = await updateNodeKeyframes({
project: {files: {'source.tsx': input}, rootDir: '/'},
node: {filePath: 'source.tsx', nodePath},
videoConfig: videoConfigValues ?? undefined,
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.ts
index 50c30e25eb..4d267ac41a 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,5 +1,5 @@
import {
- updateMultipleJsxNodeProps,
+ updateMultipleNodeProps,
type RemovedProp,
type SequencePropsNodeUpdate,
type SequencePropsNodeUpdateResult,
@@ -44,7 +44,7 @@ export const updateMultipleSequenceProps = ({
prettierConfigOverride: PrettierConfigOverride;
}): Promise<UpdateMultipleSequencePropsResult> => {
return Promise.resolve().then(() => {
- const result = updateMultipleJsxNodeProps({
+ const result = updateMultipleNodeProps({
project: {files: {'source.tsx': input}, rootDir: '/'},
changes: changes.map(
({nodePath, updates, schema, videoConfigValues}) => ({
diff --git a/packages/studio-server/src/helpers/resolve-composition-component.ts b/packages/studio-server/src/helpers/resolve-composition-component.ts
index b692f99e02..287bfbae9e 100644
--- a/packages/studio-server/src/helpers/resolve-composition-component.ts
+++ b/packages/studio-server/src/helpers/resolve-composition-component.ts
@@ -4,8 +4,8 @@ import {
addElement,
applyCodemodChanges,
CodemodsInternals,
- getJsxNodes,
- type InsertJsxElementCodemodEnvironment,
+ getNodes,
+ type CodemodEnvironment,
type ResolvedCompositionComponent,
type ResolvedCompositionComponentWithFile,
} from '@remotion/codemods';
@@ -28,7 +28,7 @@ const {
const makeCodemodEnvironment = (
remotionRoot: string,
sourceFileOverrides: ReadonlyMap<string, string> | null,
-): InsertJsxElementCodemodEnvironment => ({
+): CodemodEnvironment => ({
dirname: path.dirname,
extname: path.extname,
fileExists: (fileName) =>
@@ -173,7 +173,7 @@ export const insertJsxElementIntoComposition = async ({
prettierConfigOverride,
});
const nextProject = applyCodemodChanges(project, result.changes);
- const insertedNode = getJsxNodes({
+ const insertedNode = getNodes({
project: nextProject,
filePath: location.fileName,
}).find(
diff --git a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
index a43c0dc5ee..95058cb618 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
@@ -13,11 +13,7 @@ import type {
TSAsExpression,
UnaryExpression,
} from '@babel/types';
-import {
- CodemodsInternals,
- getJsxNodeProps,
- getJsxNodes,
-} from '@remotion/codemods';
+import {CodemodsInternals, getNodeProps, getNodes} from '@remotion/codemods';
import {RenderInternals} from '@remotion/renderer';
import type {SubscribeToSequencePropsResponse} from '@remotion/studio-shared';
import {LINEAR_KEYFRAME_EASING} from '@remotion/studio-shared';
@@ -1357,7 +1353,7 @@ export const resolveSequencePropsNodePathsFromFilename = ({
action: 'read',
});
const fileContents = readFileSync(absolutePath, 'utf-8');
- const nodes = getJsxNodes({
+ const nodes = getNodes({
project: {rootDir: remotionRoot, files: {[absolutePath]: fileContents}},
filePath: absolutePath,
});
@@ -1391,7 +1387,7 @@ export const computeSequencePropsStatusFromContent = ({
videoConfigValues: VideoConfigValues | null;
}): CanUpdateSequencePropsResponseTrue => {
try {
- return getJsxNodeProps({
+ return getNodeProps({
project: {rootDir: '/', files: {'source.tsx': fileContents}},
node: {filePath: 'source.tsx', nodePath},
componentIdentity,
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.ts
index d73577633a..f609b0c440 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,5 +1,5 @@
import {readFileSync} from 'node:fs';
-import {deleteJsxNodes} from '@remotion/codemods';
+import {deleteNodes} from '@remotion/codemods';
import {RenderInternals} from '@remotion/renderer';
import type {
DeleteJsxNodesRequest,
@@ -67,7 +67,7 @@ export const deleteJsxNodesHandler: ApiHandler<
const fileContents = readFileSync(absolutePath, 'utf-8');
- const result = await deleteJsxNodes({
+ const result = await deleteNodes({
project: {
files: {[absolutePath]: fileContents},
rootDir: remotionRoot,
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.ts
index 3fec10b5d7..3a70edb6f2 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 {duplicateJsxNodes} from '@remotion/codemods';
+import {duplicateNodes} from '@remotion/codemods';
import {RenderInternals} from '@remotion/renderer';
import type {
DuplicateJsxNodeRequest,
@@ -50,7 +50,7 @@ export const duplicateJsxNodeHandler: ApiHandler<
action: 'modify',
});
const fileContents = readFileSync(absolutePath, 'utf-8');
- const result = await duplicateJsxNodes({
+ const result = await duplicateNodes({
project: {
files: {[absolutePath]: fileContents},
rootDir: remotionRoot,
diff --git a/packages/studio-server/src/preview-server/routes/reorder-sequence.ts b/packages/studio-server/src/preview-server/routes/reorder-sequence.ts
index ab7fdced52..4a9c322b97 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 {reorderJsxNode} from '@remotion/codemods';
+import {reorderNode} from '@remotion/codemods';
import {RenderInternals} from '@remotion/renderer';
import type {
ReorderSequenceRequest,
@@ -43,7 +43,7 @@ export const reorderSequenceHandler: ApiHandler<
});
const fileContents = readFileSync(absolutePath, 'utf-8');
- const result = await reorderJsxNode({
+ const result = await reorderNode({
project: {files: {[absolutePath]: fileContents}, rootDir: remotionRoot},
node: {filePath: absolutePath, nodePath: sourceNodePath.nodePath},
target: {filePath: absolutePath, nodePath: targetNodePath.nodePath},
diff --git a/packages/studio-server/src/preview-server/routes/replace-video-source.ts b/packages/studio-server/src/preview-server/routes/replace-video-source.ts
index 10de3f55a9..33fad31f50 100644
--- a/packages/studio-server/src/preview-server/routes/replace-video-source.ts
+++ b/packages/studio-server/src/preview-server/routes/replace-video-source.ts
@@ -1,5 +1,5 @@
import {readFileSync} from 'node:fs';
-import {updateJsxNodeProps} from '@remotion/codemods';
+import {updateNodeProps} from '@remotion/codemods';
import {RenderInternals} from '@remotion/renderer';
import type {
ReplaceVideoSourceRequest,
@@ -33,7 +33,7 @@ export const replaceVideoSourceHandler: ApiHandler<
action: 'modify',
});
const fileContents = readFileSync(absolutePath, 'utf-8');
- const result = updateJsxNodeProps({
+ const result = updateNodeProps({
project: {
files: {[absolutePath]: fileContents},
rootDir: remotionRoot,
diff --git a/packages/studio-server/src/preview-server/routes/wrap-jsx-node.ts b/packages/studio-server/src/preview-server/routes/wrap-jsx-node.ts
index cdff964540..bf06eb089a 100644
--- a/packages/studio-server/src/preview-server/routes/wrap-jsx-node.ts
+++ b/packages/studio-server/src/preview-server/routes/wrap-jsx-node.ts
@@ -1,5 +1,5 @@
import {readFileSync} from 'node:fs';
-import {canWrapJsxNode, createElement, wrapJsxNode} from '@remotion/codemods';
+import {canWrapNode, createElement, wrapNode} from '@remotion/codemods';
import {RenderInternals} from '@remotion/renderer';
import type {
WrapJsxNodeRequest,
@@ -36,7 +36,7 @@ export const wrapJsxNodeHandler: ApiHandler<
action: 'modify',
});
const fileContents = readFileSync(absolutePath, 'utf-8');
- const eligibility = canWrapJsxNode({input: fileContents, nodePath});
+ const eligibility = canWrapNode({input: fileContents, nodePath});
if (wrapper === null) {
return Promise.resolve({
success: true,
@@ -53,7 +53,7 @@ export const wrapJsxNodeHandler: ApiHandler<
throw new Error('This JSX element cannot be wrapped');
}
- const result = wrapJsxNode({
+ const result = wrapNode({
project: {files: {[absolutePath]: fileContents}, rootDir: remotionRoot},
node: {filePath: absolutePath, nodePath},
wrapper: createElement({
diff --git a/packages/template-vibe-code/README.md b/packages/template-vibe-code/README.md
index eb862e7690..a265e8b5d5 100644
--- a/packages/template-vibe-code/README.md
+++ b/packages/template-vibe-code/README.md
@@ -60,7 +60,7 @@ The browser bundler compiles with WebAssembly and shared memory, which requires
### How layers are linked to code
-The browser bundler records where every JSX element was written, and the Canvas exposes that location for each mounted sequence through [`getCanvasSequenceSourceLocation()`](https://www.remotion.dev/docs/canvas/get-canvas-sequence-source-location). The editor looks the location up in the compiled files with `getJsxNodes()` and registers the resulting node paths with [`controller.setSequenceNodePaths()`](https://www.remotion.dev/docs/canvas/create-canvas-controller#setsequencenodepaths), so selection, the timeline and the inspector all refer to the same source node β€” also for elements rendered in a `.map()` loop. Elements created by dependencies have no source location and are shown but not editable.
+The browser bundler records where every JSX element was written, and the Canvas exposes that location for each mounted sequence through [`getCanvasSequenceSourceLocation()`](https://www.remotion.dev/docs/canvas/get-canvas-sequence-source-location). The editor looks the location up in the compiled files with `getNodes()` and registers the resulting node paths with [`controller.setSequenceNodePaths()`](https://www.remotion.dev/docs/canvas/create-canvas-controller#setsequencenodepaths), so selection, the timeline and the inspector all refer to the same source node β€” also for elements rendered in a `.map()` loop. Elements created by dependencies have no source location and are shown but not editable.
### Live previews
diff --git a/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx b/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx
index 4d1e97e832..c538c84d54 100644
--- a/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx
+++ b/packages/template-vibe-code/src/editor/components/Inspector/LayerInspector.tsx
@@ -1,6 +1,6 @@
"use client";
-import { getJsxNodeProps, type SequencePropUpdate } from "@remotion/codemods";
+import { getNodeProps, type SequencePropUpdate } from "@remotion/codemods";
import { RotateCcwIcon } from "lucide-react";
import React, { useMemo } from "react";
import { Button } from "@/components/ui/button";
@@ -40,7 +40,7 @@ import {
} from "./fields";
type VisibleField = ReturnType<typeof getVisibleFields>[number];
-type PropStatus = ReturnType<typeof getJsxNodeProps>["props"][string];
+type PropStatus = ReturnType<typeof getNodeProps>["props"][string];
// Radix Select items cannot have an empty string as value.
const defaultOption = "__default__";
@@ -336,9 +336,9 @@ export const LayerInspector: React.FC<{ readonly layer: Layer }> = ({
let visible = getVisibleFields(schema);
const keys = visible.map(({ key }) => key);
- let props: ReturnType<typeof getJsxNodeProps>["props"] | null = null;
+ let props: ReturnType<typeof getNodeProps>["props"] | null = null;
try {
- props = getJsxNodeProps({
+ props = getNodeProps({
project,
node,
keys,
@@ -367,7 +367,7 @@ export const LayerInspector: React.FC<{ readonly layer: Layer }> = ({
if (variantFields.length > 0) {
visible = [...visible, ...variantFields];
try {
- const extra = getJsxNodeProps({
+ const extra = getNodeProps({
project,
node,
keys: variantFields.map((item) => item.key),
diff --git a/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx b/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx
index 5e94a48853..4639a5083a 100644
--- a/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx
+++ b/packages/template-vibe-code/src/editor/components/Timeline/Timeline.tsx
@@ -5,7 +5,7 @@ import {
useCanvasSelection,
useCanvasSequenceHover,
} from "@remotion/canvas";
-import { getJsxNodeProps } from "@remotion/codemods";
+import { getNodeProps } from "@remotion/codemods";
import {
FilmIcon,
ImageIcon,
@@ -380,7 +380,7 @@ export const Timeline: React.FC = () => {
let blocked: string | null = null;
if (node) {
try {
- const { props } = getJsxNodeProps({
+ const { props } = getNodeProps({
project,
node,
keys: ["from", "durationInFrames"],
diff --git a/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts b/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts
index 5b95f3f713..3ff2dc03ef 100644
--- a/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts
+++ b/packages/template-vibe-code/src/editor/hooks/use-editor-actions.ts
@@ -11,23 +11,23 @@ import {
applyCodemodChanges,
createElement,
deleteComposition,
- deleteJsxNodes,
+ deleteNodes as deleteNodesCodemod,
duplicateComposition,
- duplicateJsxNodes,
+ duplicateNodes as duplicateNodesCodemod,
renameComposition,
- reorderJsxNode,
+ reorderNode as reorderNodeCodemod,
resolveCompositionComponent,
setCompositionDefaultProps,
splitSequences,
updateCompositionMetadata,
- updateJsxNodeProps,
- wrapJsxNode,
+ updateNodeProps,
+ wrapNode,
type CodemodElement,
type CodemodProject,
type CodemodResult,
type CodemodValue,
type CompositionMetadata,
- type JsxNodeReference,
+ type NodeReference,
type SequencePropUpdate,
} from "@remotion/codemods";
import { useMemo, useRef } from "react";
@@ -338,15 +338,15 @@ export const ${componentName}: React.FC = () => {
},
// Layers
- deleteNodes: (nodes: JsxNodeReference[]) =>
- applyCodemod((project) => deleteJsxNodes({ project, nodes }), {
+ deleteNodes: (nodes: NodeReference[]) =>
+ applyCodemod((project) => deleteNodesCodemod({ project, nodes }), {
clearSelection: true,
}),
- duplicateNodes: (nodes: JsxNodeReference[]) =>
- applyCodemod((project) => duplicateJsxNodes({ project, nodes }), {
+ duplicateNodes: (nodes: NodeReference[]) =>
+ applyCodemod((project) => duplicateNodesCodemod({ project, nodes }), {
clearSelection: true,
}),
- splitNodesAtPlayhead: (nodes: JsxNodeReference[]) => {
+ splitNodesAtPlayhead: (nodes: NodeReference[]) => {
const frame = currentFrame();
return applyCodemod(
(project) =>
@@ -357,13 +357,10 @@ export const ${componentName}: React.FC = () => {
{ clearSelection: true },
);
},
- wrapNode: (
- node: JsxNodeReference,
- wrapper: "Sequence" | "AbsoluteFill",
- ) =>
+ wrapNode: (node: NodeReference, wrapper: "Sequence" | "AbsoluteFill") =>
applyCodemod(
(project) =>
- wrapJsxNode({
+ wrapNode({
project,
node,
wrapper: createElement({
@@ -373,7 +370,7 @@ export const ${componentName}: React.FC = () => {
}),
{ clearSelection: true },
),
- reorderNode: (node: JsxNodeReference, direction: "up" | "down") => {
+ reorderNode: (node: NodeReference, direction: "up" | "down") => {
const siblings = ref.current.layers
.map((layer) => layer.source)
.filter(
@@ -400,7 +397,7 @@ export const ${componentName}: React.FC = () => {
return applyCodemod(
(project) =>
- reorderJsxNode({
+ reorderNodeCodemod({
project,
node,
target,
@@ -410,12 +407,12 @@ export const ${componentName}: React.FC = () => {
);
},
updateNodeProps: (
- node: JsxNodeReference,
+ node: NodeReference,
updates: SequencePropUpdate[],
schema: InteractivitySchema | null,
) =>
applyCodemod((project) =>
- updateJsxNodeProps({
+ updateNodeProps({
project,
node,
updates,
@@ -466,7 +463,7 @@ export const ${componentName}: React.FC = () => {
const ok = await applyCodemod(
(project) =>
- updateJsxNodeProps({
+ updateNodeProps({
project,
node,
updates,
@@ -501,9 +498,9 @@ export const ${componentName}: React.FC = () => {
pendingPreviews.clear();
},
- renameNode: (node: JsxNodeReference, name: string) =>
+ renameNode: (node: NodeReference, name: string) =>
applyCodemod((project) =>
- updateJsxNodeProps({
+ updateNodeProps({
project,
node,
updates: [
diff --git a/packages/template-vibe-code/src/editor/model/compositions.ts b/packages/template-vibe-code/src/editor/model/compositions.ts
index eccf7bb751..b0e0a7b544 100644
--- a/packages/template-vibe-code/src/editor/model/compositions.ts
+++ b/packages/template-vibe-code/src/editor/model/compositions.ts
@@ -1,15 +1,15 @@
import {
- getJsxNodeProps,
- getJsxNodes,
+ getNodeProps,
+ getNodes,
type CodemodProject,
- type JsxNodeReference,
+ type NodeReference,
} from "@remotion/codemods";
export type CompositionInfo = {
id: string;
tagName: "Composition" | "Still";
filePath: string;
- node: JsxNodeReference;
+ node: NodeReference;
line: number | null;
width: number | null;
height: number | null;
@@ -21,7 +21,7 @@ export type CompositionInfo = {
const compositionTags = new Set(["Composition", "Still"]);
const readStatic = <T>(
- props: ReturnType<typeof getJsxNodeProps>["props"],
+ props: ReturnType<typeof getNodeProps>["props"],
key: string,
guard: (value: unknown) => value is T,
): T | null => {
@@ -59,7 +59,7 @@ export const findCompositionFile = (project: CodemodProject): string | null => {
try {
if (
- getJsxNodes({ project, filePath }).some((node) =>
+ getNodes({ project, filePath }).some((node) =>
compositionTags.has(node.tagName),
)
) {
@@ -82,10 +82,10 @@ export const getCompositions = (
}
try {
- return getJsxNodes({ project, filePath: compositionFile })
+ return getNodes({ project, filePath: compositionFile })
.filter((node) => compositionTags.has(node.tagName))
.flatMap((node): CompositionInfo[] => {
- const { props } = getJsxNodeProps({
+ const { props } = getNodeProps({
project,
node,
keys: [
diff --git a/packages/template-vibe-code/src/editor/model/layers.ts b/packages/template-vibe-code/src/editor/model/layers.ts
index 8c54de2ba7..f2369829c5 100644
--- a/packages/template-vibe-code/src/editor/model/layers.ts
+++ b/packages/template-vibe-code/src/editor/model/layers.ts
@@ -6,17 +6,17 @@ import {
type TimelineTrackData,
} from "@remotion/canvas";
import {
- getJsxNodes,
+ getNodes,
type CodemodProject,
- type JsxNode,
- type JsxNodeReference,
+ type CodemodNode,
+ type NodeReference,
} from "@remotion/codemods";
import type { SequencePropsSubscriptionKey } from "remotion";
export type Layer = {
track: TimelineTrackData;
/** The JSX element in the source code that registers this sequence. */
- source: JsxNode | null;
+ source: CodemodNode | null;
nodePathInfo: SequenceNodePathInfo;
selectionItem: Extract<CanvasSelectionItem, { type: "sequence" }>;
};
@@ -24,16 +24,16 @@ export type Layer = {
const getJsxNodesSafe = (
project: CodemodProject,
filePath: string,
- cache: Map<string, JsxNode[]>,
-): JsxNode[] => {
+ cache: Map<string, CodemodNode[]>,
+): CodemodNode[] => {
const cached = cache.get(filePath);
if (cached) {
return cached;
}
- let nodes: JsxNode[] = [];
+ let nodes: CodemodNode[] = [];
try {
- nodes = getJsxNodes({ project, filePath });
+ nodes = getNodes({ project, filePath });
} catch {
// Unknown or unparsable file: the layer stays without a source.
}
@@ -57,7 +57,7 @@ export const resolveSequenceNodePaths = (
compiledProject: CodemodProject,
): Record<string, SequencePropsSubscriptionKey> => {
const nodePaths: Record<string, SequencePropsSubscriptionKey> = {};
- const cache = new Map<string, JsxNode[]>();
+ const cache = new Map<string, CodemodNode[]>();
for (const track of tracks) {
const overrideId = track.sequence.controls?.overrideId;
@@ -104,7 +104,7 @@ export const buildLayers = (
tracks: readonly TimelineTrackData[],
project: CodemodProject,
): Layer[] => {
- const cache = new Map<string, JsxNode[]>();
+ const cache = new Map<string, CodemodNode[]>();
return tracks.map((track): Layer => {
const nodePathInfo = getCanvasSequenceNodePathInfo(track);
@@ -126,7 +126,7 @@ export const buildLayers = (
export const getNodeReference = (
item: CanvasSelectionItem,
-): JsxNodeReference | null => {
+): NodeReference | null => {
if (item.type === "guide") {
return null;
}
@@ -140,7 +140,7 @@ export const getNodeReference = (
};
/** Two JSX elements that are children of the same parent element. */
-export const areSiblingNodes = (a: JsxNodeReference, b: JsxNodeReference) => {
+export const areSiblingNodes = (a: NodeReference, b: NodeReference) => {
if (a.filePath !== b.filePath || a.nodePath.length !== b.nodePath.length) {
return false;
}