@remotion/studio 4.0.473 → 4.0.475

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 (123) hide show
  1. package/dist/components/AssetSelectorItem.js +30 -6
  2. package/dist/components/Canvas.js +77 -0
  3. package/dist/components/ColorPicker/ColorPicker.js +4 -31
  4. package/dist/components/CompositionSelectorItem.js +4 -4
  5. package/dist/components/Editor.js +4 -1
  6. package/dist/components/Modals.js +2 -2
  7. package/dist/components/NewComposition/ComboBox.js +1 -0
  8. package/dist/components/NewComposition/InputDragger.d.ts +1 -0
  9. package/dist/components/NewComposition/InputDragger.js +9 -6
  10. package/dist/components/PreviewToolbar.js +2 -2
  11. package/dist/components/SelectedOutlineOverlay.d.ts +61 -33
  12. package/dist/components/SelectedOutlineOverlay.js +813 -351
  13. package/dist/components/SelectedOutlineUvControls.d.ts +17 -0
  14. package/dist/components/SelectedOutlineUvControls.js +167 -0
  15. package/dist/components/StudioCanvasCapture.d.ts +5 -0
  16. package/dist/components/StudioCanvasCapture.js +40 -0
  17. package/dist/components/Timeline/EasingEditorModal.d.ts +11 -0
  18. package/dist/components/Timeline/EasingEditorModal.js +247 -0
  19. package/dist/components/Timeline/KeyframeSettingsModal.js +5 -4
  20. package/dist/components/Timeline/SequencePropsObserver.js +3 -3
  21. package/dist/components/Timeline/Timeline.js +10 -7
  22. package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +7 -7
  23. package/dist/components/Timeline/TimelineClipboardKeybindings.js +19 -16
  24. package/dist/components/Timeline/TimelineDeleteKeybindings.js +71 -40
  25. package/dist/components/Timeline/TimelineDragHandler.js +2 -2
  26. package/dist/components/Timeline/TimelineEffectItem.js +8 -9
  27. package/dist/components/Timeline/TimelineEffectPropItem.js +18 -18
  28. package/dist/components/Timeline/TimelineExpandedKeyframeRow.d.ts +1 -0
  29. package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +7 -2
  30. package/dist/components/Timeline/TimelineExpandedSection.js +5 -5
  31. package/dist/components/Timeline/TimelineExpandedTrackKeyframes.js +1 -1
  32. package/dist/components/Timeline/TimelineHeightContainer.js +2 -0
  33. package/dist/components/Timeline/TimelineItemStack.js +3 -56
  34. package/dist/components/Timeline/TimelineKeyframeControls.d.ts +7 -0
  35. package/dist/components/Timeline/TimelineKeyframeControls.js +265 -68
  36. package/dist/components/Timeline/TimelineKeyframeDiamond.js +4 -3
  37. package/dist/components/Timeline/TimelineKeyframeEasingLine.d.ts +9 -0
  38. package/dist/components/Timeline/TimelineKeyframeEasingLine.js +245 -0
  39. package/dist/components/Timeline/TimelineKeyframeTracksContext.d.ts +7 -0
  40. package/dist/components/Timeline/TimelineKeyframeTracksContext.js +17 -0
  41. package/dist/components/Timeline/TimelineKeyframedValue.js +1 -1
  42. package/dist/components/Timeline/TimelineMediaInfo.js +4 -24
  43. package/dist/components/Timeline/TimelineNumberField.js +15 -7
  44. package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +4 -0
  45. package/dist/components/Timeline/TimelineRotationField.js +22 -34
  46. package/dist/components/Timeline/TimelineScaleField.js +16 -12
  47. package/dist/components/Timeline/TimelineScrollable.js +19 -3
  48. package/dist/components/Timeline/TimelineSelection.d.ts +82 -3
  49. package/dist/components/Timeline/TimelineSelection.js +312 -30
  50. package/dist/components/Timeline/TimelineSequence.js +23 -15
  51. package/dist/components/Timeline/TimelineSequenceItem.js +48 -73
  52. package/dist/components/Timeline/TimelineSequenceName.js +3 -17
  53. package/dist/components/Timeline/TimelineSequencePropItem.js +37 -37
  54. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +5 -5
  55. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +46 -44
  56. package/dist/components/Timeline/TimelineTimeIndicators.js +4 -2
  57. package/dist/components/Timeline/TimelineTransformOriginField.d.ts +11 -0
  58. package/dist/components/Timeline/TimelineTransformOriginField.js +138 -0
  59. package/dist/components/Timeline/TimelineTranslateField.js +24 -19
  60. package/dist/components/Timeline/TimelineUvCoordinateField.js +18 -12
  61. package/dist/components/Timeline/{apply-effect-response-to-code-values.d.ts → apply-effect-response-to-prop-statuses.d.ts} +1 -1
  62. package/dist/components/Timeline/{apply-effect-response-to-code-values.js → apply-effect-response-to-prop-statuses.js} +3 -3
  63. package/dist/components/Timeline/call-add-keyframe.d.ts +22 -5
  64. package/dist/components/Timeline/call-add-keyframe.js +71 -7
  65. package/dist/components/Timeline/call-delete-keyframe.d.ts +7 -7
  66. package/dist/components/Timeline/call-delete-keyframe.js +7 -7
  67. package/dist/components/Timeline/call-move-keyframe.d.ts +3 -3
  68. package/dist/components/Timeline/call-move-keyframe.js +3 -3
  69. package/dist/components/Timeline/call-update-keyframe-settings.d.ts +5 -5
  70. package/dist/components/Timeline/call-update-keyframe-settings.js +6 -6
  71. package/dist/components/Timeline/delete-selected-keyframe.d.ts +5 -5
  72. package/dist/components/Timeline/delete-selected-keyframe.js +5 -5
  73. package/dist/components/Timeline/delete-selected-timeline-item.d.ts +5 -5
  74. package/dist/components/Timeline/delete-selected-timeline-item.js +28 -16
  75. package/dist/components/Timeline/get-node-keyframes.d.ts +3 -3
  76. package/dist/components/Timeline/get-node-keyframes.js +4 -4
  77. package/dist/components/Timeline/get-timeline-easing-segments.d.ts +9 -0
  78. package/dist/components/Timeline/get-timeline-easing-segments.js +19 -0
  79. package/dist/components/Timeline/reset-selected-timeline-props.d.ts +7 -7
  80. package/dist/components/Timeline/reset-selected-timeline-props.js +23 -15
  81. package/dist/components/Timeline/save-effect-prop.d.ts +2 -2
  82. package/dist/components/Timeline/save-effect-prop.js +5 -5
  83. package/dist/components/Timeline/save-prop-queue.d.ts +3 -3
  84. package/dist/components/Timeline/save-prop-queue.js +3 -3
  85. package/dist/components/Timeline/save-sequence-prop.d.ts +3 -3
  86. package/dist/components/Timeline/save-sequence-prop.js +4 -4
  87. package/dist/components/Timeline/timeline-field-utils.d.ts +10 -0
  88. package/dist/components/Timeline/timeline-field-utils.js +26 -5
  89. package/dist/components/Timeline/timeline-rotation-utils.d.ts +2 -0
  90. package/dist/components/Timeline/timeline-rotation-utils.js +32 -0
  91. package/dist/components/Timeline/timeline-translate-utils.d.ts +1 -1
  92. package/dist/components/Timeline/timeline-translate-utils.js +4 -5
  93. package/dist/components/Timeline/transform-origin-utils.d.ts +24 -0
  94. package/dist/components/Timeline/transform-origin-utils.js +170 -0
  95. package/dist/components/Timeline/update-selected-easing.d.ts +35 -0
  96. package/dist/components/Timeline/update-selected-easing.js +133 -0
  97. package/dist/components/Timeline/use-expanded-track-keyframe-rows.d.ts +1 -0
  98. package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +35 -7
  99. package/dist/components/Timeline/use-sequence-props-subscription.js +3 -3
  100. package/dist/components/Timeline/use-timeline-height.js +3 -3
  101. package/dist/components/Timeline/use-timeline-keyframe-drag.js +13 -11
  102. package/dist/components/canvas-capture-enabled.d.ts +1 -0
  103. package/dist/components/canvas-capture-enabled.js +4 -0
  104. package/dist/components/effect-drag-and-drop.d.ts +11 -0
  105. package/dist/components/effect-drag-and-drop.js +73 -0
  106. package/dist/components/import-assets.d.ts +15 -0
  107. package/dist/components/import-assets.js +63 -1
  108. package/dist/components/selected-outline-geometry.d.ts +20 -0
  109. package/dist/components/selected-outline-geometry.js +18 -0
  110. package/dist/components/selected-outline-uv.d.ts +46 -0
  111. package/dist/components/selected-outline-uv.js +240 -0
  112. package/dist/esm/{chunk-q0jkt0zq.js → chunk-qaqqvw4q.js} +8096 -5307
  113. package/dist/esm/internals.mjs +8096 -5307
  114. package/dist/esm/previewEntry.mjs +8106 -5317
  115. package/dist/esm/renderEntry.mjs +1 -1
  116. package/dist/helpers/colors.d.ts +0 -1
  117. package/dist/helpers/colors.js +1 -2
  118. package/dist/helpers/timeline-layout.d.ts +6 -6
  119. package/dist/helpers/timeline-layout.js +5 -5
  120. package/dist/state/modals.d.ts +2 -4
  121. package/package.json +11 -10
  122. package/dist/components/NewComposition/DeleteStaticFile.d.ts +0 -4
  123. package/dist/components/NewComposition/DeleteStaticFile.js +0 -44
