@remotion/studio-server 4.0.489 → 4.0.491

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/better-opn/index.d.ts +4 -0
  2. package/dist/better-opn/index.js +152 -31
  3. package/dist/codemods/effect-param-expression.js +3 -0
  4. package/dist/codemods/paste-effects.d.ts +2 -1
  5. package/dist/codemods/paste-effects.js +33 -6
  6. package/dist/codemods/update-keyframes/update-keyframes.d.ts +10 -5
  7. package/dist/codemods/update-keyframes/update-keyframes.js +126 -46
  8. package/dist/codemods/update-nested-prop.d.ts +3 -2
  9. package/dist/codemods/update-nested-prop.js +17 -4
  10. package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +6 -3
  11. package/dist/codemods/update-sequence-props/update-sequence-props.js +51 -10
  12. package/dist/helpers/get-installed-installable-packages.js +4 -12
  13. package/dist/helpers/resolve-composition-component.js +1 -0
  14. package/dist/helpers/video-config-numeric-expression.d.ts +12 -0
  15. package/dist/helpers/video-config-numeric-expression.js +152 -0
  16. package/dist/helpers/video-config-values.d.ts +7 -0
  17. package/dist/helpers/video-config-values.js +84 -0
  18. package/dist/index.d.ts +1 -2
  19. package/dist/preview-server/element-install-state.d.ts +1 -0
  20. package/dist/preview-server/routes/add-effect-keyframe.js +6 -0
  21. package/dist/preview-server/routes/add-keyframes.js +2 -0
  22. package/dist/preview-server/routes/add-sequence-keyframe.js +2 -0
  23. package/dist/preview-server/routes/apply-codemod.d.ts +1 -0
  24. package/dist/preview-server/routes/apply-codemod.js +62 -13
  25. package/dist/preview-server/routes/can-update-effect-props.d.ts +8 -4
  26. package/dist/preview-server/routes/can-update-effect-props.js +26 -5
  27. package/dist/preview-server/routes/can-update-sequence-props.d.ts +9 -5
  28. package/dist/preview-server/routes/can-update-sequence-props.js +99 -30
  29. package/dist/preview-server/routes/delete-keyframes.js +8 -0
  30. package/dist/preview-server/routes/install-dependency.d.ts +1 -0
  31. package/dist/preview-server/routes/install-dependency.js +17 -15
  32. package/dist/preview-server/routes/move-keyframes.js +2 -0
  33. package/dist/preview-server/routes/paste-effects.js +2 -1
  34. package/dist/preview-server/routes/save-effect-props.js +5 -0
  35. package/dist/preview-server/routes/save-sequence-props.js +4 -0
  36. package/dist/preview-server/routes/subscribe-to-sequence-props.js +2 -1
  37. package/dist/preview-server/routes/unsubscribe-from-sequence-props.js +1 -0
  38. package/dist/preview-server/routes/update-effect-keyframe-settings.js +7 -0
  39. package/dist/preview-server/routes/update-element-install-target.js +15 -1
  40. package/dist/preview-server/routes/update-sequence-keyframe-settings.js +3 -0
  41. package/dist/preview-server/sequence-props-watchers.d.ts +5 -3
  42. package/dist/preview-server/sequence-props-watchers.js +14 -5
  43. package/dist/preview-server/start-server.d.ts +0 -1
  44. package/dist/preview-server/start-server.js +0 -1
  45. package/dist/routes.js +2 -0
  46. package/dist/start-studio.d.ts +1 -2
  47. package/dist/start-studio.js +1 -2
  48. package/package.json +6 -6
@@ -38,6 +38,8 @@ const studio_shared_1 = require("@remotion/studio-shared");
38
38
  const recast = __importStar(require("recast"));
39
39
  const get_ast_node_path_1 = require("../../helpers/get-ast-node-path");
40
40
  const parse_keyframe_easing_expression_1 = require("../../helpers/parse-keyframe-easing-expression");
41
+ const video_config_numeric_expression_1 = require("../../helpers/video-config-numeric-expression");
42
+ const video_config_values_1 = require("../../helpers/video-config-values");
41
43
  const can_update_sequence_props_1 = require("../../preview-server/routes/can-update-sequence-props");
42
44
  const format_file_content_1 = require("../format-file-content");
43
45
  const parse_ast_1 = require("../parse-ast");
@@ -109,23 +111,9 @@ const getSupportedCallArgument = (arg) => {
109
111
  }
110
112
  return arg;
111
113
  };
