@remotion/studio 4.0.471 → 4.0.473

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 (192) hide show
  1. package/dist/api/rename-static-file.d.ts +6 -0
  2. package/dist/api/rename-static-file.js +18 -0
  3. package/dist/components/AssetSelector.js +55 -5
  4. package/dist/components/AssetSelectorItem.js +153 -27
  5. package/dist/components/Canvas.js +147 -0
  6. package/dist/components/CompositionSelectorItem.d.ts +1 -0
  7. package/dist/components/CompositionSelectorItem.js +12 -4
  8. package/dist/components/ConfirmationDialog-types.d.ts +8 -0
  9. package/dist/components/ConfirmationDialog-types.js +2 -0
  10. package/dist/components/ConfirmationDialog.d.ts +7 -0
  11. package/dist/components/ConfirmationDialog.js +103 -0
  12. package/dist/components/ContextMenu.d.ts +9 -1
  13. package/dist/components/ContextMenu.js +99 -47
  14. package/dist/components/CurrentAsset.d.ts +1 -0
  15. package/dist/components/CurrentAsset.js +13 -2
  16. package/dist/components/Editor.js +14 -6
  17. package/dist/components/EditorContent.js +15 -2
  18. package/dist/components/EditorContexts.js +2 -1
  19. package/dist/components/EditorRuler/Ruler.js +2 -0
  20. package/dist/components/ExplorerPanel.d.ts +0 -4
  21. package/dist/components/ExplorerPanel.js +8 -4
  22. package/dist/components/ExplorerPanelRef.d.ts +4 -0
  23. package/dist/components/ExplorerPanelRef.js +5 -0
  24. package/dist/components/FilePreview.d.ts +1 -1
  25. package/dist/components/InitialCompositionLoader.d.ts +0 -1
  26. package/dist/components/InitialCompositionLoader.js +5 -27
  27. package/dist/components/Menu/MenuItem.js +7 -1
  28. package/dist/components/Menu/SubMenu.js +5 -1
  29. package/dist/components/Menu/portals.js +17 -8
  30. package/dist/components/MenuToolbar.js +5 -1
  31. package/dist/components/ModalContainer.js +6 -1
  32. package/dist/components/Modals.js +8 -2
  33. package/dist/components/NewComposition/CodemodFooter.js +2 -2
  34. package/dist/components/NewComposition/ComboBox.js +8 -2
  35. package/dist/components/NewComposition/DeleteFolder.d.ts +6 -0
  36. package/dist/components/NewComposition/DeleteFolder.js +39 -0
  37. package/dist/components/NewComposition/DeleteStaticFile.d.ts +4 -0
  38. package/dist/components/NewComposition/DeleteStaticFile.js +44 -0
  39. package/dist/components/NewComposition/RenameFolder.d.ts +6 -0
  40. package/dist/components/NewComposition/RenameFolder.js +60 -0
  41. package/dist/components/NewComposition/RenameStaticFile.d.ts +4 -0
  42. package/dist/components/NewComposition/RenameStaticFile.js +118 -0
  43. package/dist/components/OptionsPanel.js +5 -1
  44. package/dist/components/OutlineToggle.d.ts +2 -0
  45. package/dist/components/OutlineToggle.js +20 -0
  46. package/dist/components/Preview.d.ts +0 -2
  47. package/dist/components/Preview.js +23 -33
  48. package/dist/components/PreviewToolbar.js +19 -6
  49. package/dist/components/RenderButton.js +8 -2
  50. package/dist/components/RenderPreview.js +2 -2
  51. package/dist/components/SelectedOutlineOverlay.d.ts +105 -4
  52. package/dist/components/SelectedOutlineOverlay.js +578 -59
  53. package/dist/components/ShowOutlinesProvider.d.ts +4 -0
  54. package/dist/components/ShowOutlinesProvider.js +24 -0
  55. package/dist/components/SizeSelector.js +3 -3
  56. package/dist/components/Splitter/SplitterContainer.js +9 -0
  57. package/dist/components/Splitter/SplitterHandle.js +65 -70
  58. package/dist/components/StaticFilePreview.js +2 -2
  59. package/dist/components/Timeline/KeyframeSettingsModal.d.ts +15 -0
  60. package/dist/components/Timeline/KeyframeSettingsModal.js +150 -0
  61. package/dist/components/Timeline/Timeline.js +50 -15
  62. package/dist/components/Timeline/TimelineArrayField.d.ts +9 -0
  63. package/dist/components/Timeline/TimelineArrayField.js +210 -0
  64. package/dist/components/Timeline/TimelineBooleanField.d.ts +2 -2
  65. package/dist/components/Timeline/TimelineBooleanField.js +2 -2
  66. package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +43 -0
  67. package/dist/components/Timeline/TimelineClipboardKeybindings.js +479 -0
  68. package/dist/components/Timeline/TimelineColorField.d.ts +2 -2
  69. package/dist/components/Timeline/TimelineColorField.js +2 -8
  70. package/dist/components/Timeline/TimelineDeleteKeybindings.js +12 -2
  71. package/dist/components/Timeline/TimelineEffectItem.js +3 -2
  72. package/dist/components/Timeline/TimelineEffectPropItem.js +146 -26
  73. package/dist/components/Timeline/TimelineEnumField.d.ts +2 -2
  74. package/dist/components/Timeline/TimelineEnumField.js +3 -3
  75. package/dist/components/Timeline/TimelineKeyframeControls.d.ts +4 -3
  76. package/dist/components/Timeline/TimelineKeyframeControls.js +41 -37
  77. package/dist/components/Timeline/TimelineKeyframeDiamond.js +24 -21
  78. package/dist/components/Timeline/TimelineKeyframeDiamondIcon.d.ts +6 -0
  79. package/dist/components/Timeline/TimelineKeyframeDiamondIcon.js +14 -0
  80. package/dist/components/Timeline/TimelineKeyframeDragState.d.ts +17 -0
  81. package/dist/components/Timeline/TimelineKeyframeDragState.js +39 -0
  82. package/dist/components/Timeline/TimelineKeyframedValue.d.ts +7 -2
  83. package/dist/components/Timeline/TimelineKeyframedValue.js +22 -8
  84. package/dist/components/Timeline/TimelineLayerEye.d.ts +1 -0
  85. package/dist/components/Timeline/TimelineLayerEye.js +8 -3
  86. package/dist/components/Timeline/TimelineList.js +2 -2
  87. package/dist/components/Timeline/TimelineMediaInfo.d.ts +0 -13
  88. package/dist/components/Timeline/TimelineMediaInfo.js +8 -73
  89. package/dist/components/Timeline/TimelineNumberField.d.ts +2 -2
  90. package/dist/components/Timeline/TimelineNumberField.js +7 -11
  91. package/dist/components/Timeline/TimelinePrimitiveFieldValue.d.ts +17 -0
  92. package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +53 -0
  93. package/dist/components/Timeline/TimelineRotationField.d.ts +2 -2
  94. package/dist/components/Timeline/TimelineRotationField.js +41 -24
  95. package/dist/components/Timeline/TimelineRowChrome.js +8 -7
  96. package/dist/components/Timeline/TimelineScaleField.d.ts +20 -0
  97. package/dist/components/Timeline/TimelineScaleField.js +314 -0
  98. package/dist/components/Timeline/TimelineSchemaField.d.ts +3 -2
  99. package/dist/components/Timeline/TimelineSchemaField.js +8 -42
  100. package/dist/components/Timeline/TimelineSelection.js +3 -2
  101. package/dist/components/Timeline/TimelineSequence.d.ts +1 -0
  102. package/dist/components/Timeline/TimelineSequence.js +51 -10
  103. package/dist/components/Timeline/TimelineSequenceFrame.js +1 -0
  104. package/dist/components/Timeline/TimelineSequenceItem.d.ts +1 -0
  105. package/dist/components/Timeline/TimelineSequenceItem.js +282 -28
  106. package/dist/components/Timeline/TimelineSequencePropItem.js +161 -35
  107. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +58 -0
  108. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +525 -0
  109. package/dist/components/Timeline/TimelineTrack.js +1 -1
  110. package/dist/components/Timeline/TimelineTranslateField.d.ts +2 -2
  111. package/dist/components/Timeline/TimelineTranslateField.js +21 -25
  112. package/dist/components/Timeline/TimelineUvCoordinateField.d.ts +2 -2
  113. package/dist/components/Timeline/TimelineUvCoordinateField.js +20 -26
  114. package/dist/components/Timeline/apply-effect-response-to-code-values.d.ts +5 -0
  115. package/dist/components/Timeline/apply-effect-response-to-code-values.js +19 -0
  116. package/dist/components/Timeline/call-add-keyframe.js +4 -0
  117. package/dist/components/Timeline/call-move-keyframe.d.ts +19 -0
  118. package/dist/components/Timeline/call-move-keyframe.js +71 -0
  119. package/dist/components/Timeline/call-update-keyframe-settings.d.ts +22 -0
  120. package/dist/components/Timeline/call-update-keyframe-settings.js +52 -0
  121. package/dist/components/Timeline/delete-selected-timeline-item.d.ts +7 -4
  122. package/dist/components/Timeline/delete-selected-timeline-item.js +33 -21
  123. package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +4 -2
  124. package/dist/components/Timeline/duplicate-selected-timeline-item.js +39 -34
  125. package/dist/components/Timeline/get-bounded-keyframe-drag-delta.d.ts +8 -0
  126. package/dist/components/Timeline/get-bounded-keyframe-drag-delta.js +12 -0
  127. package/dist/components/Timeline/get-keyframe-navigation.d.ts +2 -2
  128. package/dist/components/Timeline/get-keyframe-navigation.js +14 -6
  129. package/dist/components/Timeline/get-node-keyframes.d.ts +5 -2
  130. package/dist/components/Timeline/get-node-keyframes.js +38 -5
  131. package/dist/components/Timeline/get-timeline-keyframes.js +4 -4
  132. package/dist/components/Timeline/reset-selected-timeline-props.js +22 -8
  133. package/dist/components/Timeline/save-effect-prop.d.ts +14 -3
  134. package/dist/components/Timeline/save-effect-prop.js +36 -18
  135. package/dist/components/Timeline/save-prop-queue.d.ts +2 -1
  136. package/dist/components/Timeline/save-prop-queue.js +5 -2
  137. package/dist/components/Timeline/save-sequence-prop.d.ts +2 -7
  138. package/dist/components/Timeline/save-sequence-prop.js +33 -30
  139. package/dist/components/Timeline/should-clear-selection-on-pointer-down.d.ts +3 -0
  140. package/dist/components/Timeline/should-clear-selection-on-pointer-down.js +7 -0
  141. package/dist/components/Timeline/timeline-asset-link.d.ts +13 -0
  142. package/dist/components/Timeline/timeline-asset-link.js +37 -0
  143. package/dist/components/Timeline/timeline-field-utils.d.ts +1 -0
  144. package/dist/components/Timeline/timeline-field-utils.js +5 -1
  145. package/dist/components/Timeline/timeline-translate-utils.js +9 -2
  146. package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +7 -0
  147. package/dist/components/Timeline/use-timeline-keyframe-drag.d.ts +10 -0
  148. package/dist/components/Timeline/use-timeline-keyframe-drag.js +378 -0
  149. package/dist/components/TopPanel.d.ts +1 -1
  150. package/dist/components/folder-menu-items.d.ts +12 -0
  151. package/dist/components/folder-menu-items.js +147 -0
  152. package/dist/components/import-assets.d.ts +22 -0
  153. package/dist/components/import-assets.js +294 -0
  154. package/dist/components/load-canvas-content-from-url.d.ts +1 -0
  155. package/dist/components/load-canvas-content-from-url.js +9 -3
  156. package/dist/components/use-select-asset.d.ts +1 -0
  157. package/dist/components/use-select-asset.js +30 -0
  158. package/dist/error-overlay/error-origin.d.ts +3 -0
  159. package/dist/error-overlay/error-origin.js +42 -0
  160. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +6 -2
  161. package/dist/error-overlay/remotion-overlay/ErrorLoader.js +38 -0
  162. package/dist/error-overlay/remotion-overlay/ShortcutHint.js +1 -1
  163. package/dist/error-overlay/remotion-overlay/log-studio-error.d.ts +3 -0
  164. package/dist/error-overlay/remotion-overlay/log-studio-error.js +27 -0
  165. package/dist/esm/{chunk-z0z9d4r0.js → chunk-q0jkt0zq.js} +23062 -17350
  166. package/dist/esm/internals.mjs +23062 -17350
  167. package/dist/esm/previewEntry.mjs +22351 -16615
  168. package/dist/esm/renderEntry.mjs +1 -1
  169. package/dist/helpers/calculate-timeline.js +7 -3
  170. package/dist/helpers/create-folder-tree.js +1 -0
  171. package/dist/helpers/get-asset-metadata.js +2 -2
  172. package/dist/helpers/get-folder-id.d.ts +4 -0
  173. package/dist/helpers/get-folder-id.js +7 -0
  174. package/dist/helpers/get-preview-file-type.d.ts +2 -0
  175. package/dist/helpers/get-preview-file-type.js +33 -0
  176. package/dist/helpers/get-timeline-sequence-sort-key.d.ts +2 -0
  177. package/dist/helpers/install-required-package.d.ts +1 -0
  178. package/dist/helpers/install-required-package.js +39 -0
  179. package/dist/helpers/remote-asset-drag.d.ts +4 -0
  180. package/dist/helpers/remote-asset-drag.js +73 -0
  181. package/dist/helpers/timeline-layout.js +5 -1
  182. package/dist/helpers/use-asset-drag-events.d.ts +5 -2
  183. package/dist/helpers/use-asset-drag-events.js +13 -2
  184. package/dist/helpers/validate-folder-rename.d.ts +6 -0
  185. package/dist/helpers/validate-folder-rename.js +19 -0
  186. package/dist/hot-middleware-client/client.js +6 -0
  187. package/dist/state/editor-outlines.d.ts +8 -0
  188. package/dist/state/editor-outlines.js +18 -0
  189. package/dist/state/modals.d.ts +29 -2
  190. package/dist/state/scale-lock.d.ts +18 -0
  191. package/dist/state/scale-lock.js +59 -0
  192. package/package.json +10 -10
