🎥 Make videos programmatically with React
cool
Jonny Burger727cfd395296
diff --git a/packages/studio-server/src/preview-server/routes/apply-visual-control-change.ts b/packages/studio-server/src/preview-server/routes/apply-visual-control-change.tsindex cdc5d8ec10..223c5d27c7 100644--- a/packages/studio-server/src/preview-server/routes/apply-visual-control-change.ts+++ b/packages/studio-server/src/preview-server/routes/apply-visual-control-change.ts@@ -71,10 +71,17 @@ export const applyVisualControlHandler: ApiHandler<// Prettier not available, use unformatted output}- pushToUndoStack(absolutePath, fileContents, logLevel, remotionRoot, {- undoMessage: 'Undid visual control change',- redoMessage: 'Redid visual control change',- });+ pushToUndoStack(+ absolutePath,+ fileContents,+ logLevel,+ remotionRoot,+ {+ undoMessage: 'Undid visual control change',+ redoMessage: 'Redid visual control change',+ },+ 'visual-control',+ );suppressUndoStackInvalidation(absolutePath);suppressHmrForFile(absolutePath);writeFileAndNotifyFileWatchers(absolutePath, output);diff --git a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts b/packages/studio-server/src/preview-server/routes/save-sequence-props.tsindex b2af56e9ae..397d884323 100644--- a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts+++ b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts@@ -65,10 +65,17 @@ export const saveSequencePropsHandler: ApiHandler<defaultValueString: normalizedDefault,});- pushToUndoStack(absolutePath, fileContents, logLevel, remotionRoot, {- undoMessage: `Undid ${undoPropChange}`,- redoMessage: `Redid ${redoPropChange}`,- });+ pushToUndoStack(+ absolutePath,+ fileContents,+ logLevel,+ remotionRoot,+ {+ undoMessage: `Undid ${undoPropChange}`,+ redoMessage: `Redid ${redoPropChange}`,+ },+ 'sequence-props',+ );suppressUndoStackInvalidation(absolutePath);suppressHmrForFile(absolutePath);writeFileAndNotifyFileWatchers(absolutePath, output);diff --git a/packages/studio-server/src/preview-server/routes/update-default-props.ts b/packages/studio-server/src/preview-server/routes/update-default-props.tsindex 0433d2e9c5..c5fac9966d 100644--- a/packages/studio-server/src/preview-server/routes/update-default-props.ts+++ b/packages/studio-server/src/preview-server/routes/update-default-props.ts@@ -54,6 +54,7 @@ export const updateDefaultPropsHandler: ApiHandler<undoMessage: `Undid default props update for "${compositionId}"`,redoMessage: `Redid default props update for "${compositionId}"`,},+ 'default-props',);suppressUndoStackInvalidation(projectInfo.rootFile);suppressHmrForFile(projectInfo.rootFile);diff --git a/packages/studio-server/src/preview-server/undo-stack.ts b/packages/studio-server/src/preview-server/undo-stack.tsindex 1119f320ce..d15bad5159 100644--- a/packages/studio-server/src/preview-server/undo-stack.ts+++ b/packages/studio-server/src/preview-server/undo-stack.ts@@ -18,11 +18,17 @@ export interface UndoEntryDescription {redoMessage: string;}-interface UndoEntry {+type UndoEntryType = 'visual-control' | 'default-props' | 'sequence-props';++type UndoEntry = {filePath: string;oldContents: string;description: UndoEntryDescription;-}+} & (+ | {entryType: 'visual-control'}+ | {entryType: 'default-props'}+ | {entryType: 'sequence-props'}+);const MAX_ENTRIES = 100;const undoStack: UndoEntry[] = [];@@ -54,10 +60,11 @@ export function pushToUndoStack(logLevel: LogLevel,remotionRoot: string,description: UndoEntryDescription,+ entryType: UndoEntryType,) {storedLogLevel = logLevel;storedRemotionRoot = remotionRoot;- undoStack.push({filePath, oldContents, description});+ undoStack.push({filePath, oldContents, description, entryType});if (undoStack.length > MAX_ENTRIES) {undoStack.shift();}@@ -90,8 +97,9 @@ export function pushToRedoStack(filePath: string,oldContents: string,description: UndoEntryDescription,+ entryType: UndoEntryType,) {- redoStack.push({filePath, oldContents, description});+ redoStack.push({filePath, oldContents, description, entryType});if (redoStack.length > MAX_ENTRIES) {redoStack.shift();}@@ -243,6 +251,7 @@ export function popUndo(): {success: true} | {success: false; reason: string} {filePath: entry.filePath,oldContents: currentContents,description: entry.description,+ entryType: entry.entryType,});suppressUndoStackInvalidation(entry.filePath);@@ -258,7 +267,10 @@ export function popUndo(): {success: true} | {success: false; reason: string} {);logFileAction(entry.description.undoMessage, entry.filePath);- emitVisualControlChanges(entry.oldContents);+ if (entry.entryType === 'visual-control') {+ emitVisualControlChanges(entry.oldContents);+ }+ensureWatching(entry.filePath);broadcastState();return {success: true};@@ -275,6 +287,7 @@ export function popRedo(): {success: true} | {success: false; reason: string} {filePath: entry.filePath,oldContents: currentContents,description: entry.description,+ entryType: entry.entryType,});suppressUndoStackInvalidation(entry.filePath);@@ -290,7 +303,10 @@ export function popRedo(): {success: true} | {success: false; reason: string} {);logFileAction(entry.description.redoMessage, entry.filePath);- emitVisualControlChanges(entry.oldContents);+ if (entry.entryType === 'visual-control') {+ emitVisualControlChanges(entry.oldContents);+ }+ensureWatching(entry.filePath);broadcastState();return {success: true};