@remotion/studio 4.0.472 → 4.0.474

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 (165) 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 +45 -4
  4. package/dist/components/AssetSelectorItem.js +177 -27
  5. package/dist/components/Canvas.js +131 -11
  6. package/dist/components/ConfirmationDialog-types.d.ts +8 -0
  7. package/dist/components/ConfirmationDialog-types.js +2 -0
  8. package/dist/components/ConfirmationDialog.d.ts +7 -0
  9. package/dist/components/ConfirmationDialog.js +103 -0
  10. package/dist/components/ContextMenu.d.ts +9 -1
  11. package/dist/components/ContextMenu.js +49 -5
  12. package/dist/components/CurrentAsset.d.ts +1 -0
  13. package/dist/components/CurrentAsset.js +13 -2
  14. package/dist/components/EditorContent.js +15 -2
  15. package/dist/components/EditorContexts.js +2 -1
  16. package/dist/components/EditorRuler/Ruler.js +2 -0
  17. package/dist/components/ExplorerPanel.d.ts +0 -4
  18. package/dist/components/ExplorerPanel.js +8 -4
  19. package/dist/components/ExplorerPanelRef.d.ts +4 -0
  20. package/dist/components/ExplorerPanelRef.js +5 -0
  21. package/dist/components/FilePreview.d.ts +1 -1
  22. package/dist/components/InitialCompositionLoader.d.ts +0 -1
  23. package/dist/components/InitialCompositionLoader.js +5 -27
  24. package/dist/components/Menu/MenuItem.js +7 -1
  25. package/dist/components/Menu/SubMenu.js +5 -1
  26. package/dist/components/Menu/portals.js +17 -8
  27. package/dist/components/MenuToolbar.js +5 -1
  28. package/dist/components/ModalContainer.js +6 -1
  29. package/dist/components/Modals.js +5 -2
  30. package/dist/components/NewComposition/ComboBox.js +8 -2
  31. package/dist/components/NewComposition/InputDragger.d.ts +1 -0
  32. package/dist/components/NewComposition/InputDragger.js +9 -6
  33. package/dist/components/NewComposition/RenameStaticFile.d.ts +4 -0
  34. package/dist/components/NewComposition/RenameStaticFile.js +118 -0
  35. package/dist/components/OptionsPanel.js +5 -1
  36. package/dist/components/OutlineToggle.d.ts +2 -0
  37. package/dist/components/OutlineToggle.js +20 -0
  38. package/dist/components/Preview.d.ts +0 -2
  39. package/dist/components/Preview.js +23 -33
  40. package/dist/components/PreviewToolbar.js +19 -6
  41. package/dist/components/RenderButton.js +8 -2
  42. package/dist/components/RenderPreview.js +2 -2
  43. package/dist/components/SelectedOutlineOverlay.d.ts +29 -3
  44. package/dist/components/SelectedOutlineOverlay.js +259 -80
  45. package/dist/components/ShowOutlinesProvider.d.ts +4 -0
  46. package/dist/components/ShowOutlinesProvider.js +24 -0
  47. package/dist/components/SizeSelector.js +3 -3
  48. package/dist/components/Splitter/SplitterHandle.js +2 -0
  49. package/dist/components/StaticFilePreview.js +2 -2
  50. package/dist/components/Timeline/KeyframeSettingsModal.d.ts +15 -0
  51. package/dist/components/Timeline/KeyframeSettingsModal.js +150 -0
  52. package/dist/components/Timeline/SequencePropsObserver.js +3 -3
  53. package/dist/components/Timeline/Timeline.js +3 -13
  54. package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +26 -3
  55. package/dist/components/Timeline/TimelineClipboardKeybindings.js +242 -25
  56. package/dist/components/Timeline/TimelineDeleteKeybindings.js +23 -11
  57. package/dist/components/Timeline/TimelineEffectItem.js +8 -7
  58. package/dist/components/Timeline/TimelineEffectPropItem.js +69 -19
  59. package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +6 -1
  60. package/dist/components/Timeline/TimelineExpandedSection.js +5 -5
  61. package/dist/components/Timeline/TimelineKeyframeControls.js +13 -23
  62. package/dist/components/Timeline/TimelineKeyframeDiamond.js +24 -22
  63. package/dist/components/Timeline/TimelineKeyframeDiamondIcon.d.ts +6 -0
  64. package/dist/components/Timeline/TimelineKeyframeDiamondIcon.js +14 -0
  65. package/dist/components/Timeline/TimelineKeyframeDragState.d.ts +17 -0
  66. package/dist/components/Timeline/TimelineKeyframeDragState.js +39 -0
  67. package/dist/components/Timeline/TimelineKeyframeEasingLine.d.ts +9 -0
  68. package/dist/components/Timeline/TimelineKeyframeEasingLine.js +120 -0
  69. package/dist/components/Timeline/TimelineKeyframedValue.js +1 -1
  70. package/dist/components/Timeline/TimelineList.js +2 -2
  71. package/dist/components/Timeline/TimelineMediaInfo.d.ts +0 -13
  72. package/dist/components/Timeline/TimelineMediaInfo.js +8 -73
  73. package/dist/components/Timeline/TimelineNumberField.js +15 -7
  74. package/dist/components/Timeline/TimelineRotationField.js +17 -11
  75. package/dist/components/Timeline/TimelineScaleField.js +17 -13
  76. package/dist/components/Timeline/TimelineSelection.d.ts +15 -0
  77. package/dist/components/Timeline/TimelineSelection.js +26 -1
  78. package/dist/components/Timeline/TimelineSequence.js +6 -6
  79. package/dist/components/Timeline/TimelineSequenceItem.d.ts +1 -0
  80. package/dist/components/Timeline/TimelineSequenceItem.js +297 -36
  81. package/dist/components/Timeline/TimelineSequencePropItem.js +113 -48
  82. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +5 -5
  83. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +69 -70
  84. package/dist/components/Timeline/TimelineTranslateField.js +24 -19
  85. package/dist/components/Timeline/TimelineUvCoordinateField.js +18 -12
  86. package/dist/components/Timeline/apply-effect-response-to-prop-statuses.d.ts +5 -0
  87. package/dist/components/Timeline/apply-effect-response-to-prop-statuses.js +19 -0
  88. package/dist/components/Timeline/call-add-keyframe.d.ts +5 -5
  89. package/dist/components/Timeline/call-add-keyframe.js +6 -4
  90. package/dist/components/Timeline/call-delete-keyframe.d.ts +7 -7
  91. package/dist/components/Timeline/call-delete-keyframe.js +7 -7
  92. package/dist/components/Timeline/call-move-keyframe.d.ts +19 -0
  93. package/dist/components/Timeline/call-move-keyframe.js +71 -0
  94. package/dist/components/Timeline/call-update-keyframe-settings.d.ts +22 -0
  95. package/dist/components/Timeline/call-update-keyframe-settings.js +52 -0
  96. package/dist/components/Timeline/delete-selected-keyframe.d.ts +5 -5
  97. package/dist/components/Timeline/delete-selected-keyframe.js +5 -5
  98. package/dist/components/Timeline/delete-selected-timeline-item.d.ts +10 -7
  99. package/dist/components/Timeline/delete-selected-timeline-item.js +37 -23
  100. package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +4 -2
  101. package/dist/components/Timeline/duplicate-selected-timeline-item.js +39 -34
  102. package/dist/components/Timeline/get-bounded-keyframe-drag-delta.d.ts +8 -0
  103. package/dist/components/Timeline/get-bounded-keyframe-drag-delta.js +12 -0
  104. package/dist/components/Timeline/get-keyframe-navigation.d.ts +2 -2
  105. package/dist/components/Timeline/get-keyframe-navigation.js +14 -6
  106. package/dist/components/Timeline/get-node-keyframes.d.ts +3 -3
  107. package/dist/components/Timeline/get-node-keyframes.js +4 -4
  108. package/dist/components/Timeline/get-timeline-easing-segments.d.ts +9 -0
  109. package/dist/components/Timeline/get-timeline-easing-segments.js +19 -0
  110. package/dist/components/Timeline/reset-selected-timeline-props.d.ts +7 -7
  111. package/dist/components/Timeline/reset-selected-timeline-props.js +13 -12
  112. package/dist/components/Timeline/save-effect-prop.d.ts +16 -5
  113. package/dist/components/Timeline/save-effect-prop.js +37 -19
  114. package/dist/components/Timeline/save-prop-queue.d.ts +4 -3
  115. package/dist/components/Timeline/save-prop-queue.js +6 -3
  116. package/dist/components/Timeline/save-sequence-prop.d.ts +5 -10
  117. package/dist/components/Timeline/save-sequence-prop.js +35 -32
  118. package/dist/components/Timeline/should-clear-selection-on-pointer-down.d.ts +3 -0
  119. package/dist/components/Timeline/should-clear-selection-on-pointer-down.js +7 -0
  120. package/dist/components/Timeline/timeline-asset-link.d.ts +13 -0
  121. package/dist/components/Timeline/timeline-asset-link.js +37 -0
  122. package/dist/components/Timeline/timeline-field-utils.d.ts +10 -0
  123. package/dist/components/Timeline/timeline-field-utils.js +26 -5
  124. package/dist/components/Timeline/timeline-translate-utils.d.ts +1 -1
  125. package/dist/components/Timeline/timeline-translate-utils.js +6 -4
  126. package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +7 -7
  127. package/dist/components/Timeline/use-sequence-props-subscription.js +3 -3
  128. package/dist/components/Timeline/use-timeline-height.js +3 -3
  129. package/dist/components/Timeline/use-timeline-keyframe-drag.d.ts +10 -0
  130. package/dist/components/Timeline/use-timeline-keyframe-drag.js +380 -0
  131. package/dist/components/import-assets.d.ts +31 -0
  132. package/dist/components/import-assets.js +216 -17
  133. package/dist/components/load-canvas-content-from-url.d.ts +1 -0
  134. package/dist/components/load-canvas-content-from-url.js +9 -3
  135. package/dist/components/use-select-asset.d.ts +1 -0
  136. package/dist/components/use-select-asset.js +30 -0
  137. package/dist/error-overlay/error-origin.d.ts +3 -0
  138. package/dist/error-overlay/error-origin.js +42 -0
  139. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +6 -2
  140. package/dist/error-overlay/remotion-overlay/ErrorLoader.js +38 -0
  141. package/dist/error-overlay/remotion-overlay/ShortcutHint.js +1 -1
  142. package/dist/error-overlay/remotion-overlay/log-studio-error.d.ts +3 -0
  143. package/dist/error-overlay/remotion-overlay/log-studio-error.js +27 -0
  144. package/dist/esm/{chunk-48grt472.js → chunk-xjvc8qen.js} +21838 -18862
  145. package/dist/esm/internals.mjs +21838 -18862
  146. package/dist/esm/previewEntry.mjs +21127 -18127
  147. package/dist/esm/renderEntry.mjs +1 -1
  148. package/dist/helpers/get-asset-metadata.js +2 -2
  149. package/dist/helpers/get-preview-file-type.d.ts +2 -0
  150. package/dist/helpers/get-preview-file-type.js +33 -0
  151. package/dist/helpers/install-required-package.d.ts +1 -0
  152. package/dist/helpers/install-required-package.js +39 -0
  153. package/dist/helpers/remote-asset-drag.d.ts +4 -0
  154. package/dist/helpers/remote-asset-drag.js +73 -0
  155. package/dist/helpers/timeline-layout.d.ts +6 -6
  156. package/dist/helpers/timeline-layout.js +5 -5
  157. package/dist/helpers/use-asset-drag-events.d.ts +5 -2
  158. package/dist/helpers/use-asset-drag-events.js +13 -2
  159. package/dist/hot-middleware-client/client.js +6 -0
  160. package/dist/state/editor-outlines.d.ts +8 -0
  161. package/dist/state/editor-outlines.js +18 -0
  162. package/dist/state/modals.d.ts +16 -2
  163. package/package.json +10 -10
  164. package/dist/helpers/detect-file-type.d.ts +0 -69
  165. package/dist/helpers/detect-file-type.js +0 -278