112
- const getNumericValue = (node) => {
113
- if (node.type === 'NumericLiteral') {
114
- return node.value;
115
- }
116
- if (node.type === 'UnaryExpression' &&
117
- (node.operator === '-' || node.operator === '+') &&
118
- node.argument.type === 'NumericLiteral') {
119
- return node.operator === '-' ? -node.argument.value : node.argument.value;
120
- }
121
- if (node.type === 'TSAsExpression') {
122
- return getNumericValue(node.expression);
123
- }
124
- return null;
125
- };
126
- const getInterpolationExpression = (node) => {
114
+ const getInterpolationExpression = (node, videoConfigValues) => {
127
115
  if (node.type === 'TSAsExpression') {
128
- return getInterpolationExpression(node.expression);
116
+ return getInterpolationExpression(node.expression, videoConfigValues);
129
117
  }
130
118
  if (node.type !== 'CallExpression' ||
131
119
  node.callee.type !== 'Identifier' ||
@@ -153,12 +141,18 @@ const getInterpolationExpression = (node) => {
153
141
  outputElement.type === 'SpreadElement') {
154
142
  return null;
155
143
  }
156
- const frame = getNumericValue(inputElement);
157
- if (frame === null || !(0, can_update_sequence_props_1.isStaticValue)(outputElement)) {
144
+ const frameExpression = (0, video_config_numeric_expression_1.parseVideoConfigNumericExpression)({
145
+ node: inputElement,
146
+ videoConfigValues,
147
+ });
148
+ if (frameExpression === null || !(0, can_update_sequence_props_1.isStaticValue)(outputElement)) {
158
149
  return null;
159
150
  }
160
151
  keyframes.push({
161
- frame,
152
+ frame: frameExpression.value,
153
+ frameExpression: inputElement,
154
+ frameNumericExpression: frameExpression,
155
+ originalFrame: frameExpression.value,
162
156
  output: outputElement,
163
157
  value: (0, can_update_sequence_props_1.extractStaticValue)(outputElement),
164
158
  });
@@ -192,11 +186,15 @@ const getInterpolationCalleeForValues = ({ schema, key, staticValue, newValue, }
192
186
  const createFrameExpression = (frame) => {
193
187
  return (0, update_nested_prop_1.parseValueExpression)(frame);
194
188
  };
195
- const createClampOptionsExpression = () => {
196
- return b.objectExpression([
189
+ const createClampOptionsExpression = ({ defaultOutput, }) => {
190
+ const properties = [
197
191
  b.objectProperty(b.identifier('extrapolateLeft'), b.stringLiteral('clamp')),
198
192
  b.objectProperty(b.identifier('extrapolateRight'), b.stringLiteral('clamp')),
199
- ]);
193
+ ];
194
+ if (defaultOutput !== null && defaultOutput !== 'linear') {
195
+ properties.push(b.objectProperty(b.identifier('output'), b.stringLiteral(defaultOutput)));
196
+ }
197
+ return b.objectExpression(properties);
200
198
  };
201
199
  const createEmptyOptionsExpression = () => b.objectExpression([]);
202
200
  const findObjectOptionProperty = (options, propertyName) => {
@@ -451,9 +449,18 @@ const validatePosterize = (posterize) => {
451
449
  throw new Error('Cannot update keyframe settings: posterize must be > 0');
452
450
  }
453
451
  };
454
- const updateKeyframeSettings = ({ expression, clamping, posterize, }) => {
452
+ const validateOutput = (output) => {
453
+ if (output === undefined ||
454
+ output === 'linear' ||
455
+ output === 'perceptual-scale') {
456
+ return;
457
+ }
458
+ throw new Error('Cannot update keyframe settings: output must be "linear" or "perceptual-scale"');
459
+ };
460
+ const updateKeyframeSettings = ({ expression, clamping, posterize, output, videoConfigValues, }) => {
455
461
  validatePosterize(posterize);
456
- const existing = getInterpolationExpression(expression);
462
+ validateOutput(output);
463
+ const existing = getInterpolationExpression(expression, videoConfigValues);
457
464
  if (!existing) {
458
465
  throw new Error('Cannot update keyframe settings on non-keyframed value');
459
466
  }
@@ -474,6 +481,7 @@ const updateKeyframeSettings = ({ expression, clamping, posterize, }) => {
474
481
  propertyName: 'extrapolateRight',
475
482
  value: null,
476
483
  });
484
+ setOptionsProperty({ options, propertyName: 'output', value: null });
477
485
  }
478
486
  else if (clamping) {
479
487
  setOptionsProperty({
@@ -487,6 +495,13 @@ const updateKeyframeSettings = ({ expression, clamping, posterize, }) => {
487
495
  value: b.stringLiteral(clamping.right),
488
496
  });
489
497
  }
498
+ if (!isColorInterpolation && output !== undefined) {
499
+ setOptionsProperty({
500
+ options,
501
+ propertyName: 'output',
502
+ value: output === 'linear' ? null : b.stringLiteral(output),
503
+ });
504
+ }
490
505
  setOptionsProperty({
491
506
  options,
492
507
  propertyName: 'posterize',
@@ -502,8 +517,8 @@ const updateKeyframeSettings = ({ expression, clamping, posterize, }) => {
502
517
  keyframes: existing.keyframes,
503
518
  });
504
519
  };
505
- const updateKeyframeEasing = ({ expression, segmentIndex, easing, }) => {
506
- const existing = getInterpolationExpression(expression);
520
+ const updateKeyframeEasing = ({ expression, segmentIndex, easing, videoConfigValues, }) => {
521
+ const existing = getInterpolationExpression(expression, videoConfigValues);
507
522
  if (!existing) {
508
523
  throw new Error('Cannot update easing on non-keyframed value');
509
524
  }
@@ -546,7 +561,12 @@ const createInterpolateExpression = ({ callee, input, extraArgs, keyframes, }) =
546
561
  const sortedKeyframes = [...keyframes].sort((first, second) => first.frame - second.frame);
547
562
  return b.callExpression(callee, [
548
563
  input,
549
- b.arrayExpression(sortedKeyframes.map((keyframe) => createFrameExpression(keyframe.frame))),
564
+ b.arrayExpression(sortedKeyframes.map((keyframe) => keyframe.frame === keyframe.originalFrame
565
+ ? keyframe.frameExpression
566
+ : (0, video_config_numeric_expression_1.updateVideoConfigNumericExpression)({
567
+ expression: keyframe.frameNumericExpression,
568
+ value: keyframe.frame,
569
+ }))),
550
570
  b.arrayExpression(sortedKeyframes.map((keyframe) => keyframe.output)),
551
571
  ...extraArgs,
552
572
  ]);
@@ -556,11 +576,12 @@ const noIntroducedIdentifiers = {
556
576
  needsFrameHook: false,
557
577
  needsEasingImport: false,
558
578
  };
559
- const addKeyframe = ({ expression, key, frame, value, schema, }) => {
579
+ const addKeyframe = ({ expression, key, frame, value, schema, videoConfigValues, }) => {
580
+ var _a;
560
581
  if (!(0, studio_shared_1.isSchemaFieldKeyframable)({ schema, key })) {
561
582
  throw new Error(`Cannot add keyframe: "${key}" is not keyframable`);
562
583
  }
563
- const existing = getInterpolationExpression(expression);
584
+ const existing = getInterpolationExpression(expression, videoConfigValues);
564
585
  const newOutput = (0, update_nested_prop_1.parseValueExpression)(value);
565
586
  if (existing) {
566
587
  const existingCalleeName = existing.callee.type === 'Identifier'
@@ -573,9 +594,19 @@ const addKeyframe = ({ expression, key, frame, value, schema, }) => {
573
594
  const nextCalleeName = schemaCalleeName !== null && schemaCalleeName !== void 0 ? schemaCalleeName : existingCalleeName;
574
595
  const existingIndex = existing.keyframes.findIndex((keyframe) => keyframe.frame === frame);
575
596
  const nextKeyframes = existingIndex === -1
576
- ? [...existing.keyframes, { frame, output: newOutput, value }]
597
+ ? [
598
+ ...existing.keyframes,
599
+ {
600
+ frame,
601
+ frameExpression: createFrameExpression(frame),
602
+ frameNumericExpression: { type: 'literal', value: frame },
603
+ originalFrame: frame,
604
+ output: newOutput,
605
+ value,
606
+ },
607
+ ]
577
608
  : existing.keyframes.map((keyframe, index) => index === existingIndex
578
- ? { frame, output: newOutput, value }
609
+ ? { ...keyframe, output: newOutput, value }
579
610
  : keyframe);
580
611
  const normalizedEasing = existingIndex === -1
581
612
  ? normalizeEasingAfterAddingKeyframe({
@@ -604,11 +635,24 @@ const addKeyframe = ({ expression, key, frame, value, schema, }) => {
604
635
  },
605
636
  };
606
637
  }
607
- if (!(0, can_update_sequence_props_1.isStaticValue)(expression)) {
638
+ const staticNumericExpression = (0, video_config_numeric_expression_1.parseVideoConfigNumericExpression)({
639
+ node: expression,
640
+ videoConfigValues,
641
+ });
642
+ if (!(0, can_update_sequence_props_1.isStaticValue)(expression) && staticNumericExpression === null) {
608
643
  throw new Error('Cannot add keyframe to computed expression');
609
644
  }
610
- const staticValue = (0, can_update_sequence_props_1.extractStaticValue)(expression);
611
- const keyframes = [{ frame, output: newOutput, value }];
645
+ const staticValue = (_a = staticNumericExpression === null || staticNumericExpression === void 0 ? void 0 : staticNumericExpression.value) !== null && _a !== void 0 ? _a : (0, can_update_sequence_props_1.extractStaticValue)(expression);
646
+ const keyframes = [
647
+ {
648
+ frame,
649
+ frameExpression: createFrameExpression(frame),
650
+ frameNumericExpression: { type: 'literal', value: frame },
651
+ originalFrame: frame,
652
+ output: newOutput,
653
+ value,
654
+ },
655
+ ];
612
656
  const callee = getInterpolationCalleeForValues({
613
657
  schema,
614
658
  key,
@@ -617,7 +661,11 @@ const addKeyframe = ({ expression, key, frame, value, schema, }) => {
617
661
  });
618
662
  const extraArgs = callee.type === 'Identifier' && callee.name === 'interpolateColors'
619
663
  ? []
620
- : [createClampOptionsExpression()];
664
+ : [
665
+ createClampOptionsExpression({
666
+ defaultOutput: getDefaultKeyframeOutput({ schema, key }),
667
+ }),
668
+ ];
621
669
  return {
622
670
  expression: createInterpolateExpression({
623
671
  callee,
@@ -634,8 +682,8 @@ const addKeyframe = ({ expression, key, frame, value, schema, }) => {
634
682
  },
635
683
  };
636
684
  };
637
- const removeKeyframe = ({ expression, frame, }) => {
638
- const existing = getInterpolationExpression(expression);
685
+ const removeKeyframe = ({ expression, frame, videoConfigValues, }) => {
686
+ const existing = getInterpolationExpression(expression, videoConfigValues);
639
687
  if (!existing) {
640
688
  throw new Error('Cannot remove keyframe from non-interpolated expression');
641
689
  }
@@ -669,8 +717,8 @@ const removeKeyframe = ({ expression, frame, }) => {
669
717
  },
670
718
  };
671
719
  };
672
- const moveKeyframes = ({ expression, moves, }) => {
673
- const existing = getInterpolationExpression(expression);
720
+ const moveKeyframes = ({ expression, moves, videoConfigValues, }) => {
721
+ const existing = getInterpolationExpression(expression, videoConfigValues);
674
722
  if (!existing) {
675
723
  throw new Error('Cannot move keyframe in non-interpolated expression');
676
724
  }
@@ -728,7 +776,7 @@ const moveKeyframes = ({ expression, moves, }) => {
728
776
  keyframes: nextKeyframes,
729
777
  });
730
778
  };
731
- const applyKeyframeOperation = ({ expression, key, operation, schema, }) => {
779
+ const applyKeyframeOperation = ({ expression, key, operation, schema, videoConfigValues, }) => {
732
780
  if (operation.type === 'add') {
733
781
  return addKeyframe({
734
782
  expression,
@@ -736,6 +784,7 @@ const applyKeyframeOperation = ({ expression, key, operation, schema, }) => {
736
784
  frame: operation.frame,
737
785
  value: operation.value,
738
786
  schema,
787
+ videoConfigValues,
739
788
  });
740
789
  }
741
790
  if (operation.type === 'settings') {
@@ -744,6 +793,8 @@ const applyKeyframeOperation = ({ expression, key, operation, schema, }) => {
744
793
  expression,
745
794
  clamping: operation.clamping,
746
795
  posterize: operation.posterize,
796
+ output: operation.output,
797
+ videoConfigValues,
747
798
  }),
748
799
  introduced: noIntroducedIdentifiers,
749
800
  };
@@ -753,6 +804,7 @@ const applyKeyframeOperation = ({ expression, key, operation, schema, }) => {
753
804
  expression,
754
805
  segmentIndex: operation.segmentIndex,
755
806
  easing: operation.easing,
807
+ videoConfigValues,
756
808
  });
757
809
  return {
758
810
  expression: updated.expression,
@@ -764,11 +816,19 @@ const applyKeyframeOperation = ({ expression, key, operation, schema, }) => {
764
816
  }
765
817
  if (operation.type === 'move') {
766
818
  return {
767
- expression: moveKeyframes({ expression, moves: operation.moves }),
819
+ expression: moveKeyframes({
820
+ expression,
821
+ moves: operation.moves,
822
+ videoConfigValues,
823
+ }),
768
824
  introduced: noIntroducedIdentifiers,
769
825
  };
770
826
  }
771
- return removeKeyframe({ expression, frame: operation.frame });
827
+ return removeKeyframe({
828
+ expression,
829
+ frame: operation.frame,
830
+ videoConfigValues,
831
+ });
772
832
  };
773
833
  const getExpressionFromJsxAttribute = (attr) => {
774
834
  if (!attr.value) {
@@ -832,6 +892,14 @@ const findFieldInSchema = (schema, key) => {
832
892
  }
833
893
  return undefined;
834
894
  };
895
+ const getDefaultKeyframeOutput = ({ schema, key, }) => {
896
+ const field = schema ? findFieldInSchema(schema, key) : undefined;
897
+ if (((field === null || field === void 0 ? void 0 : field.type) === 'number' || (field === null || field === void 0 ? void 0 : field.type) === 'scale') &&
898
+ field.defaultKeyframeOutput !== undefined) {
899
+ return field.defaultKeyframeOutput;
900
+ }
901
+ return key === 'style.scale' ? 'perceptual-scale' : null;
902
+ };
835
903
  const getInitialValueForMissingProp = ({ schema, key, newValue, }) => {
836
904
  const field = schema ? findFieldInSchema(schema, key) : undefined;
837
905
  if (field && field.type !== 'hidden' && field.default !== undefined) {
@@ -958,10 +1026,14 @@ const getEffectPropsObjectExpression = (call) => {
958
1026
  }
959
1027
  return call.arguments[0];
960
1028
  };
961
- const updateSequenceKeyframesAst = ({ input, nodePath, updates, schema, }) => {
1029
+ const updateSequenceKeyframesAst = ({ input, nodePath, updates, schema, videoConfigValues, }) => {
962
1030
  var _a;
963
1031
  var _b;
964
1032
  const ast = (0, parse_ast_1.parseAst)(input);
1033
+ const videoConfigIdentifierValues = (0, video_config_values_1.getVideoConfigIdentifierValues)({
1034
+ ast,
1035
+ videoConfigValues,
1036
+ });
965
1037
  const jsxPath = (0, get_ast_node_path_1.getAstNodePath)(ast, nodePath);
966
1038
  const node = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, nodePath);
967
1039
  if (!node || !jsxPath) {
@@ -994,6 +1066,7 @@ const updateSequenceKeyframesAst = ({ input, nodePath, updates, schema, }) => {
994
1066
  key: update.key,
995
1067
  operation: update.operation,
996
1068
  schema: schema !== null && schema !== void 0 ? schema : null,
1069
+ videoConfigValues: videoConfigIdentifierValues,
997
1070
  });
998
1071
  newValueStrings.push(recast.print(nextExpression).code);
999
1072
  prop.setExpression(nextExpression);
@@ -1028,12 +1101,13 @@ const updateSequenceKeyframesAst = ({ input, nodePath, updates, schema, }) => {
1028
1101
  };
1029
1102
  };
1030
1103
  exports.updateSequenceKeyframesAst = updateSequenceKeyframesAst;
1031
- const updateSequenceKeyframes = async ({ input, nodePath, updates, schema, prettierConfigOverride, }) => {
1104
+ const updateSequenceKeyframes = async ({ input, nodePath, updates, schema, prettierConfigOverride, videoConfigValues, }) => {
1032
1105
  const { serialized, oldValueStrings, newValueStrings, logLine, updatedNodePath, } = (0, exports.updateSequenceKeyframesAst)({
1033
1106
  input,
1034
1107
  nodePath,
1035
1108
  updates,
1036
1109
  schema,
1110
+ videoConfigValues,
1037
1111
  });
1038
1112
  const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
1039
1113
  input: serialized,
@@ -1053,10 +1127,14 @@ const updateSequenceKeyframes = async ({ input, nodePath, updates, schema, prett
1053
1127
  };
1054
1128
  };
1055
1129
  exports.updateSequenceKeyframes = updateSequenceKeyframes;
1056
- const updateEffectKeyframesAst = ({ input, sequenceNodePath, effectIndex, updates, schema, }) => {
1130
+ const updateEffectKeyframesAst = ({ input, sequenceNodePath, effectIndex, updates, schema, videoConfigValues, }) => {
1057
1131
  var _a, _b;
1058
1132
  var _c, _d, _e;
1059
1133
  const ast = (0, parse_ast_1.parseAst)(input);
1134
+ const videoConfigIdentifierValues = (0, video_config_values_1.getVideoConfigIdentifierValues)({
1135
+ ast,
1136
+ videoConfigValues,
1137
+ });
1060
1138
  const jsxPath = (0, get_ast_node_path_1.getAstNodePath)(ast, sequenceNodePath);
1061
1139
  const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
1062
1140
  if (!jsx || !jsxPath) {
@@ -1096,6 +1174,7 @@ const updateEffectKeyframesAst = ({ input, sequenceNodePath, effectIndex, update
1096
1174
  key: update.key,
1097
1175
  operation: update.operation,
1098
1176
  schema: schema !== null && schema !== void 0 ? schema : null,
1177
+ videoConfigValues: videoConfigIdentifierValues,
1099
1178
  });
1100
1179
  newValueStrings.push(recast.print(nextExpression).code);
1101
1180
  prop.setExpression(nextExpression);
@@ -1131,13 +1210,14 @@ const updateEffectKeyframesAst = ({ input, sequenceNodePath, effectIndex, update
1131
1210
  };
1132
1211
  };
1133
1212
  exports.updateEffectKeyframesAst = updateEffectKeyframesAst;
1134
- const updateEffectKeyframes = async ({ input, sequenceNodePath, effectIndex, updates, schema, prettierConfigOverride, }) => {
1213
+ const updateEffectKeyframes = async ({ input, sequenceNodePath, effectIndex, updates, schema, prettierConfigOverride, videoConfigValues, }) => {
1135
1214
  const { serialized, oldValueStrings, newValueStrings, logLine, effectCallee, updatedSequenceNodePath, } = (0, exports.updateEffectKeyframesAst)({
1136
1215
  input,
1137
1216
  sequenceNodePath,
1138
1217
  effectIndex,
1139
1218
  updates,
1140
1219
  schema,
1220
+ videoConfigValues,
1141
1221
  });
1142
1222
  const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
1143
1223
  input: serialized,
@@ -1,11 +1,12 @@
1
- import type { JSXOpeningElement } from '@babel/types';
1
+ import type { JSXOpeningElement, Expression } from '@babel/types';
2
2
  import type { ExpressionKind } from 'ast-types/lib/gen/kinds';
3
3
  export declare const parseValueExpression: (value: unknown) => ExpressionKind;
4
- export declare const updateNestedProp: ({ node, parentKey, childKey, value, defaultValue, isDefault, }: {
4
+ export declare const updateNestedProp: ({ node, parentKey, childKey, value, defaultValue, isDefault, createValueExpression, }: {
5
5
  node: JSXOpeningElement;
6
6
  parentKey: string;
7
7
  childKey: string;
8
8
  value: unknown;
9
9
  defaultValue: unknown;
10
10
  isDefault: boolean;
11
+ createValueExpression: ((existing: Expression | null) => ExpressionKind) | null;
11
12
  }) => string;
@@ -116,12 +116,15 @@ const removeNestedProp = ({ attr, attrIndex, attributes, childKey, }) => {
116
116
  attributes.splice(attrIndex, 1);
117
117
  }
118
118
  };
119
- const setNestedProp = ({ attr, attributes, parentKey, childKey, value, }) => {
120
- const parsedValue = (0, exports.parseValueExpression)(value);
119
+ const setNestedProp = ({ attr, attributes, parentKey, childKey, value, createValueExpression, }) => {
120
+ var _a;
121
121
  if (attr) {
122
122
  const objExpr = getObjectExpression(attr);
123
123
  if (objExpr) {
124
124
  const { prop } = findObjectProperty(objExpr, childKey);
125
+ const parsedValue = createValueExpression
126
+ ? createValueExpression((_a = prop === null || prop === void 0 ? void 0 : prop.value) !== null && _a !== void 0 ? _a : null)
127
+ : (0, exports.parseValueExpression)(value);
125
128
  if (prop) {
126
129
  prop.value = parsedValue;
127
130
  }
@@ -131,6 +134,9 @@ const setNestedProp = ({ attr, attributes, parentKey, childKey, value, }) => {
131
134
  }
132
135
  }
133
136
  else {
137
+ const parsedValue = createValueExpression
138
+ ? createValueExpression(null)
139
+ : (0, exports.parseValueExpression)(value);
134
140
  const objExpr = b.objectExpression([
135
141
  b.objectProperty(b.identifier(childKey), parsedValue),
136
142
  ]);
@@ -138,7 +144,7 @@ const setNestedProp = ({ attr, attributes, parentKey, childKey, value, }) => {
138
144
  attributes.push(newAttr);
139
145
  }
140
146
  };
141
- const updateNestedProp = ({ node, parentKey, childKey, value, defaultValue, isDefault, }) => {
147
+ const updateNestedProp = ({ node, parentKey, childKey, value, defaultValue, isDefault, createValueExpression, }) => {
142
148
  if (!node.attributes) {
143
149
  node.attributes = [];
144
150
  }
@@ -149,7 +155,14 @@ const updateNestedProp = ({ node, parentKey, childKey, value, defaultValue, isDe
149
155
  removeNestedProp({ attr, attrIndex, attributes, childKey });
150
156
  }
151
157
  else {
152
- setNestedProp({ attr, attributes, parentKey, childKey, value });
158
+ setNestedProp({
159
+ attr,
160
+ attributes,
161
+ parentKey,
162
+ childKey,
163
+ value,
164
+ createValueExpression,
165
+ });
153
166
  }
154
167
  return oldValueString;
155
168
  };
@@ -1,5 +1,5 @@
1
1
  import type { GoogleFontSourceEdit } from '@remotion/studio-shared';
2
- import type { InteractivitySchema, SequenceNodePath } from 'remotion';
2
+ import type { InteractivitySchema, SequenceNodePath, VideoConfigValues } from 'remotion';
3
3
  export type SequencePropUpdate = {
4
4
  key: string;
5
5
  value: unknown;
@@ -14,6 +14,7 @@ export type SequencePropsNodeUpdate = {
14
14
  nodePath: SequenceNodePath;
15
15
  updates: SequencePropUpdate[];
16
16
  schema: InteractivitySchema;
17
+ videoConfigValues: VideoConfigValues | null;
17
18
  };
18
19
  export type SequencePropsNodeUpdateResult = {
19
20
  oldValueStrings: string[];
@@ -33,11 +34,12 @@ type UpdateSequencePropsResult = {
33
34
  logLine: number;
34
35
  removedProps: RemovedProp[];
35
36
  };
36
- export declare const updateSequencePropsAst: ({ input, nodePath, updates, schema, }: {
37
+ export declare const updateSequencePropsAst: ({ input, nodePath, updates, schema, videoConfigValues, }: {
37
38
  input: string;
38
39
  nodePath: SequenceNodePath;
39
40
  updates: SequencePropUpdate[];
40
41
  schema: InteractivitySchema;
42
+ videoConfigValues: VideoConfigValues | null;
41
43
  }) => {
42
44
  serialized: string;
43
45
  oldValueStrings: string[];
@@ -49,11 +51,12 @@ export declare const updateMultipleSequenceProps: ({ input, changes, prettierCon
49
51
  changes: SequencePropsNodeUpdate[];
50
52
  prettierConfigOverride: PrettierConfigOverride;
51
53
  }) => Promise<UpdateMultipleSequencePropsResult>;
52
- export declare const updateSequenceProps: ({ input, nodePath, updates, schema, prettierConfigOverride, }: {
54
+ export declare const updateSequenceProps: ({ input, nodePath, updates, schema, prettierConfigOverride, videoConfigValues, }: {
53
55
  input: string;
54
56
  nodePath: SequenceNodePath;
55
57
  updates: SequencePropUpdate[];
56
58
  schema: InteractivitySchema;
57
59
  prettierConfigOverride: PrettierConfigOverride;
60
+ videoConfigValues: VideoConfigValues | null;
58
61
  }) => Promise<UpdateSequencePropsResult>;
59
62
  export {};
@@ -36,6 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.updateSequenceProps = exports.updateMultipleSequenceProps = exports.updateSequencePropsAst = void 0;
37
37
  const recast = __importStar(require("recast"));
38
38
  const no_react_1 = require("remotion/no-react");
39
+ const video_config_numeric_expression_1 = require("../../helpers/video-config-numeric-expression");
40
+ const video_config_values_1 = require("../../helpers/video-config-values");
39
41
  const can_update_sequence_props_1 = require("../../preview-server/routes/can-update-sequence-props");
40
42
  const format_file_content_1 = require("../format-file-content");
41
43
  const parse_ast_1 = require("../parse-ast");
@@ -60,6 +62,7 @@ const removeVariantKey = ({ node, variantKey, }) => {
60
62
  value: undefined,
61
63
  defaultValue: null,
62
64
  isDefault: true,
65
+ createValueExpression: null,
63
66
  });
64
67
  };
65
68
  const snapshotTopLevelAttrs = (node) => {
@@ -471,17 +474,32 @@ const applyGoogleFontSourceEdits = ({ ast, updates, }) => {
471
474
  removeUnusedGoogleFontSourceEdits(ast);
472
475
  }
473
476
  };
474
- const updateSequencePropsNode = ({ jsxElement, updates, schema, }) => {
475
- var _a, _b, _c;
476
- var _d, _e;
477
+ const updateSequencePropsNode = ({ jsxElement, updates, schema, videoConfigValues, }) => {
478
+ var _a, _b, _c, _d;
479
+ var _e, _f;
477
480
  const node = jsxElement.openingElement;
478
- const logLine = (_d = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : 1;
481
+ const logLine = (_e = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _e !== void 0 ? _e : 1;
479
482
  const oldValueStrings = [];
480
483
  const initialAttrs = snapshotTopLevelAttrs(node);
481
484
  const updatedTopLevelKeys = new Set(updates.map(({ key }) => {
482
485
  const dot = key.indexOf('.');
483
486
  return dot === -1 ? key : key.slice(0, dot);
484
487
  }));
488
+ const createValueExpression = ({ existing, value, }) => {
489
+ if (existing === null || typeof value !== 'number') {
490
+ return (0, update_nested_prop_1.parseValueExpression)(value);
491
+ }
492
+ const expression = (0, video_config_numeric_expression_1.parseVideoConfigNumericExpression)({
493
+ node: existing,
494
+ videoConfigValues,
495
+ });
496
+ if (expression === null) {
497
+ return (0, update_nested_prop_1.parseValueExpression)(value);
498
+ }
499
+ return expression.value === value
500
+ ? existing
501
+ : (0, video_config_numeric_expression_1.updateVideoConfigNumericExpression)({ expression, value });
502
+ };
485
503
  for (const { key, value, defaultValue } of updates) {
486
504
  let oldValueString = '';
487
505
  if (key === 'children') {
@@ -504,6 +522,7 @@ const updateSequencePropsNode = ({ jsxElement, updates, schema, }) => {
504
522
  value,
505
523
  defaultValue,
506
524
  isDefault,
525
+ createValueExpression: (existing) => createValueExpression({ existing, value }),
507
526
  });
508
527
  }
509
528
  else {
@@ -540,7 +559,15 @@ const updateSequencePropsNode = ({ jsxElement, updates, schema, }) => {
540
559
  }
541
560
  }
542
561
  else {
543
- const parsed = (0, update_nested_prop_1.parseValueExpression)(value);
562
+ const existingExpression = (attr === null || attr === void 0 ? void 0 : attr.type) === 'JSXAttribute' &&
563
+ ((_d = attr.value) === null || _d === void 0 ? void 0 : _d.type) === 'JSXExpressionContainer' &&
564
+ attr.value.expression.type !== 'JSXEmptyExpression'
565
+ ? attr.value.expression
566
+ : null;
567
+ const parsed = createValueExpression({
568
+ existing: existingExpression,
569
+ value,
570
+ });
544
571
  const newValue = value === true ? null : b.jsxExpressionContainer(parsed);
545
572
  if (!attr || attr.type === 'JSXSpreadAttribute') {
546
573
  const newAttr = b.jsxAttribute(b.jsxIdentifier(key), newValue);
@@ -570,7 +597,7 @@ const updateSequencePropsNode = ({ jsxElement, updates, schema, }) => {
570
597
  }
571
598
  }
572
599
  const finalAttrNames = new Set();
573
- for (const a of (_e = node.attributes) !== null && _e !== void 0 ? _e : []) {
600
+ for (const a of (_f = node.attributes) !== null && _f !== void 0 ? _f : []) {
574
601
  if (a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier') {
575
602
  finalAttrNames.add(a.name.name);
576
603
  }
@@ -588,8 +615,12 @@ const updateSequencePropsNode = ({ jsxElement, updates, schema, }) => {
588
615
  removedProps,
589
616
  };
590
617
  };
591
- const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
618
+ const updateSequencePropsAst = ({ input, nodePath, updates, schema, videoConfigValues, }) => {
592
619
  const ast = (0, parse_ast_1.parseAst)(input);
620
+ const videoConfigIdentifierValues = (0, video_config_values_1.getVideoConfigIdentifierValues)({
621
+ ast,
622
+ videoConfigValues,
623
+ });
593
624
  const jsxElement = (0, can_update_sequence_props_1.findJsxElementNodeAtNodePath)(ast, nodePath);
594
625
  if (!jsxElement) {
595
626
  throw new Error('Could not find a JSX element at the specified line to update');
@@ -598,6 +629,7 @@ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
598
629
  jsxElement,
599
630
  updates,
600
631
  schema,
632
+ videoConfigValues: videoConfigIdentifierValues,
601
633
  });
602
634
  applyGoogleFontSourceEdits({ ast, updates });
603
635
  return {
@@ -611,13 +643,21 @@ exports.updateSequencePropsAst = updateSequencePropsAst;
611
643
  const updateMultipleSequenceProps = async ({ input, changes, prettierConfigOverride, }) => {
612
644
  const ast = (0, parse_ast_1.parseAst)(input);
613
645
  const allUpdates = [];
614
- const results = changes.map(({ nodePath, updates, schema }) => {
646
+ const results = changes.map(({ nodePath, updates, schema, videoConfigValues }) => {
615
647
  const jsxElement = (0, can_update_sequence_props_1.findJsxElementNodeAtNodePath)(ast, nodePath);
616
648
  if (!jsxElement) {
617
649
  throw new Error('Could not find a JSX element at the specified line to update');
618
650
  }
619
651
  allUpdates.push(...updates);
620
- return updateSequencePropsNode({ jsxElement, updates, schema });
652
+ return updateSequencePropsNode({
653
+ jsxElement,
654
+ updates,
655
+ schema,
656
+ videoConfigValues: (0, video_config_values_1.getVideoConfigIdentifierValues)({
657
+ ast,
658
+ videoConfigValues,
659
+ }),
660
+ });
621
661
  });
622
662
  applyGoogleFontSourceEdits({ ast, updates: allUpdates });
623
663
  const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
@@ -631,12 +671,13 @@ const updateMultipleSequenceProps = async ({ input, changes, prettierConfigOverr
631
671
  };
632
672
  };
633
673
  exports.updateMultipleSequenceProps = updateMultipleSequenceProps;
634
- const updateSequenceProps = async ({ input, nodePath, updates, schema, prettierConfigOverride, }) => {
674
+ const updateSequenceProps = async ({ input, nodePath, updates, schema, prettierConfigOverride, videoConfigValues, }) => {
635
675
  const { serialized, oldValueStrings, logLine, removedProps } = (0, exports.updateSequencePropsAst)({
636
676
  input,
637
677
  nodePath,
638
678
  updates,
639
679
  schema,
680
+ videoConfigValues,
640
681
  });
641
682
  const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
642
683
  input: serialized,
@@ -1,22 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInstalledInstallablePackages = void 0;
4
- const studio_shared_1 = require("@remotion/studio-shared");
5
4
  const get_installed_dependencies_1 = require("./get-installed-dependencies");
6
5
  const getInstalledInstallablePackages = (remotionRoot) => {
7
- const { dependencies, devDependencies, optionalDependencies } = (0, get_installed_dependencies_1.getInstalledDependencies)(remotionRoot);
8
- const installablePackages = [
6
+ const { dependencies, devDependencies, optionalDependencies, peerDependencies, } = (0, get_installed_dependencies_1.getInstalledDependencies)(remotionRoot);
7
+ return Array.from(new Set([
9
8
  ...dependencies,
10
9
  ...devDependencies,
11
10
  ...optionalDependencies,
12
- ];
13
- const remotionPackages = Object.entries(studio_shared_1.installableMap)
14
- .filter(([, _installable]) => _installable)
15
- .map(([pkg]) => (pkg === 'core' ? 'remotion' : `@remotion/${pkg}`))
16
- .filter((pkg) => installablePackages.includes(pkg));
17
- const installedExtraPackages = studio_shared_1.extraPackages
18
- .map((pkg) => pkg.name)
19
- .filter((pkg) => installablePackages.includes(pkg));
20
- return [...remotionPackages, ...installedExtraPackages];
11
+ ...peerDependencies,
12
+ ]));
21
13
  };
22
14
  exports.getInstalledInstallablePackages = getInstalledInstallablePackages;