deleteNodes()v4.0.530
Deletes one or more nodes identified by their references. It works with any element, including <Sequence> and <Solid>.
Draft API: This API is not yet stable. We are in the experimental phase of this package and reserve to change it at any time.
delete-nodes.tsimport {deleteNodes , typeCodemodProject } from '@remotion/codemods'; import type {SequenceNodePath } from 'remotion'; declare constproject :CodemodProject ; declare constnodePath :SequenceNodePath ; constresult =deleteNodes ({project ,nodes : [{filePath : 'src/Video.tsx',nodePath }], });console .log (result .changes );
From v4.0.544, this function returns its result synchronously and throws errors immediately.
Options
project
An in-memory CodemodProject. The input project is not mutated.
nodes
The nodes to delete. Nodes may belong to different project files.
filePath
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 node to delete. Obtain it from getNodes(), an insertion result, or a mounted layer. Canvas layers expose it as nodePathInfo.sequenceSubscriptionKey.nodePath.
Return value
An object with the following properties.
changes
An array describing each changed file with its filePath, previousContents, and nextContents.
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.
Errors
Throws when a reference cannot be resolved or a node cannot be deleted. Failed edits leave the input project unchanged.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||