@@ -7,8 +7,15 @@ const save_effect_prop_1 = require("./save-effect-prop");
7
7
  const save_sequence_prop_1 = require("./save-sequence-prop");
8
8
  const isPropResetSelection = (selection) => selection.type === 'sequence-prop' ||
9
9
  selection.type === 'sequence-effect-prop';
10
+ function assertPropResetSelections(selections) {
11
+ for (const selection of selections) {
12
+ if (!isPropResetSelection(selection)) {
13
+ throw new Error(`Assertion failed: Cannot reset timeline selection of type ${selection.type}`);
14
+ }
15
+ }
16
+ }
10
17
  const isVisibleFieldSchema = (fieldSchema) => fieldSchema !== undefined && fieldSchema.type !== 'hidden';
11
- const isNonDefaultCodeValue = ({ codeValue, defaultValue, }) => JSON.stringify(codeValue !== null && codeValue !== void 0 ? codeValue : defaultValue) !== JSON.stringify(defaultValue);
18
+ const isNonDefaultCodeValue = ({ propStatus, defaultValue, }) => JSON.stringify(propStatus !== null && propStatus !== void 0 ? propStatus : defaultValue) !== JSON.stringify(defaultValue);
12
19
  const isResettablePropStatus = ({ propStatus, defaultValue, }) => {
13
20
  if (!propStatus || propStatus.status === 'computed') {
14
21
  return false;
@@ -20,25 +27,26 @@ const isResettablePropStatus = ({ propStatus, defaultValue, }) => {
20
27
  return true;
21
28
  }
22
29
  return isNonDefaultCodeValue({
23
- codeValue: propStatus.codeValue,
30
+ propStatus: propStatus.codeValue,
24
31
  defaultValue,
25
32
  });
26
33
  };
27
34
  const getDefaultValue = (fieldSchema) => fieldSchema.default !== undefined
28
35
  ? JSON.stringify(fieldSchema.default)
29
36
  : null;
30
- const getTimelinePropResetTargets = ({ selections, sequences, overrideIdsToNodePaths, codeValues, }) => {
37
+ const getTimelinePropResetTargets = ({ selections, sequences, overrideIdsToNodePaths, propStatuses, }) => {
31
38
  var _a;
32
39
  var _b;
33
- const firstSelection = selections[0];
34
- if (!firstSelection || !isPropResetSelection(firstSelection)) {
40
+ const propSelections = selections.filter(isPropResetSelection);
41
+ if (propSelections.length === 0) {
35
42
  return null;
36
43
  }
44
+ if (propSelections.length !== selections.length) {
45
+ return null;
46
+ }
47
+ assertPropResetSelections(selections);
37
48
  const resetTargets = [];
38
49
  for (const selection of selections) {
39
- if (!isPropResetSelection(selection)) {
40
- throw new Error(`Assertion failed: Cannot reset timeline selections of different types (${firstSelection.type}, ${selection.type})`);
41
- }
42
50
  const track = (0, find_track_for_node_path_info_1.findTrackForNodePathInfo)({
43
51
  sequences,
44
52
  overrideIdsToNodePaths,
@@ -54,7 +62,7 @@ const getTimelinePropResetTargets = ({ selections, sequences, overrideIdsToNodeP
54
62
  continue;
55
63
  }
56
64
  const sequenceFieldSchema = sequence.controls.schema[selection.key];
57
- const sequencePropStatus = (_a = remotion_1.Internals.getCodeValuesCtx(codeValues, nodePath)) === null || _a === void 0 ? void 0 : _a[selection.key];
65
+ const sequencePropStatus = (_a = remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath)) === null || _a === void 0 ? void 0 : _a[selection.key];
58
66
  if (!isVisibleFieldSchema(sequenceFieldSchema) ||
59
67
  !isResettablePropStatus({
60
68
  propStatus: sequencePropStatus,
@@ -75,8 +83,8 @@ const getTimelinePropResetTargets = ({ selections, sequences, overrideIdsToNodeP
75
83
  }
76
84
  const effect = sequence.effects[selection.i];
77
85
  const fieldSchema = effect === null || effect === void 0 ? void 0 : effect.schema[selection.key];
78
- const effectStatus = remotion_1.Internals.getEffectCodeValuesCtx({
79
- codeValues,
86
+ const effectStatus = remotion_1.Internals.getEffectPropStatusesCtx({
87
+ propStatuses,
80
88
  nodePath,
81
89
  effectIndex: selection.i,
82
90
  });
@@ -105,12 +113,12 @@ const getTimelinePropResetTargets = ({ selections, sequences, overrideIdsToNodeP
105
113
  return resetTargets;
106
114
  };
107
115
  exports.getTimelinePropResetTargets = getTimelinePropResetTargets;
108
- const resetSelectedTimelineProps = ({ selections, sequences, overrideIdsToNodePaths, codeValues, setCodeValues, clientId, }) => {
116
+ const resetSelectedTimelineProps = ({ selections, sequences, overrideIdsToNodePaths, propStatuses, setPropStatuses, clientId, }) => {
109
117
  const resetTargets = (0, exports.getTimelinePropResetTargets)({
110
118
  selections,
111
119
  sequences,
112
120
  overrideIdsToNodePaths,
113
- codeValues,
121
+ propStatuses,
114
122
  });
115
123
  if (resetTargets === null || resetTargets.length === 0) {
116
124
  return null;
@@ -128,7 +136,7 @@ const resetSelectedTimelineProps = ({ selections, sequences, overrideIdsToNodePa
128
136
  defaultValue: target.defaultValue,
129
137
  schema: target.schema,
130
138
  })),
131
- setCodeValues,
139
+ setPropStatuses,
132
140
  clientId,
133
141
  undoLabel: sequencePropTargets.length > 1
134
142
  ? 'Reset selected sequence props'
@@ -148,7 +156,7 @@ const resetSelectedTimelineProps = ({ selections, sequences, overrideIdsToNodePa
148
156
  value: target.value,
149
157
  defaultValue: target.defaultValue,
150
158
  schema: target.schema,
151
- setCodeValues,
159
+ setPropStatuses,
152
160
  clientId,
153
161
  }));
154
162
  }
@@ -1,6 +1,6 @@
1
1
  import { type EffectClipboardParam } from '@remotion/studio-shared';
2
2
  import type { SequencePropsSubscriptionKey, SequenceSchema } from 'remotion';
3
- import type { SetCodeValues } from './save-sequence-prop';
3
+ import type { SetPropStatuses } from './save-sequence-prop';
4
4
  type SaveEffectPropBase = {
5
5
  fileName: string;
6
6
  nodePath: SequencePropsSubscriptionKey;
@@ -8,7 +8,7 @@ type SaveEffectPropBase = {
8
8
  fieldKey: string;
9
9
  defaultValue: string | null;
10
10
  schema: SequenceSchema;
11
- setCodeValues: SetCodeValues;
11
+ setPropStatuses: SetPropStatuses;
12
12
  clientId: string;
13
13
  };
14
14
  type SaveEffectPropValue = SaveEffectPropBase & {
@@ -3,23 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.saveEffectProp = void 0;
4
4
  const studio_shared_1 = require("@remotion/studio-shared");
5
5
  const call_api_1 = require("../call-api");
6
- const apply_effect_response_to_code_values_1 = require("./apply-effect-response-to-code-values");
6
+ const apply_effect_response_to_prop_statuses_1 = require("./apply-effect-response-to-prop-statuses");
7
7
  const save_prop_queue_1 = require("./save-prop-queue");
8
8
  const saveEffectProp = (input) => {
9
- const { fileName, nodePath, effectIndex, fieldKey, defaultValue, schema, setCodeValues, clientId, } = input;
9
+ const { fileName, nodePath, effectIndex, fieldKey, defaultValue, schema, setPropStatuses, clientId, } = input;
10
10
  return (0, save_prop_queue_1.enqueueSavePropChange)({
11
11
  nodePath,
12
- setCodeValues,
12
+ setPropStatuses,
13
13
  applyOptimistic: (prev) => input.type === 'effect-param'
14
14
  ? prev
15
- : (0, studio_shared_1.optimisticUpdateForEffectCodeValues)({
15
+ : (0, studio_shared_1.optimisticUpdateForEffectPropStatuses)({
16
16
  previous: prev,
17
17
  effectIndex,
18
18
  fieldKey,
19
19
  value: input.value,
20
20
  schema,
21
21
  }),
22
- applyServerResponse: (prev, response) => (0, apply_effect_response_to_code_values_1.applyEffectResponseToCodeValues)({ previous: prev, response }),
22
+ applyServerResponse: (prev, response) => (0, apply_effect_response_to_prop_statuses_1.applyEffectResponseToPropStatuses)({ previous: prev, response }),
23
23
  apiCall: () => (0, call_api_1.callApi)('/api/save-effect-props', input.type === 'effect-param'
24
24
  ? {
25
25
  type: 'effect-param',
@@ -1,12 +1,12 @@
1
1
  import type { CanUpdateSequencePropsResponse, SequencePropsSubscriptionKey } from 'remotion';
2
- type SetCodeValues = (nodePath: SequencePropsSubscriptionKey, values: (prev: CanUpdateSequencePropsResponse) => CanUpdateSequencePropsResponse) => void;
2
+ type SetPropStatuses = (nodePath: SequencePropsSubscriptionKey, values: (prev: CanUpdateSequencePropsResponse) => CanUpdateSequencePropsResponse) => void;
3
3
  export type EnqueueSaveOptions<TResponse> = {
4
4
  nodePath: SequencePropsSubscriptionKey;
5
- setCodeValues: SetCodeValues;
5
+ setPropStatuses: SetPropStatuses;
6
6
  applyOptimistic: (prev: CanUpdateSequencePropsResponse) => CanUpdateSequencePropsResponse;
7
7
  applyServerResponse?: (prev: CanUpdateSequencePropsResponse, response: TResponse) => CanUpdateSequencePropsResponse;
8
8
  apiCall: () => Promise<TResponse>;
9
9
  errorLabel: string;
10
10
  };
11
- export declare const enqueueSavePropChange: <TResponse>({ nodePath, setCodeValues, applyOptimistic, applyServerResponse, apiCall, errorLabel, }: EnqueueSaveOptions<TResponse>) => Promise<void>;
11
+ export declare const enqueueSavePropChange: <TResponse>({ nodePath, setPropStatuses, applyOptimistic, applyServerResponse, apiCall, errorLabel, }: EnqueueSaveOptions<TResponse>) => Promise<void>;
12
12
  export {};
@@ -19,12 +19,12 @@ const dropQueue = (nodePath, q) => {
19
19
  queues.delete(key);
20
20
  }
21
21
  };
22
- const enqueueSavePropChange = ({ nodePath, setCodeValues, applyOptimistic, applyServerResponse, apiCall, errorLabel, }) => {
22
+ const enqueueSavePropChange = ({ nodePath, setPropStatuses, applyOptimistic, applyServerResponse, apiCall, errorLabel, }) => {
23
23
  const q = getQueue(nodePath);
24
24
  if (q.cancelled) {
25
25
  return Promise.resolve();
26
26
  }
27
- setCodeValues(nodePath, (prev) => {
27
+ setPropStatuses(nodePath, (prev) => {
28
28
  return applyOptimistic(prev);
29
29
  });
30
30
  const myQueue = q;
@@ -40,7 +40,7 @@ const enqueueSavePropChange = ({ nodePath, setCodeValues, applyOptimistic, apply
40
40
  // If nothing more is queued, reset baseline so the next round starts fresh.
41
41
  if (myQueue.chain === next) {
42
42
  if (applyServerResponse) {
43
- setCodeValues(nodePath, (prev) => applyServerResponse(prev, response));
43
+ setPropStatuses(nodePath, (prev) => applyServerResponse(prev, response));
44
44
  }
45
45
  dropQueue(nodePath, myQueue);
46
46
  }
@@ -1,5 +1,5 @@
1
1
  import type { CanUpdateSequencePropsResponse, SequencePropsSubscriptionKey, SequenceSchema } from 'remotion';
2
- export type SetCodeValues = (nodePath: SequencePropsSubscriptionKey, values: (prev: CanUpdateSequencePropsResponse) => CanUpdateSequencePropsResponse) => void;
2
+ export type SetPropStatuses = (nodePath: SequencePropsSubscriptionKey, values: (prev: CanUpdateSequencePropsResponse) => CanUpdateSequencePropsResponse) => void;
3
3
  export type SaveSequencePropChange = {
4
4
  fileName: string;
5
5
  nodePath: SequencePropsSubscriptionKey;
@@ -10,10 +10,10 @@ export type SaveSequencePropChange = {
10
10
  };
11
11
  type SaveSequencePropsOptions = {
12
12
  changes: SaveSequencePropChange[];
13
- setCodeValues: SetCodeValues;
13
+ setPropStatuses: SetPropStatuses;
14
14
  clientId: string;
15
15
  undoLabel: string;
16
16
  redoLabel: string;
17
17
  };
18
- export declare const saveSequenceProps: ({ changes, setCodeValues, clientId, undoLabel, redoLabel, }: SaveSequencePropsOptions) => Promise<void>;
18
+ export declare const saveSequenceProps: ({ changes, setPropStatuses, clientId, undoLabel, redoLabel, }: SaveSequencePropsOptions) => Promise<void>;
19
19
  export {};
@@ -4,7 +4,7 @@ exports.saveSequenceProps = void 0;
4
4
  const studio_shared_1 = require("@remotion/studio-shared");
5
5
  const call_api_1 = require("../call-api");
6
6
  const save_prop_queue_1 = require("./save-prop-queue");
7
- const saveSequenceProps = ({ changes, setCodeValues, clientId, undoLabel, redoLabel, }) => {
7
+ const saveSequenceProps = ({ changes, setPropStatuses, clientId, undoLabel, redoLabel, }) => {
8
8
  if (changes.length === 0) {
9
9
  return Promise.resolve();
10
10
  }
@@ -15,8 +15,8 @@ const saveSequenceProps = ({ changes, setCodeValues, clientId, undoLabel, redoLa
15
15
  }
16
16
  return (0, save_prop_queue_1.enqueueSavePropChange)({
17
17
  nodePath: change.nodePath,
18
- setCodeValues,
19
- applyOptimistic: (prev) => (0, studio_shared_1.optimisticUpdateForCodeValues)({
18
+ setPropStatuses,
19
+ applyOptimistic: (prev) => (0, studio_shared_1.optimisticUpdateForPropStatuses)({
20
20
  previous: prev,
21
21
  fieldKey: change.fieldKey,
22
22
  value: change.value,
@@ -41,7 +41,7 @@ const saveSequenceProps = ({ changes, setCodeValues, clientId, undoLabel, redoLa
41
41
  });
42
42
  }
43
43
  for (const change of changes) {
44
- setCodeValues(change.nodePath, (prev) => (0, studio_shared_1.optimisticUpdateForCodeValues)({
44
+ setPropStatuses(change.nodePath, (prev) => (0, studio_shared_1.optimisticUpdateForPropStatuses)({
45
45
  previous: prev,
46
46
  fieldKey: change.fieldKey,
47
47
  value: change.value,
@@ -1,3 +1,13 @@
1
1
  export declare const getDecimalPlaces: (num: number) => number;
2
+ export declare const getTimelineDisplayDecimalPlaces: ({ defaultDecimalPlaces, step, }: {
3
+ readonly defaultDecimalPlaces: number;
4
+ readonly step: number | undefined;
5
+ }) => number;
6
+ export declare const roundToDecimalPlaces: (value: number, decimalPlaces: number) => number;
7
+ export declare const formatTimelineNumber: ({ decimalPlaces, fixed, value, }: {
8
+ readonly decimalPlaces: number;
9
+ readonly fixed: boolean;
10
+ readonly value: string | number;
11
+ }) => string;
2
12
  export declare const normalizeTimelineNumber: (value: number) => number;
3
13
  export declare const draggerStyle: React.CSSProperties;
@@ -1,14 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.draggerStyle = exports.normalizeTimelineNumber = exports.getDecimalPlaces = void 0;
3
+ exports.draggerStyle = exports.normalizeTimelineNumber = exports.formatTimelineNumber = exports.roundToDecimalPlaces = exports.getTimelineDisplayDecimalPlaces = exports.getDecimalPlaces = void 0;
4
4
  const getDecimalPlaces = (num) => {
5
- const str = String(num);
6
- const decimalIndex = str.indexOf('.');
7
- return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1;
5
+ const [coefficient, exponent] = String(num).toLowerCase().split('e');
6
+ const decimalIndex = coefficient.indexOf('.');
7
+ const coefficientDecimals = decimalIndex === -1 ? 0 : coefficient.length - decimalIndex - 1;
8
+ if (exponent === undefined) {
9
+ return coefficientDecimals;
10
+ }
11
+ return Math.max(0, coefficientDecimals - Number(exponent));
8
12
  };
9
13
  exports.getDecimalPlaces = getDecimalPlaces;
14
+ const getTimelineDisplayDecimalPlaces = ({ defaultDecimalPlaces, step, }) => {
15
+ return Math.max(defaultDecimalPlaces, step === undefined ? 0 : (0, exports.getDecimalPlaces)(step));
16
+ };
17
+ exports.getTimelineDisplayDecimalPlaces = getTimelineDisplayDecimalPlaces;
18
+ const roundToDecimalPlaces = (value, decimalPlaces) => {
19
+ const factor = 10 ** decimalPlaces;
20
+ const rounded = Math.round(value * factor) / factor;
21
+ return Object.is(rounded, -0) ? 0 : rounded;
22
+ };
23
+ exports.roundToDecimalPlaces = roundToDecimalPlaces;
24
+ const formatTimelineNumber = ({ decimalPlaces, fixed, value, }) => {
25
+ const rounded = (0, exports.roundToDecimalPlaces)(Number(value), decimalPlaces);
26
+ return fixed && decimalPlaces > 0
27
+ ? rounded.toFixed(decimalPlaces)
28
+ : String(rounded);
29
+ };
30
+ exports.formatTimelineNumber = formatTimelineNumber;
10
31
  const normalizeTimelineNumber = (value) => {
11
- return Math.round(value * 1000000) / 1000000;
32
+ return (0, exports.roundToDecimalPlaces)(value, 6);
12
33
  };
13
34
  exports.normalizeTimelineNumber = normalizeTimelineNumber;
14
35
  exports.draggerStyle = {
@@ -0,0 +1,2 @@
1
+ export declare const parseCssRotationToDegrees: (value: string) => number;
2
+ export declare const serializeCssRotation: (value: number) => string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeCssRotation = exports.parseCssRotationToDegrees = void 0;
4
+ const timeline_field_utils_1 = require("./timeline-field-utils");
5
+ const unitPattern = /^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/;
6
+ const unitToDegrees = {
7
+ deg: 1,
8
+ rad: 180 / Math.PI,
9
+ turn: 360,
10
+ grad: 360 / 400,
11
+ };
12
+ const parseCssRotationToDegrees = (value) => {
13
+ const match = value.trim().match(unitPattern);
14
+ if (match) {
15
+ return (0, timeline_field_utils_1.normalizeTimelineNumber)(Number(match[1]) * unitToDegrees[match[2]]);
16
+ }
17
+ if (typeof DOMMatrix === 'undefined') {
18
+ return 0;
19
+ }
20
+ try {
21
+ const m = new DOMMatrix(`rotate(${value})`);
22
+ return (0, timeline_field_utils_1.normalizeTimelineNumber)(Math.atan2(m.b, m.a) * (180 / Math.PI));
23
+ }
24
+ catch (_a) {
25
+ return 0;
26
+ }
27
+ };
28
+ exports.parseCssRotationToDegrees = parseCssRotationToDegrees;
29
+ const serializeCssRotation = (value) => {
30
+ return `${(0, timeline_field_utils_1.normalizeTimelineNumber)(value)}deg`;
31
+ };
32
+ exports.serializeCssRotation = serializeCssRotation;
@@ -1,2 +1,2 @@
1
1
  export declare const parseTranslate: (value: string) => [number, number];
2
- export declare const serializeTranslate: (x: number, y: number) => string;
2
+ export declare const serializeTranslate: (x: number, y: number, decimalPlaces?: number) => string;
@@ -15,13 +15,12 @@ const parseTranslate = (value) => {
15
15
  ];
16
16
  };
17
17
  exports.parseTranslate = parseTranslate;
18
- const formatTranslateCoordinate = (value) => {
18
+ const formatTranslateCoordinate = (value, decimalPlaces) => {
19
19
  const normalized = (0, timeline_field_utils_1.normalizeTimelineNumber)(value);
20
- const factor = 10 ** translateDecimalPlaces;
21
- const rounded = Math.round(normalized * factor) / factor;
20
+ const rounded = (0, timeline_field_utils_1.roundToDecimalPlaces)(normalized, decimalPlaces);
22
21
  return String(Object.is(rounded, -0) ? 0 : rounded);
23
22
  };
24
- const serializeTranslate = (x, y) => {
25
- return `${formatTranslateCoordinate(x)}px ${formatTranslateCoordinate(y)}px`;
23
+ const serializeTranslate = (x, y, decimalPlaces = translateDecimalPlaces) => {
24
+ return `${formatTranslateCoordinate(x, decimalPlaces)}px ${formatTranslateCoordinate(y, decimalPlaces)}px`;
26
25
  };
27
26
  exports.serializeTranslate = serializeTranslate;
@@ -0,0 +1,24 @@
1
+ export type TransformOriginUnit = '%' | 'px';
2
+ export type TransformOriginAxisValue = {
3
+ readonly value: number;
4
+ readonly unit: TransformOriginUnit;
5
+ };
6
+ export type ParsedTransformOrigin = {
7
+ readonly x: TransformOriginAxisValue;
8
+ readonly y: TransformOriginAxisValue;
9
+ readonly z: string | null;
10
+ };
11
+ export declare const parseTransformOrigin: (value: unknown) => ParsedTransformOrigin | null;
12
+ export declare const axisValueToUv: (axis: TransformOriginAxisValue, size: number) => number | null;
13
+ export declare const parsedTransformOriginToUv: ({ parsed, width, height, }: {
14
+ readonly parsed: ParsedTransformOrigin;
15
+ readonly width: number;
16
+ readonly height: number;
17
+ }) => readonly [number, number] | null;
18
+ export declare const serializeTransformOrigin: ({ uv, z, decimalPlaces, }: {
19
+ readonly uv: readonly [number, number];
20
+ readonly z: string | null;
21
+ readonly decimalPlaces?: number | undefined;
22
+ }) => string;
23
+ export declare const parsedTransformOriginToPercent: (parsed: ParsedTransformOrigin) => readonly [number, number] | null;
24
+ export declare const transformOriginPercentToUv: (percent: readonly [number, number]) => readonly [number, number];
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformOriginPercentToUv = exports.parsedTransformOriginToPercent = exports.serializeTransformOrigin = exports.parsedTransformOriginToUv = exports.axisValueToUv = exports.parseTransformOrigin = void 0;
4
+ const timeline_field_utils_1 = require("./timeline-field-utils");
5
+ const cssNumberWithUnit = /^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)$/i;
6
+ const cssLength = /^([+-]?(?:\d+\.?\d*|\.\d+))[a-zA-Z]+$/;
7
+ const keywords = new Set(['left', 'center', 'right', 'top', 'bottom']);
8
+ const center = { value: 50, unit: '%' };
9
+ const keywordOptions = (keyword) => {
10
+ if (keyword === 'left') {
11
+ return [{ axis: 'x', value: { value: 0, unit: '%' } }];
12
+ }
13
+ if (keyword === 'right') {
14
+ return [{ axis: 'x', value: { value: 100, unit: '%' } }];
15
+ }
16
+ if (keyword === 'top') {
17
+ return [{ axis: 'y', value: { value: 0, unit: '%' } }];
18
+ }
19
+ if (keyword === 'bottom') {
20
+ return [{ axis: 'y', value: { value: 100, unit: '%' } }];
21
+ }
22
+ return [
23
+ { axis: 'x', value: center },
24
+ { axis: 'y', value: center },
25
+ ];
26
+ };
27
+ const parseLengthPercentage = (token) => {
28
+ const match = cssNumberWithUnit.exec(token);
29
+ if (!match) {
30
+ return null;
31
+ }
32
+ const value = Number(match[1]);
33
+ if (!Number.isFinite(value)) {
34
+ return null;
35
+ }
36
+ return { value, unit: match[2].toLowerCase() };
37
+ };
38
+ const parseToken = (token) => {
39
+ const lower = token.toLowerCase();
40
+ if (keywords.has(lower)) {
41
+ return { type: 'keyword', keyword: lower };
42
+ }
43
+ const value = parseLengthPercentage(token);
44
+ return value === null ? null : { type: 'length-percentage', value };
45
+ };
46
+ const parseTwoKeywords = (first, second) => {
47
+ var _a;
48
+ const candidates = [];
49
+ for (const firstOption of keywordOptions(first)) {
50
+ for (const secondOption of keywordOptions(second)) {
51
+ if (firstOption.axis === secondOption.axis) {
52
+ continue;
53
+ }
54
+ candidates.push(firstOption.axis === 'x'
55
+ ? [firstOption.value, secondOption.value]
56
+ : [secondOption.value, firstOption.value]);
57
+ }
58
+ }
59
+ return (_a = candidates[0]) !== null && _a !== void 0 ? _a : null;
60
+ };
61
+ const parseXY = (parts) => {
62
+ if (parts.length === 1) {
63
+ const token = parseToken(parts[0]);
64
+ if (token === null) {
65
+ return null;
66
+ }
67
+ if (token.type === 'length-percentage') {
68
+ return [token.value, center];
69
+ }
70
+ if (token.keyword === 'top' || token.keyword === 'bottom') {
71
+ return [center, keywordOptions(token.keyword)[0].value];
72
+ }
73
+ return [keywordOptions(token.keyword)[0].value, center];
74
+ }
75
+ const first = parseToken(parts[0]);
76
+ const second = parseToken(parts[1]);
77
+ if (first === null || second === null) {
78
+ return null;
79
+ }
80
+ if (first.type === 'length-percentage' &&
81
+ second.type === 'length-percentage') {
82
+ return [first.value, second.value];
83
+ }
84
+ if (first.type === 'keyword' && second.type === 'keyword') {
85
+ return parseTwoKeywords(first.keyword, second.keyword);
86
+ }
87
+ const keyword = first.type === 'keyword'
88
+ ? first
89
+ : second.type === 'keyword'
90
+ ? second
91
+ : null;
92
+ const length = first.type === 'length-percentage'
93
+ ? first.value
94
+ : second.type === 'length-percentage'
95
+ ? second.value
96
+ : null;
97
+ if (keyword === null || length === null) {
98
+ return null;
99
+ }
100
+ const keywordIsFirst = first.type === 'keyword';
101
+ if (keyword.keyword === 'left' || keyword.keyword === 'right') {
102
+ return keywordIsFirst
103
+ ? [keywordOptions(keyword.keyword)[0].value, length]
104
+ : null;
105
+ }
106
+ if (keyword.keyword === 'top' || keyword.keyword === 'bottom') {
107
+ return [length, keywordOptions(keyword.keyword)[0].value];
108
+ }
109
+ return keywordIsFirst ? [center, length] : [length, center];
110
+ };
111
+ const isSupportedZ = (token) => {
112
+ if (token.includes('%')) {
113
+ return false;
114
+ }
115
+ return cssLength.test(token);
116
+ };
117
+ const parseTransformOrigin = (value) => {
118
+ var _a;
119
+ if (typeof value !== 'string') {
120
+ return null;
121
+ }
122
+ const parts = value.trim().split(/\s+/);
123
+ if (parts.length < 1 || parts.length > 3 || parts[0] === '') {
124
+ return null;
125
+ }
126
+ const xy = parseXY(parts.length === 1 ? [parts[0]] : [parts[0], parts[1]]);
127
+ if (xy === null) {
128
+ return null;
129
+ }
130
+ const z = (_a = parts[2]) !== null && _a !== void 0 ? _a : null;
131
+ if (z !== null && !isSupportedZ(z)) {
132
+ return null;
133
+ }
134
+ return { x: xy[0], y: xy[1], z };
135
+ };
136
+ exports.parseTransformOrigin = parseTransformOrigin;
137
+ const axisValueToUv = (axis, size) => {
138
+ if (!Number.isFinite(size) || size <= 0) {
139
+ return null;
140
+ }
141
+ if (axis.unit === '%') {
142
+ return axis.value / 100;
143
+ }
144
+ return axis.value / size;
145
+ };
146
+ exports.axisValueToUv = axisValueToUv;
147
+ const parsedTransformOriginToUv = ({ parsed, width, height, }) => {
148
+ const x = (0, exports.axisValueToUv)(parsed.x, width);
149
+ const y = (0, exports.axisValueToUv)(parsed.y, height);
150
+ return x === null || y === null ? null : [x, y];
151
+ };
152
+ exports.parsedTransformOriginToUv = parsedTransformOriginToUv;
153
+ const formatPercent = (value, decimalPlaces) => {
154
+ const rounded = (0, timeline_field_utils_1.roundToDecimalPlaces)((0, timeline_field_utils_1.normalizeTimelineNumber)(value * 100), decimalPlaces);
155
+ return String(Object.is(rounded, -0) ? 0 : rounded);
156
+ };
157
+ const serializeTransformOrigin = ({ uv, z, decimalPlaces = 2, }) => {
158
+ const xy = `${formatPercent(uv[0], decimalPlaces)}% ${formatPercent(uv[1], decimalPlaces)}%`;
159
+ return z === null ? xy : `${xy} ${z}`;
160
+ };
161
+ exports.serializeTransformOrigin = serializeTransformOrigin;
162
+ const parsedTransformOriginToPercent = (parsed) => {
163
+ if (parsed.x.unit !== '%' || parsed.y.unit !== '%') {
164
+ return null;
165
+ }
166
+ return [parsed.x.value, parsed.y.value];
167
+ };
168
+ exports.parsedTransformOriginToPercent = parsedTransformOriginToPercent;
169
+ const transformOriginPercentToUv = (percent) => [percent[0] / 100, percent[1] / 100];
170
+ exports.transformOriginPercentToUv = transformOriginPercentToUv;
@@ -0,0 +1,35 @@
1
+ import type { OverrideIdToNodePaths, PropStatuses, TSequence } from 'remotion';
2
+ import type { SetPropStatuses } from './save-sequence-prop';
3
+ import type { TimelineEasingSelection, TimelineSelection } from './TimelineSelection';
4
+ export type EasingSelection = TimelineEasingSelection;
5
+ export type TimelineEasingValue = 'linear' | [number, number, number, number];
6
+ export declare const getEasingSelections: (selections: readonly TimelineSelection[]) => ({
7
+ readonly nodePathInfo: import("../../helpers/get-timeline-sequence-sort-key").SequenceNodePathInfo;
8
+ } & {
9
+ readonly type: "easing";
10
+ readonly fromFrame: number;
11
+ readonly toFrame: number;
12
+ readonly segmentIndex: number;
13
+ })[];
14
+ export declare const getTimelineEasingValueForSelection: ({ selection, sequences, overrideIdsToNodePaths, propStatuses, }: {
15
+ selection: {
16
+ readonly nodePathInfo: import("../../helpers/get-timeline-sequence-sort-key").SequenceNodePathInfo;
17
+ } & {
18
+ readonly type: "easing";
19
+ readonly fromFrame: number;
20
+ readonly toFrame: number;
21
+ readonly segmentIndex: number;
22
+ };
23
+ sequences: TSequence[];
24
+ overrideIdsToNodePaths: OverrideIdToNodePaths;
25
+ propStatuses: PropStatuses;
26
+ }) => TimelineEasingValue | null;
27
+ export declare const updateSelectedTimelineEasings: ({ selections, sequences, overrideIdsToNodePaths, propStatuses, setPropStatuses, clientId, easing, }: {
28
+ selections: readonly TimelineSelection[];
29
+ sequences: TSequence[];
30
+ overrideIdsToNodePaths: OverrideIdToNodePaths;
31
+ propStatuses: PropStatuses;
32
+ setPropStatuses: SetPropStatuses;
33
+ clientId: string;
34
+ easing: TimelineEasingValue;
35
+ }) => Promise<void> | null;