@@ -0,0 +1,380 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTimelineKeyframeDrag = void 0;
4
+ const studio_shared_1 = require("@remotion/studio-shared");
5
+ const react_1 = require("react");
6
+ const remotion_1 = require("remotion");
7
+ const client_id_1 = require("../../helpers/client-id");
8
+ const timeline_layout_1 = require("../../helpers/timeline-layout");
9
+ const call_move_keyframe_1 = require("./call-move-keyframe");
10
+ const find_track_for_node_path_info_1 = require("./find-track-for-node-path-info");
11
+ const get_bounded_keyframe_drag_delta_1 = require("./get-bounded-keyframe-drag-delta");
12
+ const parse_keyframe_field_from_node_path_1 = require("./parse-keyframe-field-from-node-path");
13
+ const TimelineKeyframeDragState_1 = require("./TimelineKeyframeDragState");
14
+ const TimelineSelection_1 = require("./TimelineSelection");
15
+ const TimelineWidthProvider_1 = require("./TimelineWidthProvider");
16
+ const pointerDragThreshold = 3;
17
+ const isKeyframeSelection = (selection) => selection.type === 'keyframe';
18
+ const getCodeValueForTarget = ({ propStatuses, nodePath, }) => propStatuses[remotion_1.Internals.makeSequencePropsSubscriptionKey(nodePath)];
19
+ const getTimelineKeyframeDragTarget = ({ propStatuses, displayFrame, nodePathInfo, overrideIdsToNodePaths, sequences, }) => {
20
+ var _a, _b;
21
+ const field = (0, parse_keyframe_field_from_node_path_1.parseKeyframeFieldFromNodePath)(nodePathInfo.auxiliaryKeys);
22
+ if (field === null) {
23
+ return null;
24
+ }
25
+ const track = (0, find_track_for_node_path_info_1.findTrackForNodePathInfo)({
26
+ sequences,
27
+ overrideIdsToNodePaths,
28
+ nodePathInfo,
29
+ });
30
+ const sequence = (_a = track === null || track === void 0 ? void 0 : track.sequence) !== null && _a !== void 0 ? _a : null;
31
+ if (!(sequence === null || sequence === void 0 ? void 0 : sequence.controls)) {
32
+ return null;
33
+ }
34
+ const sourceFrame = displayFrame - ((_b = track === null || track === void 0 ? void 0 : track.keyframeDisplayOffset) !== null && _b !== void 0 ? _b : 0);
35
+ const nodePath = nodePathInfo.sequenceSubscriptionKey;
36
+ const fileName = nodePath.absolutePath;
37
+ const sequenceStatus = getCodeValueForTarget({ propStatuses, nodePath });
38
+ if (!(sequenceStatus === null || sequenceStatus === void 0 ? void 0 : sequenceStatus.canUpdate)) {
39
+ return null;
40
+ }
41
+ if (field.type === 'effect') {
42
+ const effect = sequence.effects[field.effectIndex];
43
+ const effectStatus = sequenceStatus.effects.find((candidate) => candidate.effectIndex === field.effectIndex);
44
+ if (!effect || !(effectStatus === null || effectStatus === void 0 ? void 0 : effectStatus.canUpdate)) {
45
+ return null;
46
+ }
47
+ const effectPropStatus = effectStatus.props[field.fieldKey];
48
+ if ((effectPropStatus === null || effectPropStatus === void 0 ? void 0 : effectPropStatus.status) !== 'keyframed') {
49
+ return null;
50
+ }
51
+ if (!effectPropStatus.keyframes.some((keyframe) => keyframe.frame === sourceFrame)) {
52
+ return null;
53
+ }
54
+ return {
55
+ type: 'effect',
56
+ displayFrame,
57
+ effectIndex: field.effectIndex,
58
+ fieldKey: field.fieldKey,
59
+ fileName,
60
+ nodePath,
61
+ nodePathInfo,
62
+ propStatus: effectPropStatus,
63
+ schema: effect.schema,
64
+ sourceFrame,
65
+ };
66
+ }
67
+ const sequencePropStatus = sequenceStatus.props[field.fieldKey];
68
+ if ((sequencePropStatus === null || sequencePropStatus === void 0 ? void 0 : sequencePropStatus.status) !== 'keyframed') {
69
+ return null;
70
+ }
71
+ if (!sequencePropStatus.keyframes.some((keyframe) => keyframe.frame === sourceFrame)) {
72
+ return null;
73
+ }
74
+ return {
75
+ type: 'sequence',
76
+ displayFrame,
77
+ fieldKey: field.fieldKey,
78
+ fileName,
79
+ nodePath,
80
+ nodePathInfo,
81
+ propStatus: sequencePropStatus,
82
+ schema: sequence.controls.schema,
83
+ sourceFrame,
84
+ };
85
+ };
86
+ const getTargetGroupKey = (target) => {
87
+ return JSON.stringify({
88
+ type: target.type,
89
+ nodePath: target.nodePath,
90
+ effectIndex: target.type === 'effect' ? target.effectIndex : null,
91
+ fieldKey: target.fieldKey,
92
+ });
93
+ };
94
+ const groupTargets = (targets) => {
95
+ var _a;
96
+ const groups = new Map();
97
+ for (const target of targets) {
98
+ const key = getTargetGroupKey(target);
99
+ const group = (_a = groups.get(key)) !== null && _a !== void 0 ? _a : [];
100
+ group.push(target);
101
+ groups.set(key, group);
102
+ }
103
+ return [...groups.values()];
104
+ };
105
+ const getMovesForGroup = ({ group, delta, }) => group.map((target) => ({
106
+ fromFrame: target.sourceFrame,
107
+ toFrame: target.sourceFrame + delta,
108
+ }));
109
+ const canMoveTimelineKeyframeDragTargets = ({ targets, delta, }) => groupTargets(targets).every((group) => {
110
+ const [first] = group;
111
+ if (!first) {
112
+ return true;
113
+ }
114
+ return (0, studio_shared_1.canMoveKeyframesWithoutCollisions)({
115
+ status: first.propStatus,
116
+ moves: getMovesForGroup({ group, delta }),
117
+ });
118
+ });
119
+ const makeMovedKeyframedDragOverride = ({ group, delta, }) => {
120
+ const [first] = group;
121
+ if (!first) {
122
+ throw new Error('Expected a keyframe drag target');
123
+ }
124
+ const moves = new Map(getMovesForGroup({ group, delta }).map((move) => [move.fromFrame, move.toFrame]));
125
+ return {
126
+ type: 'keyframed',
127
+ status: {
128
+ ...first.propStatus,
129
+ keyframes: first.propStatus.keyframes
130
+ .map((keyframe) => {
131
+ var _a;
132
+ return ({
133
+ ...keyframe,
134
+ frame: (_a = moves.get(keyframe.frame)) !== null && _a !== void 0 ? _a : keyframe.frame,
135
+ });
136
+ })
137
+ .sort((a, b) => a.frame - b.frame),
138
+ },
139
+ };
140
+ };
141
+ const applyDragOverrides = ({ delta, setDragOverrides, setEffectDragOverrides, targets, }) => {
142
+ for (const group of groupTargets(targets)) {
143
+ const [first] = group;
144
+ if (!first) {
145
+ continue;
146
+ }
147
+ const override = makeMovedKeyframedDragOverride({ group, delta });
148
+ if (first.type === 'sequence') {
149
+ setDragOverrides(first.nodePath, first.fieldKey, override);
150
+ continue;
151
+ }
152
+ setEffectDragOverrides(first.nodePath, first.effectIndex, first.fieldKey, override);
153
+ }
154
+ };
155
+ const clearDragOverridesForTargets = ({ clearDragOverrides, clearEffectDragOverrides, targets, }) => {
156
+ const clearedSequences = new Set();
157
+ const clearedEffects = new Set();
158
+ for (const target of targets) {
159
+ if (target.type === 'sequence') {
160
+ const sequenceKey = JSON.stringify(target.nodePath);
161
+ if (clearedSequences.has(sequenceKey)) {
162
+ continue;
163
+ }
164
+ clearedSequences.add(sequenceKey);
165
+ clearDragOverrides(target.nodePath);
166
+ continue;
167
+ }
168
+ const effectKey = JSON.stringify({
169
+ nodePath: target.nodePath,
170
+ effectIndex: target.effectIndex,
171
+ });
172
+ if (clearedEffects.has(effectKey)) {
173
+ continue;
174
+ }
175
+ clearedEffects.add(effectKey);
176
+ clearEffectDragOverrides(target.nodePath, target.effectIndex);
177
+ }
178
+ };
179
+ const getFrameDelta = ({ clientXDelta, durationInFrames, timelineWidth, }) => {
180
+ const timelineContentWidth = timelineWidth - timeline_layout_1.TIMELINE_PADDING * 2;
181
+ if (timelineContentWidth <= 0) {
182
+ return 0;
183
+ }
184
+ return Math.round((clientXDelta / timelineContentWidth) * durationInFrames);
185
+ };
186
+ const useTimelineKeyframeDrag = ({ frame, nodePathInfo, onSelect, selectable, selected, }) => {
187
+ const videoConfig = (0, remotion_1.useVideoConfig)();
188
+ const timelineWidth = (0, react_1.useContext)(TimelineWidthProvider_1.TimelineWidthContext);
189
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
190
+ const sequencesRef = (0, react_1.useContext)(remotion_1.Internals.SequenceManagerRefContext);
191
+ const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
192
+ const propStatusesRef = (0, react_1.useContext)(remotion_1.Internals.VisualModePropStatusesRefContext);
193
+ const { clearDragOverrides, clearEffectDragOverrides, setPropStatuses, setDragOverrides, setEffectDragOverrides, } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
194
+ const currentSelection = (0, TimelineSelection_1.useCurrentTimelineSelectionStateAsRef)();
195
+ const { clearDraggedKeyframes, setDraggedKeyframes } = (0, TimelineKeyframeDragState_1.useTimelineKeyframeDragState)();
196
+ return (0, react_1.useCallback)((e) => {
197
+ if (e.button !== 0 ||
198
+ !selectable ||
199
+ timelineWidth === null ||
200
+ previewServerState.type !== 'connected') {
201
+ return;
202
+ }
203
+ e.preventDefault();
204
+ e.stopPropagation();
205
+ const interaction = {
206
+ shiftKey: e.shiftKey,
207
+ toggleKey: e.metaKey || e.ctrlKey,
208
+ };
209
+ const shouldDragExistingSelection = selected && !interaction.shiftKey && !interaction.toggleKey;
210
+ if (!shouldDragExistingSelection) {
211
+ onSelect(interaction);
212
+ }
213
+ const clickedSelection = {
214
+ type: 'keyframe',
215
+ nodePathInfo,
216
+ frame,
217
+ };
218
+ const selectedKeyframes = currentSelection.current.selectedItems.filter(isKeyframeSelection);
219
+ const keyframesToDrag = shouldDragExistingSelection && selectedKeyframes.length > 0
220
+ ? selectedKeyframes
221
+ : [clickedSelection];
222
+ const startClientX = e.clientX;
223
+ let dragTargets = null;
224
+ let hasDragged = false;
225
+ let lastDelta = 0;
226
+ const propStatuses = propStatusesRef.current;
227
+ const sequences = sequencesRef.current;
228
+ const resolveDragTargets = () => {
229
+ if (dragTargets !== null) {
230
+ return dragTargets;
231
+ }
232
+ dragTargets = keyframesToDrag
233
+ .map((keyframe) => getTimelineKeyframeDragTarget({
234
+ propStatuses,
235
+ displayFrame: keyframe.frame,
236
+ nodePathInfo: keyframe.nodePathInfo,
237
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
238
+ sequences,
239
+ }))
240
+ .filter((target) => target !== null);
241
+ return dragTargets;
242
+ };
243
+ const cleanup = () => {
244
+ window.removeEventListener('pointermove', onPointerMove);
245
+ window.removeEventListener('pointerup', onPointerUp);
246
+ window.removeEventListener('pointercancel', onPointerCancel);
247
+ };
248
+ const clearActiveOverrides = () => {
249
+ const targets = dragTargets;
250
+ if (targets === null) {
251
+ return;
252
+ }
253
+ clearDragOverridesForTargets({
254
+ clearDragOverrides,
255
+ clearEffectDragOverrides,
256
+ targets,
257
+ });
258
+ };
259
+ const onPointerMove = (event) => {
260
+ const clientXDelta = event.clientX - startClientX;
261
+ if (!hasDragged && Math.abs(clientXDelta) < pointerDragThreshold) {
262
+ return;
263
+ }
264
+ const targets = resolveDragTargets();
265
+ if (targets.length === 0) {
266
+ cleanup();
267
+ clearDraggedKeyframes();
268
+ return;
269
+ }
270
+ const rawDelta = getFrameDelta({
271
+ clientXDelta,
272
+ durationInFrames: videoConfig.durationInFrames,
273
+ timelineWidth,
274
+ });
275
+ const delta = (0, get_bounded_keyframe_drag_delta_1.getBoundedKeyframeDragDelta)({
276
+ delta: rawDelta,
277
+ durationInFrames: videoConfig.durationInFrames,
278
+ targets,
279
+ });
280
+ if (hasDragged && delta === lastDelta) {
281
+ return;
282
+ }
283
+ hasDragged = true;
284
+ lastDelta = delta;
285
+ if (!canMoveTimelineKeyframeDragTargets({ targets, delta })) {
286
+ clearActiveOverrides();
287
+ clearDraggedKeyframes();
288
+ return;
289
+ }
290
+ setDraggedKeyframes(targets.map((target) => ({
291
+ nodePathInfo: target.nodePathInfo,
292
+ frame: target.displayFrame + delta,
293
+ })));
294
+ applyDragOverrides({
295
+ delta,
296
+ setDragOverrides,
297
+ setEffectDragOverrides,
298
+ targets,
299
+ });
300
+ };
301
+ const onPointerUp = () => {
302
+ cleanup();
303
+ const targets = dragTargets;
304
+ if (!hasDragged || lastDelta === 0 || targets === null) {
305
+ clearActiveOverrides();
306
+ clearDraggedKeyframes();
307
+ return;
308
+ }
309
+ if (!canMoveTimelineKeyframeDragTargets({
310
+ targets,
311
+ delta: lastDelta,
312
+ })) {
313
+ clearActiveOverrides();
314
+ clearDraggedKeyframes();
315
+ return;
316
+ }
317
+ currentSelection.current.selectItems(targets.map((target) => ({
318
+ type: 'keyframe',
319
+ nodePathInfo: target.nodePathInfo,
320
+ frame: target.displayFrame + lastDelta,
321
+ })));
322
+ clearActiveOverrides();
323
+ clearDraggedKeyframes();
324
+ (0, call_move_keyframe_1.callMoveKeyframes)({
325
+ sequenceKeyframes: targets
326
+ .filter((target) => target.type === 'sequence')
327
+ .map((target) => ({
328
+ fileName: target.fileName,
329
+ nodePath: target.nodePath,
330
+ fieldKey: target.fieldKey,
331
+ fromFrame: target.sourceFrame,
332
+ toFrame: target.sourceFrame + lastDelta,
333
+ schema: target.schema,
334
+ })),
335
+ effectKeyframes: targets
336
+ .filter((target) => target.type === 'effect')
337
+ .map((target) => ({
338
+ fileName: target.fileName,
339
+ nodePath: target.nodePath,
340
+ effectIndex: target.effectIndex,
341
+ fieldKey: target.fieldKey,
342
+ fromFrame: target.sourceFrame,
343
+ toFrame: target.sourceFrame + lastDelta,
344
+ schema: target.schema,
345
+ })),
346
+ setPropStatuses,
347
+ clientId: previewServerState.clientId,
348
+ }).catch(() => undefined);
349
+ };
350
+ const onPointerCancel = () => {
351
+ cleanup();
352
+ clearActiveOverrides();
353
+ clearDraggedKeyframes();
354
+ };
355
+ window.addEventListener('pointermove', onPointerMove);
356
+ window.addEventListener('pointerup', onPointerUp);
357
+ window.addEventListener('pointercancel', onPointerCancel);
358
+ }, [
359
+ clearDragOverrides,
360
+ clearEffectDragOverrides,
361
+ clearDraggedKeyframes,
362
+ currentSelection,
363
+ frame,
364
+ nodePathInfo,
365
+ onSelect,
366
+ overrideIdToNodePathMappings,
367
+ propStatusesRef,
368
+ previewServerState,
369
+ selectable,
370
+ selected,
371
+ sequencesRef,
372
+ setPropStatuses,
373
+ setDragOverrides,
374
+ setDraggedKeyframes,
375
+ setEffectDragOverrides,
376
+ timelineWidth,
377
+ videoConfig.durationInFrames,
378
+ ]);
379
+ };
380
+ exports.useTimelineKeyframeDrag = useTimelineKeyframeDrag;
@@ -1,6 +1,37 @@
1
+ import { type FileType, type InsertableCompositionElement } from '@remotion/studio-shared';
2
+ export declare const getAssetElement: ({ fileType, src, }: {
3
+ fileType: FileType;
4
+ src: string;
5
+ }) => InsertableCompositionElement | null;
6
+ export declare const getAssetElementFromPath: (assetPath: string) => InsertableCompositionElement | null;
1
7
  export declare const pickFilesToImport: () => Promise<File[]>;
2
8
  export declare const importAssets: ({ compositionFile, compositionId, files, }: {
3
9
  compositionFile: string;
4
10
  compositionId: string;
5
11
  files: File[];
6
12
  }) => Promise<void>;
13
+ export declare const importRemoteAsset: ({ compositionFile, compositionId, url, }: {
14
+ compositionFile: string;
15
+ compositionId: string;
16
+ url: string;
17
+ }) => Promise<void>;
18
+ export declare const insertRemoteAudio: ({ compositionFile, compositionId, url, }: {
19
+ compositionFile: string;
20
+ compositionId: string;
21
+ url: string;
22
+ }) => Promise<void>;
23
+ export declare const insertExistingAssets: ({ assetPaths, compositionFile, compositionId, }: {
24
+ assetPaths: string[];
25
+ compositionFile: string;
26
+ compositionId: string;
27
+ }) => Promise<void>;
28
+ export declare const insertComponent: ({ component, compositionFile, compositionId, }: {
29
+ component: {
30
+ componentName: string;
31
+ importName: string;
32
+ importPath: string;
33
+ props: import("@remotion/studio-shared").ComponentProp[];
34
+ };
35
+ compositionFile: string;
36
+ compositionId: string;
37
+ }) => Promise<void>;