🎥 Make videos programmatically with React
`@remotion/studio-server`: Reduce time to save bulk effect edits
Jonny Burgerce325d2d5843
diff --git a/packages/studio-server/src/helpers/video-config-values.ts b/packages/studio-server/src/helpers/video-config-values.tsindex 8d97ebb7f8..b6cbf51d2a 100644--- a/packages/studio-server/src/helpers/video-config-values.ts+++ b/packages/studio-server/src/helpers/video-config-values.ts@@ -100,16 +100,15 @@ export const getVideoConfigIdentifiers = ({return bindings;};-// Editing uses the current instance's configuration supplied with the mutation.-export const getVideoConfigIdentifierValues = ({- ast,+export const resolveVideoConfigIdentifierValues = ({+ identifiers,videoConfigValues,}: {- ast: File;+ identifiers: ReadonlyMap<Identifier, VideoConfigNumericBinding>;videoConfigValues: VideoConfigValues | null;}): VideoConfigIdentifierValues =>new Map(- [...getVideoConfigIdentifiers({ast})].flatMap(([identifier, binding]) => {+ [...identifiers].flatMap(([identifier, binding]) => {if (binding.type === 'constant') return [[identifier, binding]];const value = videoConfigValues?.[binding.field];return value === undefined || !Number.isFinite(value)@@ -117,3 +116,16 @@ export const getVideoConfigIdentifierValues = ({: [[identifier, {type: 'constant', value}]];}),);++// Editing uses the current instance's configuration supplied with the mutation.+export const getVideoConfigIdentifierValues = ({+ ast,+ videoConfigValues,+}: {+ ast: File;+ videoConfigValues: VideoConfigValues | null;+}): VideoConfigIdentifierValues =>+ resolveVideoConfigIdentifierValues({+ identifiers: getVideoConfigIdentifiers({ast}),+ videoConfigValues,+ });diff --git a/packages/studio-server/src/preview-server/routes/save-multiple-effect-props.ts b/packages/studio-server/src/preview-server/routes/save-multiple-effect-props.tsindex 09e2144aed..6ec31d4350 100644--- a/packages/studio-server/src/preview-server/routes/save-multiple-effect-props.ts+++ b/packages/studio-server/src/preview-server/routes/save-multiple-effect-props.ts@@ -16,7 +16,10 @@ import {} from '../../codemods/update-effect-props/update-effect-props';import {writeFileAndNotifyFileWatchers} from '../../file-watcher';import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';-import {getVideoConfigIdentifierValues} from '../../helpers/video-config-values';+import {+ getVideoConfigIdentifiers,+ resolveVideoConfigIdentifierValues,+} from '../../helpers/video-config-values';import type {ApiHandler} from '../api-types';import {printUndoHint,@@ -213,6 +216,11 @@ export const saveMultipleEffectPropsHandler: ApiHandler<).values(),];const statusAsts = new Map<string, File>();+ // Share binding analysis, but resolve each target's video configuration below.+ const statusIdentifiers = new Map<+ string,+ ReturnType<typeof getVideoConfigIdentifiers>+ >();const results: SaveMultipleEffectPropsResult[] = statusTargets.map((edit) => {const {absolutePath} = resolveFileInsideProject({@@ -235,22 +243,32 @@ export const saveMultipleEffectPropsHandler: ApiHandler<ast,edit.sequenceNodePath.nodePath,);- const status = jsx- ? computeEffectPropStatus({- ast,- jsx,- effectIndex: edit.effectIndex,- keys: getAllSchemaKeys(edit.schema),- videoConfigValues: getVideoConfigIdentifierValues({- ast,- videoConfigValues: edit.sequenceNodePath.videoConfigValues,- }),- })- : {- canUpdate: false as const,- effectIndex: edit.effectIndex,- reason: 'not-found' as const,- };+ let status: SaveMultipleEffectPropsResult['status'];+ if (jsx) {+ const keys = getAllSchemaKeys(edit.schema);+ let identifiers = statusIdentifiers.get(absolutePath);+ if (!identifiers) {+ identifiers = getVideoConfigIdentifiers({ast});+ statusIdentifiers.set(absolutePath, identifiers);+ }++ status = computeEffectPropStatus({+ ast,+ jsx,+ effectIndex: edit.effectIndex,+ keys,+ videoConfigValues: resolveVideoConfigIdentifierValues({+ identifiers,+ videoConfigValues: edit.sequenceNodePath.videoConfigValues,+ }),+ });+ } else {+ status = {+ canUpdate: false,+ effectIndex: edit.effectIndex,+ reason: 'not-found',+ };+ }return {fileName: edit.fileName,