@@ -0,0 +1,525 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineSequenceRightEdgeDragHandle = exports.useTimelineSequenceFromDrag = exports.getTimelineSequenceFromDragTargets = exports.getTimelineSequenceDurationDragTargets = exports.getTimelineSequenceFromDragChanges = exports.getTimelineSequenceFromDragValue = exports.getTimelineSequenceDurationDragChanges = exports.getTimelineSequenceDurationDragValue = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const studio_shared_1 = require("@remotion/studio-shared");
6
+ const react_1 = require("react");
7
+ const remotion_1 = require("remotion");
8
+ const no_react_1 = require("remotion/no-react");
9
+ const calculate_timeline_1 = require("../../helpers/calculate-timeline");
10
+ const client_id_1 = require("../../helpers/client-id");
11
+ const timeline_layout_1 = require("../../helpers/timeline-layout");
12
+ const ForceSpecificCursor_1 = require("../ForceSpecificCursor");
13
+ const save_sequence_prop_1 = require("./save-sequence-prop");
14
+ const TimelineSelection_1 = require("./TimelineSelection");
15
+ const HANDLE_WIDTH = 6;
16
+ const baseStyle = {
17
+ position: 'absolute',
18
+ top: 0,
19
+ bottom: 0,
20
+ width: HANDLE_WIDTH,
21
+ cursor: 'ew-resize',
22
+ zIndex: 1,
23
+ touchAction: 'none',
24
+ };
25
+ const canUpdateDurationInFrames = ({ codeValues, nodePath, }) => {
26
+ var _a, _b;
27
+ const status = (_b = (_a = remotion_1.Internals.getCodeValuesCtx(codeValues, nodePath)) === null || _a === void 0 ? void 0 : _a.durationInFrames) === null || _b === void 0 ? void 0 : _b.status;
28
+ return status === 'static';
29
+ };
30
+ const canUpdateFrom = ({ codeValues, nodePath, }) => {
31
+ var _a, _b;
32
+ const status = (_b = (_a = remotion_1.Internals.getCodeValuesCtx(codeValues, nodePath)) === null || _a === void 0 ? void 0 : _a.from) === null || _b === void 0 ? void 0 : _b.status;
33
+ return status === 'static';
34
+ };
35
+ const isDurationDraggableSequence = (sequence) => {
36
+ return ((sequence.type === 'sequence' || sequence.type === 'image') &&
37
+ !sequence.loopDisplay &&
38
+ !sequence.isInsideSeries &&
39
+ Boolean(sequence.controls));
40
+ };
41
+ const isFromDraggableSequence = (sequence) => {
42
+ return (!sequence.loopDisplay &&
43
+ !sequence.isInsideSeries &&
44
+ Boolean(sequence.controls));
45
+ };
46
+ const getTimelineSequenceDurationDragValue = ({ initialDuration, deltaFrames, }) => Math.max(1, initialDuration + deltaFrames);
47
+ exports.getTimelineSequenceDurationDragValue = getTimelineSequenceDurationDragValue;
48
+ const getTimelineSequenceDurationDragChanges = ({ targets, deltaFrames, }) => {
49
+ return targets.flatMap((target) => {
50
+ const nextValue = (0, exports.getTimelineSequenceDurationDragValue)({
51
+ initialDuration: target.initialDuration,
52
+ deltaFrames,
53
+ });
54
+ if (nextValue === target.initialDuration) {
55
+ return [];
56
+ }
57
+ return [
58
+ {
59
+ fileName: target.fileName,
60
+ nodePath: target.nodePath,
61
+ fieldKey: 'durationInFrames',
62
+ value: nextValue,
63
+ defaultValue: null,
64
+ schema: no_react_1.NoReactInternals.sequenceSchema,
65
+ },
66
+ ];
67
+ });
68
+ };
69
+ exports.getTimelineSequenceDurationDragChanges = getTimelineSequenceDurationDragChanges;
70
+ const getTimelineSequenceFromDragValue = ({ initialFrom, deltaFrames, }) => initialFrom + deltaFrames;
71
+ exports.getTimelineSequenceFromDragValue = getTimelineSequenceFromDragValue;
72
+ const getTimelineSequenceFromDragChanges = ({ targets, deltaFrames, }) => {
73
+ return targets.flatMap((target) => {
74
+ const nextValue = (0, exports.getTimelineSequenceFromDragValue)({
75
+ initialFrom: target.initialFrom,
76
+ deltaFrames,
77
+ });
78
+ if (nextValue === target.initialFrom) {
79
+ return [];
80
+ }
81
+ return [
82
+ {
83
+ fileName: target.fileName,
84
+ nodePath: target.nodePath,
85
+ fieldKey: 'from',
86
+ value: nextValue,
87
+ defaultValue: '0',
88
+ schema: no_react_1.NoReactInternals.sequenceSchema,
89
+ },
90
+ ];
91
+ });
92
+ };
93
+ exports.getTimelineSequenceFromDragChanges = getTimelineSequenceFromDragChanges;
94
+ const findSequenceTrack = ({ tracks, nodePathInfo, }) => {
95
+ const key = (0, studio_shared_1.stringifySequenceSubscriptionKey)(nodePathInfo.sequenceSubscriptionKey);
96
+ return tracks.find((candidate) => {
97
+ if (candidate.nodePathInfo === null) {
98
+ return false;
99
+ }
100
+ return ((0, studio_shared_1.stringifySequenceSubscriptionKey)(candidate.nodePathInfo.sequenceSubscriptionKey) === key && candidate.nodePathInfo.index === nodePathInfo.index);
101
+ });
102
+ };
103
+ const getTimelineSequenceDurationDragTargets = ({ draggedNodePathInfo, selectedItems, sequences, overrideIdsToNodePaths, codeValues, }) => {
104
+ const draggedSelectionKey = (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(draggedNodePathInfo);
105
+ const selectedSequenceItems = selectedItems.filter((item) => item.type === 'sequence');
106
+ const draggedItemIsSelected = selectedSequenceItems.some((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo) ===
107
+ draggedSelectionKey);
108
+ if (draggedItemIsSelected &&
109
+ selectedSequenceItems.length !== selectedItems.length) {
110
+ return null;
111
+ }
112
+ const targetNodePathInfos = draggedItemIsSelected && selectedSequenceItems.length > 1
113
+ ? selectedSequenceItems.map((item) => item.nodePathInfo)
114
+ : [draggedNodePathInfo];
115
+ const tracks = (0, calculate_timeline_1.calculateTimeline)({ sequences, overrideIdsToNodePaths });
116
+ const targets = new Map();
117
+ for (const nodePathInfo of targetNodePathInfos) {
118
+ const track = findSequenceTrack({ tracks, nodePathInfo });
119
+ const originalSequence = track
120
+ ? sequences.find((sequence) => sequence.id === track.sequence.id)
121
+ : null;
122
+ if (!track ||
123
+ !originalSequence ||
124
+ !isDurationDraggableSequence(originalSequence)) {
125
+ return null;
126
+ }
127
+ const nodePath = nodePathInfo.sequenceSubscriptionKey;
128
+ if (!canUpdateDurationInFrames({ codeValues, nodePath })) {
129
+ return null;
130
+ }
131
+ const key = (0, studio_shared_1.stringifySequenceSubscriptionKey)(nodePath);
132
+ if (!targets.has(key)) {
133
+ targets.set(key, {
134
+ fileName: nodePath.absolutePath,
135
+ initialDuration: originalSequence.duration,
136
+ nodePath,
137
+ });
138
+ }
139
+ }
140
+ return [...targets.values()];
141
+ };
142
+ exports.getTimelineSequenceDurationDragTargets = getTimelineSequenceDurationDragTargets;
143
+ const getTimelineSequenceFromDragTargets = ({ draggedNodePathInfo, selectedItems, sequences, overrideIdsToNodePaths, codeValues, }) => {
144
+ const draggedSelectionKey = (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(draggedNodePathInfo);
145
+ const selectedSequenceItems = selectedItems.filter((item) => item.type === 'sequence');
146
+ const draggedItemIsSelected = selectedSequenceItems.some((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo) ===
147
+ draggedSelectionKey);
148
+ if (draggedItemIsSelected &&
149
+ selectedSequenceItems.length !== selectedItems.length) {
150
+ return null;
151
+ }
152
+ const targetNodePathInfos = draggedItemIsSelected && selectedSequenceItems.length > 1
153
+ ? selectedSequenceItems.map((item) => item.nodePathInfo)
154
+ : [draggedNodePathInfo];
155
+ const tracks = (0, calculate_timeline_1.calculateTimeline)({ sequences, overrideIdsToNodePaths });
156
+ const targets = new Map();
157
+ for (const nodePathInfo of targetNodePathInfos) {
158
+ const track = findSequenceTrack({ tracks, nodePathInfo });
159
+ const originalSequence = track
160
+ ? sequences.find((sequence) => sequence.id === track.sequence.id)
161
+ : null;
162
+ if (!track ||
163
+ !originalSequence ||
164
+ !isFromDraggableSequence(originalSequence)) {
165
+ return null;
166
+ }
167
+ const nodePath = nodePathInfo.sequenceSubscriptionKey;
168
+ if (!canUpdateFrom({ codeValues, nodePath })) {
169
+ return null;
170
+ }
171
+ const key = (0, studio_shared_1.stringifySequenceSubscriptionKey)(nodePath);
172
+ if (!targets.has(key)) {
173
+ targets.set(key, {
174
+ fileName: nodePath.absolutePath,
175
+ initialFrom: originalSequence.from,
176
+ nodePath,
177
+ });
178
+ }
179
+ }
180
+ return [...targets.values()];
181
+ };
182
+ exports.getTimelineSequenceFromDragTargets = getTimelineSequenceFromDragTargets;
183
+ const clearDurationDragOverrides = ({ clearDragOverrides, targets, }) => {
184
+ for (const target of targets) {
185
+ clearDragOverrides(target.nodePath);
186
+ }
187
+ };
188
+ const clearFromDragOverrides = ({ clearDragOverrides, targets, }) => {
189
+ for (const target of targets) {
190
+ clearDragOverrides(target.nodePath);
191
+ }
192
+ };
193
+ const useTimelineSequenceFromDrag = ({ nodePathInfo, windowWidth, timelineDurationInFrames, }) => {
194
+ const { setCodeValues, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
195
+ const { codeValues } = (0, react_1.useContext)(remotion_1.Internals.VisualModeCodeValuesContext);
196
+ const { sequences } = (0, react_1.useContext)(remotion_1.Internals.SequenceManager);
197
+ const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
198
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
199
+ const { selectedItems } = (0, TimelineSelection_1.useTimelineSelection)();
200
+ const [dragging, setDragging] = (0, react_1.useState)(false);
201
+ const dragStateRef = (0, react_1.useRef)(null);
202
+ const latestRef = (0, react_1.useRef)({
203
+ nodePathInfo,
204
+ setCodeValues,
205
+ setDragOverrides,
206
+ clearDragOverrides,
207
+ previewServerState,
208
+ codeValues,
209
+ sequences,
210
+ overrideIdToNodePathMappings,
211
+ selectedItems,
212
+ });
213
+ latestRef.current = {
214
+ nodePathInfo,
215
+ setCodeValues,
216
+ setDragOverrides,
217
+ clearDragOverrides,
218
+ previewServerState,
219
+ codeValues,
220
+ sequences,
221
+ overrideIdToNodePathMappings,
222
+ selectedItems,
223
+ };
224
+ const finishDrag = (0, react_1.useCallback)((commit) => {
225
+ const dragState = dragStateRef.current;
226
+ dragStateRef.current = null;
227
+ document.body.style.userSelect = '';
228
+ document.body.style.webkitUserSelect = '';
229
+ setDragging(false);
230
+ if (!dragState) {
231
+ return;
232
+ }
233
+ const { setCodeValues: latestSetCodeValues, clearDragOverrides: latestClear, previewServerState: latestServerState, } = latestRef.current;
234
+ const changes = (0, exports.getTimelineSequenceFromDragChanges)({
235
+ targets: dragState.targets,
236
+ deltaFrames: dragState.latestDeltaFrames,
237
+ });
238
+ if (!commit ||
239
+ latestServerState.type !== 'connected' ||
240
+ changes.length === 0) {
241
+ clearFromDragOverrides({
242
+ clearDragOverrides: latestClear,
243
+ targets: dragState.targets,
244
+ });
245
+ return;
246
+ }
247
+ const savePromise = (0, save_sequence_prop_1.saveSequenceProps)({
248
+ changes,
249
+ setCodeValues: latestSetCodeValues,
250
+ clientId: latestServerState.clientId,
251
+ undoLabel: changes.length > 1 ? 'Move selected sequences' : 'Move sequence',
252
+ redoLabel: changes.length > 1
253
+ ? 'Move selected sequences back'
254
+ : 'Move sequence back',
255
+ });
256
+ savePromise
257
+ .catch((err) => {
258
+ remotion_1.Internals.Log.error({ logLevel: 'error', tag: null }, 'Could not save from', err);
259
+ })
260
+ .finally(() => {
261
+ clearFromDragOverrides({
262
+ clearDragOverrides: latestClear,
263
+ targets: dragState.targets,
264
+ });
265
+ });
266
+ }, []);
267
+ const onPointerDown = (0, react_1.useCallback)((e) => {
268
+ if (e.button !== 0) {
269
+ return;
270
+ }
271
+ const pxPerFrame = timelineDurationInFrames > 0
272
+ ? (windowWidth - timeline_layout_1.TIMELINE_PADDING * 2) / timelineDurationInFrames
273
+ : 0;
274
+ if (pxPerFrame <= 0) {
275
+ return;
276
+ }
277
+ const { nodePathInfo: latestNodePathInfo, selectedItems: latestSelectedItems, sequences: latestSequences, overrideIdToNodePathMappings: latestOverrideIdsToNodePaths, codeValues: latestCodeValues, } = latestRef.current;
278
+ if (latestNodePathInfo === null) {
279
+ return;
280
+ }
281
+ const targets = (0, exports.getTimelineSequenceFromDragTargets)({
282
+ draggedNodePathInfo: latestNodePathInfo,
283
+ selectedItems: latestSelectedItems,
284
+ sequences: latestSequences,
285
+ overrideIdsToNodePaths: latestOverrideIdsToNodePaths,
286
+ codeValues: latestCodeValues,
287
+ });
288
+ if (targets === null || targets.length === 0) {
289
+ return;
290
+ }
291
+ e.preventDefault();
292
+ dragStateRef.current = {
293
+ initialClientX: e.clientX,
294
+ latestDeltaFrames: 0,
295
+ pxPerFrame,
296
+ pointerId: e.pointerId,
297
+ targets,
298
+ };
299
+ document.body.style.userSelect = 'none';
300
+ document.body.style.webkitUserSelect = 'none';
301
+ setDragging(true);
302
+ }, [timelineDurationInFrames, windowWidth]);
303
+ (0, react_1.useEffect)(() => {
304
+ if (!dragging) {
305
+ return;
306
+ }
307
+ const onMove = (e) => {
308
+ const dragState = dragStateRef.current;
309
+ if (!dragState || e.pointerId !== dragState.pointerId) {
310
+ return;
311
+ }
312
+ const dx = e.clientX - dragState.initialClientX;
313
+ const deltaFrames = Math.round(dx / dragState.pxPerFrame);
314
+ dragState.latestDeltaFrames = deltaFrames;
315
+ for (const target of dragState.targets) {
316
+ latestRef.current.setDragOverrides(target.nodePath, 'from', remotion_1.Internals.makeStaticDragOverride((0, exports.getTimelineSequenceFromDragValue)({
317
+ initialFrom: target.initialFrom,
318
+ deltaFrames,
319
+ })));
320
+ }
321
+ };
322
+ const onUp = (e) => {
323
+ const dragState = dragStateRef.current;
324
+ if (!dragState || e.pointerId !== dragState.pointerId) {
325
+ return;
326
+ }
327
+ finishDrag(true);
328
+ };
329
+ const onCancel = (e) => {
330
+ const dragState = dragStateRef.current;
331
+ if (!dragState || e.pointerId !== dragState.pointerId) {
332
+ return;
333
+ }
334
+ finishDrag(false);
335
+ };
336
+ const onWindowBlur = () => {
337
+ finishDrag(false);
338
+ };
339
+ window.addEventListener('pointermove', onMove);
340
+ window.addEventListener('pointerup', onUp);
341
+ window.addEventListener('pointercancel', onCancel);
342
+ window.addEventListener('blur', onWindowBlur);
343
+ return () => {
344
+ window.removeEventListener('pointermove', onMove);
345
+ window.removeEventListener('pointerup', onUp);
346
+ window.removeEventListener('pointercancel', onCancel);
347
+ window.removeEventListener('blur', onWindowBlur);
348
+ };
349
+ }, [dragging, finishDrag]);
350
+ return {
351
+ dragging,
352
+ onPointerDown,
353
+ };
354
+ };
355
+ exports.useTimelineSequenceFromDrag = useTimelineSequenceFromDrag;
356
+ const TimelineSequenceRightEdgeDragHandle = ({ nodePathInfo, windowWidth, timelineDurationInFrames }) => {
357
+ const { setCodeValues, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
358
+ const { codeValues } = (0, react_1.useContext)(remotion_1.Internals.VisualModeCodeValuesContext);
359
+ const { sequences } = (0, react_1.useContext)(remotion_1.Internals.SequenceManager);
360
+ const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
361
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
362
+ const { selectedItems } = (0, TimelineSelection_1.useTimelineSelection)();
363
+ const [dragging, setDragging] = (0, react_1.useState)(false);
364
+ const dragStateRef = (0, react_1.useRef)(null);
365
+ // Keep latest props/setters available to window listeners installed once at pointerdown.
366
+ const latestRef = (0, react_1.useRef)({
367
+ nodePathInfo,
368
+ setCodeValues,
369
+ setDragOverrides,
370
+ clearDragOverrides,
371
+ previewServerState,
372
+ codeValues,
373
+ sequences,
374
+ overrideIdToNodePathMappings,
375
+ selectedItems,
376
+ });
377
+ latestRef.current = {
378
+ nodePathInfo,
379
+ setCodeValues,
380
+ setDragOverrides,
381
+ clearDragOverrides,
382
+ previewServerState,
383
+ codeValues,
384
+ sequences,
385
+ overrideIdToNodePathMappings,
386
+ selectedItems,
387
+ };
388
+ const finishDrag = (0, react_1.useCallback)((commit) => {
389
+ const dragState = dragStateRef.current;
390
+ dragStateRef.current = null;
391
+ document.body.style.userSelect = '';
392
+ document.body.style.webkitUserSelect = '';
393
+ (0, ForceSpecificCursor_1.stopForcingSpecificCursor)();
394
+ setDragging(false);
395
+ if (!dragState) {
396
+ return;
397
+ }
398
+ const { setCodeValues: latestSetCodeValues, clearDragOverrides: latestClear, previewServerState: latestServerState, } = latestRef.current;
399
+ const changes = (0, exports.getTimelineSequenceDurationDragChanges)({
400
+ targets: dragState.targets,
401
+ deltaFrames: dragState.latestDeltaFrames,
402
+ });
403
+ if (!commit ||
404
+ latestServerState.type !== 'connected' ||
405
+ changes.length === 0) {
406
+ clearDurationDragOverrides({
407
+ clearDragOverrides: latestClear,
408
+ targets: dragState.targets,
409
+ });
410
+ return;
411
+ }
412
+ const savePromise = (0, save_sequence_prop_1.saveSequenceProps)({
413
+ changes,
414
+ setCodeValues: latestSetCodeValues,
415
+ clientId: latestServerState.clientId,
416
+ undoLabel: changes.length > 1 ? 'Resize selected sequences' : 'Resize sequence',
417
+ redoLabel: changes.length > 1
418
+ ? 'Resize selected sequences back'
419
+ : 'Resize sequence back',
420
+ });
421
+ savePromise
422
+ .catch((err) => {
423
+ remotion_1.Internals.Log.error({ logLevel: 'error', tag: null }, 'Could not save durationInFrames', err);
424
+ })
425
+ .finally(() => {
426
+ clearDurationDragOverrides({
427
+ clearDragOverrides: latestClear,
428
+ targets: dragState.targets,
429
+ });
430
+ });
431
+ }, []);
432
+ const onPointerDown = (0, react_1.useCallback)((e) => {
433
+ if (e.button !== 0) {
434
+ return;
435
+ }
436
+ const pxPerFrame = timelineDurationInFrames > 0
437
+ ? (windowWidth - timeline_layout_1.TIMELINE_PADDING * 2) / timelineDurationInFrames
438
+ : 0;
439
+ if (pxPerFrame <= 0) {
440
+ return;
441
+ }
442
+ const { nodePathInfo: latestNodePathInfo, selectedItems: latestSelectedItems, sequences: latestSequences, overrideIdToNodePathMappings: latestOverrideIdsToNodePaths, codeValues: latestCodeValues, } = latestRef.current;
443
+ const targets = (0, exports.getTimelineSequenceDurationDragTargets)({
444
+ draggedNodePathInfo: latestNodePathInfo,
445
+ selectedItems: latestSelectedItems,
446
+ sequences: latestSequences,
447
+ overrideIdsToNodePaths: latestOverrideIdsToNodePaths,
448
+ codeValues: latestCodeValues,
449
+ });
450
+ if (targets === null || targets.length === 0) {
451
+ return;
452
+ }
453
+ e.stopPropagation();
454
+ e.preventDefault();
455
+ dragStateRef.current = {
456
+ initialClientX: e.clientX,
457
+ latestDeltaFrames: 0,
458
+ pxPerFrame,
459
+ pointerId: e.pointerId,
460
+ targets,
461
+ };
462
+ document.body.style.userSelect = 'none';
463
+ document.body.style.webkitUserSelect = 'none';
464
+ (0, ForceSpecificCursor_1.forceSpecificCursor)('ew-resize');
465
+ setDragging(true);
466
+ }, [timelineDurationInFrames, windowWidth]);
467
+ // Install global pointer listeners while dragging. They survive parent re-renders
468
+ // and element remounts that would otherwise drop React's synthetic handlers or
469
+ // pointer capture.
470
+ (0, react_1.useEffect)(() => {
471
+ if (!dragging) {
472
+ return;
473
+ }
474
+ const onMove = (e) => {
475
+ const dragState = dragStateRef.current;
476
+ if (!dragState || e.pointerId !== dragState.pointerId) {
477
+ return;
478
+ }
479
+ const dx = e.clientX - dragState.initialClientX;
480
+ const deltaFrames = Math.round(dx / dragState.pxPerFrame);
481
+ dragState.latestDeltaFrames = deltaFrames;
482
+ for (const target of dragState.targets) {
483
+ latestRef.current.setDragOverrides(target.nodePath, 'durationInFrames', remotion_1.Internals.makeStaticDragOverride((0, exports.getTimelineSequenceDurationDragValue)({
484
+ initialDuration: target.initialDuration,
485
+ deltaFrames,
486
+ })));
487
+ }
488
+ };
489
+ const onUp = (e) => {
490
+ const dragState = dragStateRef.current;
491
+ if (!dragState || e.pointerId !== dragState.pointerId) {
492
+ return;
493
+ }
494
+ finishDrag(true);
495
+ };
496
+ const onCancel = (e) => {
497
+ const dragState = dragStateRef.current;
498
+ if (!dragState || e.pointerId !== dragState.pointerId) {
499
+ return;
500
+ }
501
+ finishDrag(false);
502
+ };
503
+ // Bail if the page loses focus mid-drag.
504
+ const onWindowBlur = () => {
505
+ finishDrag(false);
506
+ };
507
+ window.addEventListener('pointermove', onMove);
508
+ window.addEventListener('pointerup', onUp);
509
+ window.addEventListener('pointercancel', onCancel);
510
+ window.addEventListener('blur', onWindowBlur);
511
+ return () => {
512
+ window.removeEventListener('pointermove', onMove);
513
+ window.removeEventListener('pointerup', onUp);
514
+ window.removeEventListener('pointercancel', onCancel);
515
+ window.removeEventListener('blur', onWindowBlur);
516
+ };
517
+ }, [dragging, finishDrag]);
518
+ const style = {
519
+ ...baseStyle,
520
+ right: 0,
521
+ background: 'transparent',
522
+ };
523
+ return (jsx_runtime_1.jsx("div", { role: "separator", "aria-orientation": "vertical", title: "Drag to change duration", style: style, onPointerDown: onPointerDown }));
524
+ };
525
+ exports.TimelineSequenceRightEdgeDragHandle = TimelineSequenceRightEdgeDragHandle;
@@ -60,7 +60,7 @@ const TimelineTrackUnmemoized = ({ track }) => {
60
60
  getIsExpanded(track.nodePathInfo);
61
61
  const showRowHighlight = track.nodePathInfo !== null && (rowSelected || containsSelection);
62
62
  return (jsx_runtime_1.jsxs("div", { children: [
63
- jsx_runtime_1.jsxs("div", { style: layerStyle, children: [showRowHighlight && timelineWidth !== null ? (jsx_runtime_1.jsx("div", { style: (0, TimelineSelection_1.getTimelineSelectedTrackHighlightStyle)(timelineWidth) })) : null, jsx_runtime_1.jsx(TimelineSequence_1.TimelineSequence, { s: track.sequence, nodePathInfo: track.nodePathInfo })
63
+ jsx_runtime_1.jsxs("div", { style: layerStyle, children: [showRowHighlight && timelineWidth !== null ? (jsx_runtime_1.jsx("div", { style: (0, TimelineSelection_1.getTimelineSelectedTrackHighlightStyle)(timelineWidth) })) : null, jsx_runtime_1.jsx(TimelineSequence_1.TimelineSequence, { s: track.sequence, nodePathInfo: track.nodePathInfo, sequenceFrameOffset: track.sequenceFrameOffset })
64
64
  ] }), showExpandedKeyframes && track.nodePathInfo ? (jsx_runtime_1.jsx(TimelineExpandedTrackKeyframes_1.TimelineExpandedTrackKeyframes, { sequence: track.sequence, nodePathInfo: track.nodePathInfo, keyframeDisplayOffset: track.keyframeDisplayOffset })) : null] }));
65
65
  };
66
66
  exports.TimelineTrack = react_1.default.memo(TimelineTrackUnmemoized);
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import type { CanUpdateSequencePropStatus } from 'remotion';
2
+ import type { CanUpdateSequencePropStatusStatic } from 'remotion';
3
3
  import type { SchemaFieldInfo, TimelineFieldOnDragValueChange, TimelineFieldOnSave } from '../../helpers/timeline-layout';
4
4
  export declare const TimelineTranslateField: React.FC<{
5
5
  readonly field: SchemaFieldInfo;
6
- readonly propStatus: CanUpdateSequencePropStatus;
6
+ readonly propStatus: CanUpdateSequencePropStatusStatic;
7
7
  readonly effectiveValue: unknown;
8
8
  readonly onSave: TimelineFieldOnSave;
9
9
  readonly onDragValueChange: TimelineFieldOnDragValueChange;
@@ -24,7 +24,7 @@ const TimelineTranslateField = ({ field, propStatus, effectiveValue, onSave, onD
24
24
  const step = field.fieldSchema.type === 'translate' ? ((_a = field.fieldSchema.step) !== null && _a !== void 0 ? _a : 1) : 1;
25
25
  const stepDecimals = (0, react_1.useMemo)(() => (0, timeline_field_utils_1.getDecimalPlaces)(step), [step]);
26
26
  const formatter = (0, react_1.useCallback)((v) => {
27
- const num = Number(v);
27
+ const num = (0, timeline_field_utils_1.normalizeTimelineNumber)(Number(v));
28
28
  const digits = Math.max(stepDecimals, (0, timeline_field_utils_1.getDecimalPlaces)(num));
29
29
  const formatted = digits === 0 ? String(num) : num.toFixed(digits);
30
30
  return `${formatted}px`;
@@ -38,7 +38,7 @@ const TimelineTranslateField = ({ field, propStatus, effectiveValue, onSave, onD
38
38
  const onXChangeEnd = (0, react_1.useCallback)((newVal) => {
39
39
  const currentY = dragY !== null && dragY !== void 0 ? dragY : codeY;
40
40
  const newStr = (0, timeline_translate_utils_1.serializeTranslate)(newVal, currentY);
41
- if (propStatus.canUpdate && newStr !== propStatus.codeValue) {
41
+ if (newStr !== propStatus.codeValue) {
42
42
  onSave(newStr).finally(() => {
43
43
  setDragX(null);
44
44
  onDragEnd();
@@ -50,17 +50,15 @@ const TimelineTranslateField = ({ field, propStatus, effectiveValue, onSave, onD
50
50
  }
51
51
  }, [dragY, codeY, propStatus, onSave, onDragEnd]);
52
52
  const onXTextChange = (0, react_1.useCallback)((newVal) => {
53
- if (propStatus.canUpdate) {
54
- const parsed = Number(newVal);
55
- if (!Number.isNaN(parsed)) {
56
- const currentY = dragY !== null && dragY !== void 0 ? dragY : codeY;
57
- const newStr = (0, timeline_translate_utils_1.serializeTranslate)(parsed, currentY);
58
- if (newStr !== propStatus.codeValue) {
59
- setDragX(parsed);
60
- onSave(newStr).finally(() => {
61
- setDragX(null);
62
- });
63
- }
53
+ const parsed = Number(newVal);
54
+ if (!Number.isNaN(parsed)) {
55
+ const currentY = dragY !== null && dragY !== void 0 ? dragY : codeY;
56
+ const newStr = (0, timeline_translate_utils_1.serializeTranslate)(parsed, currentY);
57
+ if (newStr !== propStatus.codeValue) {
58
+ setDragX(parsed);
59
+ onSave(newStr).finally(() => {
60
+ setDragX(null);
61
+ });
64
62
  }
65
63
  }
66
64
  }, [propStatus, dragY, codeY, onSave]);
@@ -73,7 +71,7 @@ const TimelineTranslateField = ({ field, propStatus, effectiveValue, onSave, onD
73
71
  const onYChangeEnd = (0, react_1.useCallback)((newVal) => {
74
72
  const currentX = dragX !== null && dragX !== void 0 ? dragX : codeX;
75
73
  const newStr = (0, timeline_translate_utils_1.serializeTranslate)(currentX, newVal);
76
- if (propStatus.canUpdate && newStr !== propStatus.codeValue) {
74
+ if (newStr !== propStatus.codeValue) {
77
75
  onSave(newStr).finally(() => {
78
76
  setDragY(null);
79
77
  onDragEnd();
@@ -85,17 +83,15 @@ const TimelineTranslateField = ({ field, propStatus, effectiveValue, onSave, onD
85
83
  }
86
84
  }, [dragX, codeX, propStatus, onSave, onDragEnd]);
87
85
  const onYTextChange = (0, react_1.useCallback)((newVal) => {
88
- if (propStatus.canUpdate) {
89
- const parsed = Number(newVal);
90
- if (!Number.isNaN(parsed)) {
91
- const currentX = dragX !== null && dragX !== void 0 ? dragX : codeX;
92
- const newStr = (0, timeline_translate_utils_1.serializeTranslate)(currentX, parsed);
93
- if (newStr !== propStatus.codeValue) {
94
- setDragY(parsed);
95
- onSave(newStr).finally(() => {
96
- setDragY(null);
97
- });
98
- }
86
+ const parsed = Number(newVal);
87
+ if (!Number.isNaN(parsed)) {
88
+ const currentX = dragX !== null && dragX !== void 0 ? dragX : codeX;
89
+ const newStr = (0, timeline_translate_utils_1.serializeTranslate)(currentX, parsed);
90
+ if (newStr !== propStatus.codeValue) {
91
+ setDragY(parsed);
92
+ onSave(newStr).finally(() => {
93
+ setDragY(null);
94
+ });
99
95
  }
100
96
  }
101
97
  }, [propStatus, onSave, dragX, codeX]);
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import type { CanUpdateSequencePropStatus } from 'remotion';
2
+ import type { CanUpdateSequencePropStatusStatic } from 'remotion';
3
3
  import type { SchemaFieldInfo, TimelineFieldOnDragValueChange, TimelineFieldOnSave } from '../../helpers/timeline-layout';
4
4
  export declare const TimelineUvCoordinateField: React.FC<{
5
5
  readonly field: SchemaFieldInfo;
6
- readonly propStatus: CanUpdateSequencePropStatus;
6
+ readonly propStatus: CanUpdateSequencePropStatusStatic;
7
7
  readonly effectiveValue: unknown;
8
8
  readonly onSave: TimelineFieldOnSave;
9
9
  readonly onDragValueChange: TimelineFieldOnDragValueChange;