Skip to content

🎥 Make videos programmatically with React

log file

Jonny Burger8da6ec068a77
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 0bc9a41374..92622cd0d8 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -347,7 +347,6 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={10}
/>
-
<Composition
id="framer"
component={Framer}
@@ -585,7 +584,6 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={2 * 60 * 60 * 30}
/>
-
<Composition
id="video-speed"
component={VideoSpeed}
@@ -991,7 +989,6 @@ export const Index: React.FC = () => {
durationInFrames={150}
/>
</Folder>
-
<Folder name="shapes">
<Composition
id="circle-test"
@@ -1118,7 +1115,7 @@ export const Index: React.FC = () => {
}}
/>
{/**
- // @ts-expect-error */}
+ // @ts-expect-error */}
<Composition
id="impossible-to-save"
component={SchemaTest}
@@ -1159,6 +1156,24 @@ export const Index: React.FC = () => {
fps={30}
defaultProps={{}}
/>
+ <Composition
+ id="Layers2"
+ component={Layers}
+ width={1080}
+ height={1080}
+ durationInFrames={150}
+ fps={30}
+ defaultProps={{}}
+ />
+ <Composition
+ id="Layers1"
+ component={Layers}
+ width={1080}
+ height={1080}
+ durationInFrames={150}
+ fps={30}
+ defaultProps={{}}
+ />
<Composition
id="WidthHeight"
component={WidthHeightSequences}
diff --git a/packages/studio-server/src/preview-server/routes/apply-codemod.ts b/packages/studio-server/src/preview-server/routes/apply-codemod.ts
index 333433c2a3..cc83e0ea63 100644
--- a/packages/studio-server/src/preview-server/routes/apply-codemod.ts
+++ b/packages/studio-server/src/preview-server/routes/apply-codemod.ts
@@ -1,3 +1,4 @@
+import {RenderInternals} from '@remotion/renderer';
import type {
ApplyCodemodRequest,
ApplyCodemodResponse,
@@ -15,8 +16,9 @@ import {checkIfTypeScriptFile} from './can-update-default-props';
export const applyCodemodHandler: ApiHandler<
ApplyCodemodRequest,
ApplyCodemodResponse
-> = async ({input: {codemod, dryRun}, remotionRoot}) => {
+> = async ({input: {codemod, dryRun}, logLevel, remotionRoot}) => {
try {
+ const time = Date.now();
const projectInfo = await getProjectInfo(remotionRoot);
if (!projectInfo.rootFile) {
throw new Error('Cannot find root file in project');
@@ -26,18 +28,24 @@ export const applyCodemodHandler: ApiHandler<
const input = readFileSync(projectInfo.rootFile, 'utf-8');
- const {newContents} = await parseAndApplyCodemod({
+ const {newContents} = parseAndApplyCodemod({
codeMod: codemod,
input,
});
+ const formatted = await formatOutput(newContents);
+
const diff = simpleDiff({
oldLines: input.split('\n'),
- newLines: newContents.split('\n'),
+ newLines: formatted.split('\n'),
});
if (!dryRun) {
- const formatted = await formatOutput(newContents);
writeFileSync(projectInfo.rootFile, formatted);
+ const end = Date.now() - time;
+ RenderInternals.Log.info(
+ {indent: false, logLevel},
+ RenderInternals.chalk.blue(`Edited root file in ${end}ms`),
+ );
}
return {
diff --git a/packages/studio-server/src/preview-server/routes/can-update-default-props.ts b/packages/studio-server/src/preview-server/routes/can-update-default-props.ts
index c9b79971aa..f492b9142a 100644
--- a/packages/studio-server/src/preview-server/routes/can-update-default-props.ts
+++ b/packages/studio-server/src/preview-server/routes/can-update-default-props.ts
@@ -14,7 +14,7 @@ export const checkIfTypeScriptFile = (file: string) => {
!file.endsWith('.mtsx') &&
!file.endsWith('.mts')
) {
- throw new Error('Cannot update default props for non-TypeScript files');
+ throw new Error('Cannot update Root file if not using TypeScript');
}
};