@remotion/studio 4.0.474 → 4.0.476

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 (94) hide show
  1. package/dist/components/Canvas.js +6 -0
  2. package/dist/components/ColorPicker/ColorPicker.js +4 -31
  3. package/dist/components/ColorPicker/ColorPickerPopup.d.ts +6 -0
  4. package/dist/components/ColorPicker/ColorPickerPopup.js +11 -6
  5. package/dist/components/CompositionSelectorItem.js +4 -4
  6. package/dist/components/Editor.js +4 -1
  7. package/dist/components/GlobalKeybindings.js +12 -0
  8. package/dist/components/KeyboardShortcutsExplainer.js +24 -0
  9. package/dist/components/Modals.js +2 -1
  10. package/dist/components/NewComposition/ComboBox.js +1 -0
  11. package/dist/components/NewComposition/InputDragger.d.ts +6 -0
  12. package/dist/components/NewComposition/InputDragger.js +40 -14
  13. package/dist/components/NewComposition/RenameComposition.js +8 -1
  14. package/dist/components/NewComposition/RenameFolder.js +8 -1
  15. package/dist/components/NewComposition/RenameStaticFile.js +11 -1
  16. package/dist/components/Notifications/Notification.js +5 -4
  17. package/dist/components/Notifications/NotificationCenter.js +1 -1
  18. package/dist/components/ObserveDefaultPropsContext.js +6 -2
  19. package/dist/components/PlayPause.js +22 -66
  20. package/dist/components/PreviewToolbar.js +17 -3
  21. package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +2 -1
  22. package/dist/components/SelectedOutlineOverlay.d.ts +104 -42
  23. package/dist/components/SelectedOutlineOverlay.js +1278 -336
  24. package/dist/components/SelectedOutlineUvControls.d.ts +17 -0
  25. package/dist/components/SelectedOutlineUvControls.js +167 -0
  26. package/dist/components/StudioCanvasCapture.d.ts +5 -0
  27. package/dist/components/StudioCanvasCapture.js +40 -0
  28. package/dist/components/Timeline/EasingEditorModal.d.ts +11 -0
  29. package/dist/components/Timeline/EasingEditorModal.js +247 -0
  30. package/dist/components/Timeline/KeyframeSettingsModal.js +1 -0
  31. package/dist/components/Timeline/Timeline.js +10 -7
  32. package/dist/components/Timeline/TimelineDeleteKeybindings.js +64 -35
  33. package/dist/components/Timeline/TimelineDragHandler.js +2 -2
  34. package/dist/components/Timeline/TimelineEffectItem.js +1 -2
  35. package/dist/components/Timeline/TimelineEffectPropItem.js +1 -1
  36. package/dist/components/Timeline/TimelineExpandedKeyframeRow.d.ts +1 -0
  37. package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +2 -2
  38. package/dist/components/Timeline/TimelineExpandedTrackKeyframes.js +1 -1
  39. package/dist/components/Timeline/TimelineHeightContainer.js +2 -0
  40. package/dist/components/Timeline/TimelineItemStack.js +3 -56
  41. package/dist/components/Timeline/TimelineKeyframeControls.d.ts +7 -0
  42. package/dist/components/Timeline/TimelineKeyframeControls.js +259 -62
  43. package/dist/components/Timeline/TimelineKeyframeDiamond.js +4 -2
  44. package/dist/components/Timeline/TimelineKeyframeEasingLine.js +128 -3
  45. package/dist/components/Timeline/TimelineKeyframeTracksContext.d.ts +7 -0
  46. package/dist/components/Timeline/TimelineKeyframeTracksContext.js +17 -0
  47. package/dist/components/Timeline/TimelineMediaInfo.js +4 -24
  48. package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +4 -0
  49. package/dist/components/Timeline/TimelineRotationField.js +21 -39
  50. package/dist/components/Timeline/TimelineScaleField.js +1 -1
  51. package/dist/components/Timeline/TimelineScrollable.js +19 -3
  52. package/dist/components/Timeline/TimelineSelection.d.ts +67 -3
  53. package/dist/components/Timeline/TimelineSelection.js +289 -32
  54. package/dist/components/Timeline/TimelineSequence.js +17 -9
  55. package/dist/components/Timeline/TimelineSequenceItem.js +328 -168
  56. package/dist/components/Timeline/TimelineSequenceName.d.ts +4 -2
  57. package/dist/components/Timeline/TimelineSequenceName.js +70 -19
  58. package/dist/components/Timeline/TimelineSequencePropItem.js +1 -1
  59. package/dist/components/Timeline/TimelineTimeIndicators.js +4 -2
  60. package/dist/components/Timeline/TimelineTransformOriginField.d.ts +11 -0
  61. package/dist/components/Timeline/TimelineTransformOriginField.js +138 -0
  62. package/dist/components/Timeline/TimelineTranslateField.js +1 -1
  63. package/dist/components/Timeline/TimelineUvCoordinateField.js +1 -1
  64. package/dist/components/Timeline/call-add-keyframe.d.ts +17 -0
  65. package/dist/components/Timeline/call-add-keyframe.js +65 -1
  66. package/dist/components/Timeline/delete-selected-timeline-item.js +23 -13
  67. package/dist/components/Timeline/disable-sequence-interactivity.d.ts +8 -0
  68. package/dist/components/Timeline/disable-sequence-interactivity.js +24 -0
  69. package/dist/components/Timeline/reset-selected-timeline-props.js +15 -7
  70. package/dist/components/Timeline/timeline-rotation-utils.d.ts +2 -0
  71. package/dist/components/Timeline/timeline-rotation-utils.js +34 -0
  72. package/dist/components/Timeline/transform-origin-utils.d.ts +24 -0
  73. package/dist/components/Timeline/transform-origin-utils.js +170 -0
  74. package/dist/components/Timeline/update-selected-easing.d.ts +35 -0
  75. package/dist/components/Timeline/update-selected-easing.js +133 -0
  76. package/dist/components/Timeline/use-expanded-track-keyframe-rows.d.ts +1 -0
  77. package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +28 -0
  78. package/dist/components/Timeline/use-timeline-keyframe-drag.js +8 -13
  79. package/dist/components/canvas-capture-enabled.d.ts +1 -0
  80. package/dist/components/canvas-capture-enabled.js +4 -0
  81. package/dist/components/effect-drag-and-drop.d.ts +11 -0
  82. package/dist/components/effect-drag-and-drop.js +73 -0
  83. package/dist/components/selected-outline-geometry.d.ts +20 -0
  84. package/dist/components/selected-outline-geometry.js +18 -0
  85. package/dist/components/selected-outline-uv.d.ts +46 -0
  86. package/dist/components/selected-outline-uv.js +240 -0
  87. package/dist/esm/{chunk-xjvc8qen.js → chunk-0atarw3p.js} +8779 -5352
  88. package/dist/esm/internals.mjs +8779 -5352
  89. package/dist/esm/previewEntry.mjs +8789 -5362
  90. package/dist/esm/renderEntry.mjs +1 -1
  91. package/dist/helpers/colors.d.ts +0 -1
  92. package/dist/helpers/colors.js +1 -2
  93. package/dist/state/modals.d.ts +2 -1
  94. package/package.json +11 -10
@@ -1,21 +1,56 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.TimelineSequenceItem = void 0;
4
37
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const studio_shared_1 = require("@remotion/studio-shared");
6
- const react_1 = require("react");
38
+ const react_1 = __importStar(require("react"));
7
39
  const remotion_1 = require("remotion");
8
40
  const no_react_1 = require("remotion/no-react");
9
41
  const client_id_1 = require("../../helpers/client-id");
10
42
  const format_file_location_1 = require("../../helpers/format-file-location");
11
- const install_required_package_1 = require("../../helpers/install-required-package");
12
43
  const timeline_layout_1 = require("../../helpers/timeline-layout");
44
+ const use_keybinding_1 = require("../../helpers/use-keybinding");
13
45
  const call_api_1 = require("../call-api");
14
46
  const ConfirmationDialog_1 = require("../ConfirmationDialog");
15
47
  const ContextMenu_1 = require("../ContextMenu");
48
+ const effect_drag_and_drop_1 = require("../effect-drag-and-drop");
16
49
  const ExpandedTracksProvider_1 = require("../ExpandedTracksProvider");
50
+ const layout_1 = require("../layout");
17
51
  const NotificationCenter_1 = require("../Notifications/NotificationCenter");
18
52
  const use_select_asset_1 = require("../use-select-asset");
53
+ const disable_sequence_interactivity_1 = require("./disable-sequence-interactivity");
19
54
  const duplicate_selected_timeline_item_1 = require("./duplicate-selected-timeline-item");
20
55
  const save_sequence_prop_1 = require("./save-sequence-prop");
21
56
  const timeline_asset_link_1 = require("./timeline-asset-link");
@@ -34,7 +69,6 @@ const labelContainerStyle = {
34
69
  display: 'flex',
35
70
  flexDirection: 'row',
36
71
  minWidth: 0,
37
- gap: 4,
38
72
  };
39
73
  const effectDropHighlight = {
40
74
  backgroundColor: 'rgba(0, 155, 255, 0.16)',
@@ -103,42 +137,23 @@ const getSequenceReorderDragData = (dataTransfer) => {
103
137
  const getDestinationIndex = ({ fromIndex, insertionIndex, }) => {
104
138
  return insertionIndex > fromIndex ? insertionIndex - 1 : insertionIndex;
105
139
  };
106
- const hasEffectDragType = (dataTransfer) => {
107
- return Array.from(dataTransfer.types).some((type) => type === studio_shared_1.EFFECT_DRAG_MIME_TYPE ||
108
- type === 'application/json' ||
109
- type === 'text/plain');
110
- };
111
- const getEffectDragData = (dataTransfer) => {
112
- for (const type of [
113
- studio_shared_1.EFFECT_DRAG_MIME_TYPE,
114
- 'application/json',
115
- 'text/plain',
116
- ]) {
117
- const value = dataTransfer.getData(type);
118
- if (!value) {
119
- continue;
120
- }
121
- const parsed = (0, studio_shared_1.parseEffectDragData)(value);
122
- if (parsed) {
123
- return parsed;
124
- }
125
- }
126
- return null;
127
- };
128
140
  const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDisplayOffset, trackIndex, }) => {
129
- var _a, _b;
130
- var _c, _d;
131
- const nodePath = (_c = nodePathInfo === null || nodePathInfo === void 0 ? void 0 : nodePathInfo.sequenceSubscriptionKey) !== null && _c !== void 0 ? _c : null;
141
+ var _a, _b, _c;
142
+ var _d, _e;
143
+ const nodePath = (_d = nodePathInfo === null || nodePathInfo === void 0 ? void 0 : nodePathInfo.sequenceSubscriptionKey) !== null && _d !== void 0 ? _d : null;
132
144
  const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
133
145
  const previewConnected = previewServerState.type === 'connected';
134
146
  const { getIsExpanded } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksGetterContext);
135
147
  const { toggleTrack } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksSetterContext);
136
148
  const { propStatuses } = (0, react_1.useContext)(remotion_1.Internals.VisualModePropStatusesContext);
137
149
  const { setPropStatuses } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
150
+ const { isHighestContext } = (0, use_keybinding_1.useKeybinding)();
138
151
  const selectAsset = (0, use_select_asset_1.useSelectAsset)();
139
152
  const { onSelect, selectable, selected } = (0, TimelineSelection_1.useTimelineRowSelection)(nodePathInfo);
153
+ const { selectedItems } = (0, TimelineSelection_1.useTimelineSelection)();
140
154
  const containsSelection = (0, TimelineSelection_1.useTimelineRowContainsSelection)(nodePathInfo);
141
155
  const [effectDropHovered, setEffectDropHovered] = (0, react_1.useState)(false);
156
+ const [isRenaming, setIsRenaming] = (0, react_1.useState)(false);
142
157
  const [sequenceDropIndicator, setSequenceDropIndicator] = (0, react_1.useState)(null);
143
158
  const [sequenceDropRejection, setSequenceDropRejection] = (0, react_1.useState)(null);
144
159
  const { canOpenInEditor, openInEditor, originalLocation } = (0, use_open_sequence_in_editor_1.useOpenSequenceInEditor)(sequence);
@@ -161,15 +176,18 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
161
176
  }, [originalLocation]);
162
177
  const canDeleteFromSource = Boolean(nodePath && (validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source));
163
178
  const nodePathKey = (0, react_1.useMemo)(() => nodePath ? remotion_1.Internals.makeSequencePropsSubscriptionKey(nodePath) : null, [nodePath]);
164
- const parentId = (_d = sequence.parent) !== null && _d !== void 0 ? _d : null;
165
- const canReorderSequence = TimelineSelection_1.SELECTION_ENABLED &&
166
- previewConnected &&
179
+ const parentId = (_e = sequence.parent) !== null && _e !== void 0 ? _e : null;
180
+ const canReorderSequence = previewConnected &&
167
181
  Boolean(nodePath && nodePathKey && (validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source)) &&
168
182
  (nodePathInfo === null || nodePathInfo === void 0 ? void 0 : nodePathInfo.numberOfSequencesWithThisNodePath) === 1;
169
- const canHandleSequenceDrag = TimelineSelection_1.SELECTION_ENABLED && previewConnected;
183
+ const canHandleSequenceDrag = previewConnected;
170
184
  const confirm = (0, ConfirmationDialog_1.useConfirmationDialog)();
171
185
  const deleteDisabled = (0, react_1.useMemo)(() => !previewConnected || !sequence.controls || !canDeleteFromSource, [previewConnected, sequence.controls, canDeleteFromSource]);
172
186
  const duplicateDisabled = deleteDisabled;
187
+ const disableInteractivityDisabled = !previewConnected ||
188
+ !sequence.showInTimeline ||
189
+ !nodePath ||
190
+ !(validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source);
173
191
  const onDuplicateSequenceFromSource = (0, react_1.useCallback)(() => {
174
192
  if (!(validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source) || !nodePathInfo) {
175
193
  return;
@@ -212,6 +230,26 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
212
230
  (0, NotificationCenter_1.showNotification)(err.message, 4000);
213
231
  }
214
232
  }, [confirm, nodePath, validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source, nodePathInfo]);
233
+ const onDisableSequenceInteractivity = (0, react_1.useCallback)(() => {
234
+ if (disableInteractivityDisabled ||
235
+ !nodePath ||
236
+ !(validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source) ||
237
+ previewServerState.type !== 'connected') {
238
+ return;
239
+ }
240
+ (0, disable_sequence_interactivity_1.disableSequenceInteractivity)({
241
+ fileName: validatedLocation.source,
242
+ nodePath,
243
+ setPropStatuses,
244
+ clientId: previewServerState.clientId,
245
+ });
246
+ }, [
247
+ disableInteractivityDisabled,
248
+ nodePath,
249
+ previewServerState,
250
+ setPropStatuses,
251
+ validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source,
252
+ ]);
215
253
  const getSequenceDropTarget = (0, react_1.useCallback)((e) => {
216
254
  const dragData = getSequenceReorderDragData(e.dataTransfer);
217
255
  if (!dragData) {
@@ -378,6 +416,205 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
378
416
  ? sequence.src
379
417
  : null;
380
418
  const assetLinkInfo = (0, react_1.useMemo)(() => (mediaSrc ? (0, timeline_asset_link_1.getTimelineAssetLinkInfo)(mediaSrc) : null), [mediaSrc]);
419
+ const isExpanded = previewConnected && nodePathInfo !== null && getIsExpanded(nodePathInfo);
420
+ const onToggleExpand = (0, react_1.useCallback)(() => {
421
+ if (nodePathInfo === null) {
422
+ return;
423
+ }
424
+ toggleTrack(nodePathInfo);
425
+ }, [nodePathInfo, toggleTrack]);
426
+ const onShowInEditorDoubleClick = (0, react_1.useCallback)((e) => {
427
+ if (!canOpenInEditor) {
428
+ return;
429
+ }
430
+ if ((0, TimelineSelection_1.isTimelineSelectionModifierEvent)(e)) {
431
+ e.stopPropagation();
432
+ return;
433
+ }
434
+ e.stopPropagation();
435
+ openInEditor();
436
+ }, [canOpenInEditor, openInEditor]);
437
+ const propStatusesForOverride = (0, react_1.useMemo)(() => {
438
+ return nodePath
439
+ ? remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath)
440
+ : undefined;
441
+ }, [propStatuses, nodePath]);
442
+ const codeHiddenStatus = propStatusesForOverride === null || propStatusesForOverride === void 0 ? void 0 : propStatusesForOverride.hidden;
443
+ const codeNameStatus = propStatusesForOverride === null || propStatusesForOverride === void 0 ? void 0 : propStatusesForOverride.name;
444
+ const isItemHidden = (0, react_1.useMemo)(() => {
445
+ var _a;
446
+ const propStatus = codeHiddenStatus && codeHiddenStatus.status === 'static'
447
+ ? codeHiddenStatus.codeValue
448
+ : undefined;
449
+ const runtimeValue = (_a = sequence.controls) === null || _a === void 0 ? void 0 : _a.currentRuntimeValueDotNotation.hidden;
450
+ const effective = (propStatus !== null && propStatus !== void 0 ? propStatus : runtimeValue);
451
+ return effective !== null && effective !== void 0 ? effective : false;
452
+ }, [codeHiddenStatus, (_a = sequence.controls) === null || _a === void 0 ? void 0 : _a.currentRuntimeValueDotNotation]);
453
+ const displayName = (0, react_1.useMemo)(() => {
454
+ if (codeNameStatus &&
455
+ codeNameStatus.status === 'static' &&
456
+ typeof codeNameStatus.codeValue === 'string') {
457
+ return codeNameStatus.codeValue;
458
+ }
459
+ return sequence.displayName;
460
+ }, [codeNameStatus, sequence.displayName]);
461
+ const onToggleVisibility = (0, react_1.useCallback)((type) => {
462
+ if (!sequence.controls ||
463
+ !nodePath ||
464
+ !validatedLocation ||
465
+ !propStatusesForOverride ||
466
+ !codeHiddenStatus ||
467
+ codeHiddenStatus.status !== 'static' ||
468
+ previewServerState.type !== 'connected') {
469
+ return;
470
+ }
471
+ const newValue = type !== 'enable';
472
+ const { schema } = sequence.controls;
473
+ const fieldSchema = schema.hidden;
474
+ const defaultValue = fieldSchema && fieldSchema.type === 'boolean'
475
+ ? JSON.stringify(fieldSchema.default)
476
+ : null;
477
+ (0, save_sequence_prop_1.saveSequenceProps)({
478
+ changes: [
479
+ {
480
+ fileName: validatedLocation.source,
481
+ nodePath,
482
+ fieldKey: 'hidden',
483
+ value: newValue,
484
+ defaultValue,
485
+ schema,
486
+ },
487
+ ],
488
+ setPropStatuses,
489
+ clientId: previewServerState.clientId,
490
+ undoLabel: newValue ? 'Hide sequence' : 'Show sequence',
491
+ redoLabel: newValue ? 'Hide sequence again' : 'Show sequence again',
492
+ });
493
+ }, [
494
+ codeHiddenStatus,
495
+ propStatusesForOverride,
496
+ nodePath,
497
+ previewServerState,
498
+ sequence.controls,
499
+ setPropStatuses,
500
+ validatedLocation,
501
+ ]);
502
+ const outerHeight = (0, react_1.useMemo)(() => (0, timeline_layout_1.getTimelineLayerHeight)(sequence.type) + timeline_layout_1.TIMELINE_ITEM_BORDER_BOTTOM, [sequence.type]);
503
+ const inner = (0, react_1.useMemo)(() => {
504
+ return {
505
+ height: timeline_layout_1.TIMELINE_LIST_ITEM_ROW_HEIGHT,
506
+ color: 'white',
507
+ fontFamily: 'Arial, Helvetica, sans-serif',
508
+ wordBreak: 'break-all',
509
+ textAlign: 'left',
510
+ flexShrink: 0,
511
+ };
512
+ }, []);
513
+ const rowStyle = (0, react_1.useMemo)(() => {
514
+ return effectDropHovered
515
+ ? {
516
+ ...inner,
517
+ ...effectDropHighlight,
518
+ }
519
+ : inner;
520
+ }, [effectDropHovered, inner]);
521
+ const hasExpandableContent = Boolean(sequence.controls) || sequence.effects.length > 0;
522
+ const canToggleVisibility = previewConnected &&
523
+ Boolean(sequence.controls) &&
524
+ nodePath !== null &&
525
+ validatedLocation !== null &&
526
+ codeHiddenStatus !== undefined &&
527
+ codeHiddenStatus !== null &&
528
+ codeHiddenStatus.status === 'static';
529
+ const canRenameThisSequence = previewServerState.type === 'connected' &&
530
+ !window.remotion_isReadOnlyStudio &&
531
+ Boolean(sequence.controls) &&
532
+ nodePath !== null &&
533
+ validatedLocation !== null &&
534
+ codeNameStatus !== undefined &&
535
+ codeNameStatus !== null &&
536
+ codeNameStatus.status === 'static';
537
+ const canRenameSelectedSequence = canRenameThisSequence &&
538
+ selected &&
539
+ selectedItems.length === 1 &&
540
+ ((_b = selectedItems[0]) === null || _b === void 0 ? void 0 : _b.type) === 'sequence';
541
+ const onCancelRenaming = (0, react_1.useCallback)(() => {
542
+ setIsRenaming(false);
543
+ }, []);
544
+ const onSaveName = (0, react_1.useCallback)(async (name) => {
545
+ if (!canRenameThisSequence ||
546
+ previewServerState.type !== 'connected' ||
547
+ !sequence.controls ||
548
+ !nodePath ||
549
+ !validatedLocation) {
550
+ setIsRenaming(false);
551
+ return;
552
+ }
553
+ if (name === displayName) {
554
+ setIsRenaming(false);
555
+ return;
556
+ }
557
+ const savePromise = (0, save_sequence_prop_1.saveSequenceProps)({
558
+ changes: [
559
+ {
560
+ fileName: validatedLocation.source,
561
+ nodePath,
562
+ fieldKey: 'name',
563
+ value: name,
564
+ defaultValue: null,
565
+ schema: sequence.controls.schema,
566
+ },
567
+ ],
568
+ setPropStatuses,
569
+ clientId: previewServerState.clientId,
570
+ undoLabel: 'Rename sequence',
571
+ redoLabel: 'Rename sequence again',
572
+ });
573
+ setIsRenaming(false);
574
+ await savePromise;
575
+ }, [
576
+ canRenameThisSequence,
577
+ displayName,
578
+ nodePath,
579
+ previewServerState,
580
+ sequence.controls,
581
+ setPropStatuses,
582
+ validatedLocation,
583
+ ]);
584
+ react_1.default.useEffect(() => {
585
+ if (!canRenameSelectedSequence || !process.env.KEYBOARD_SHORTCUTS_ENABLED) {
586
+ setIsRenaming(false);
587
+ return;
588
+ }
589
+ const onKeyDown = (e) => {
590
+ if (!isHighestContext) {
591
+ return;
592
+ }
593
+ const commandKey = window.navigator.platform.startsWith('Mac')
594
+ ? e.metaKey
595
+ : e.ctrlKey;
596
+ if (commandKey || e.key.toLowerCase() !== 'enter') {
597
+ return;
598
+ }
599
+ if (document.activeElement instanceof HTMLInputElement ||
600
+ document.activeElement instanceof HTMLTextAreaElement) {
601
+ return;
602
+ }
603
+ e.preventDefault();
604
+ e.stopImmediatePropagation();
605
+ setIsRenaming(true);
606
+ };
607
+ window.addEventListener('keydown', onKeyDown, true);
608
+ return () => {
609
+ window.removeEventListener('keydown', onKeyDown, true);
610
+ };
611
+ }, [canRenameSelectedSequence, isHighestContext]);
612
+ const onRenameSequence = (0, react_1.useCallback)(() => {
613
+ if (!canRenameThisSequence) {
614
+ return;
615
+ }
616
+ setIsRenaming(true);
617
+ }, [canRenameThisSequence]);
381
618
  const contextMenuValues = (0, react_1.useMemo)(() => {
382
619
  if (!previewConnected) {
383
620
  return [];
@@ -463,6 +700,34 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
463
700
  id: 'open-component-docs-divider',
464
701
  }
465
702
  : null,
703
+ {
704
+ type: 'item',
705
+ id: 'rename-sequence',
706
+ keyHint: 'Enter',
707
+ label: 'Rename...',
708
+ leftItem: null,
709
+ disabled: !canRenameThisSequence,
710
+ onClick: () => {
711
+ onRenameSequence();
712
+ },
713
+ quickSwitcherLabel: null,
714
+ subMenu: null,
715
+ value: 'rename-sequence',
716
+ },
717
+ {
718
+ type: 'item',
719
+ id: 'disable-interactivity',
720
+ keyHint: null,
721
+ label: 'Disable interactivity',
722
+ leftItem: null,
723
+ disabled: disableInteractivityDisabled,
724
+ onClick: () => {
725
+ onDisableSequenceInteractivity();
726
+ },
727
+ quickSwitcherLabel: null,
728
+ subMenu: null,
729
+ value: 'disable-interactivity',
730
+ },
466
731
  {
467
732
  type: 'item',
468
733
  id: 'duplicate-sequence',
@@ -500,122 +765,25 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
500
765
  ].filter(no_react_1.NoReactInternals.truthy);
501
766
  }, [
502
767
  assetLinkInfo,
768
+ canOpenInEditor,
769
+ canRenameThisSequence,
503
770
  deleteDisabled,
771
+ disableInteractivityDisabled,
504
772
  duplicateDisabled,
505
773
  fileLocation,
506
774
  onDeleteSequenceFromSource,
775
+ onDisableSequenceInteractivity,
507
776
  onDuplicateSequenceFromSource,
508
- canOpenInEditor,
777
+ onRenameSequence,
509
778
  openInEditor,
510
779
  previewConnected,
511
780
  selectAsset,
512
781
  sequence,
513
782
  ]);
514
- const isExpanded = previewConnected && nodePathInfo !== null && getIsExpanded(nodePathInfo);
515
- const onToggleExpand = (0, react_1.useCallback)(() => {
516
- if (nodePathInfo === null) {
517
- return;
518
- }
519
- toggleTrack(nodePathInfo);
520
- }, [nodePathInfo, toggleTrack]);
521
- const onShowInEditorDoubleClick = (0, react_1.useCallback)((e) => {
522
- if (!TimelineSelection_1.SELECTION_ENABLED || !canOpenInEditor) {
523
- return;
524
- }
525
- if ((0, TimelineSelection_1.isTimelineSelectionModifierEvent)(e)) {
526
- e.stopPropagation();
527
- return;
528
- }
529
- e.stopPropagation();
530
- openInEditor();
531
- }, [canOpenInEditor, openInEditor]);
532
- const propStatusesForOverride = (0, react_1.useMemo)(() => {
533
- return nodePath
534
- ? remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath)
535
- : undefined;
536
- }, [propStatuses, nodePath]);
537
- const codeHiddenStatus = propStatusesForOverride === null || propStatusesForOverride === void 0 ? void 0 : propStatusesForOverride.hidden;
538
- const isItemHidden = (0, react_1.useMemo)(() => {
539
- var _a;
540
- const propStatus = codeHiddenStatus && codeHiddenStatus.status === 'static'
541
- ? codeHiddenStatus.codeValue
542
- : undefined;
543
- const runtimeValue = (_a = sequence.controls) === null || _a === void 0 ? void 0 : _a.currentRuntimeValueDotNotation.hidden;
544
- const effective = (propStatus !== null && propStatus !== void 0 ? propStatus : runtimeValue);
545
- return effective !== null && effective !== void 0 ? effective : false;
546
- }, [codeHiddenStatus, (_a = sequence.controls) === null || _a === void 0 ? void 0 : _a.currentRuntimeValueDotNotation]);
547
- const onToggleVisibility = (0, react_1.useCallback)((type) => {
548
- if (!sequence.controls ||
549
- !nodePath ||
550
- !validatedLocation ||
551
- !propStatusesForOverride ||
552
- !codeHiddenStatus ||
553
- codeHiddenStatus.status !== 'static' ||
554
- previewServerState.type !== 'connected') {
555
- return;
556
- }
557
- const newValue = type !== 'enable';
558
- const { schema } = sequence.controls;
559
- const fieldSchema = schema.hidden;
560
- const defaultValue = fieldSchema && fieldSchema.type === 'boolean'
561
- ? JSON.stringify(fieldSchema.default)
562
- : null;
563
- (0, save_sequence_prop_1.saveSequenceProps)({
564
- changes: [
565
- {
566
- fileName: validatedLocation.source,
567
- nodePath,
568
- fieldKey: 'hidden',
569
- value: newValue,
570
- defaultValue,
571
- schema,
572
- },
573
- ],
574
- setPropStatuses,
575
- clientId: previewServerState.clientId,
576
- undoLabel: newValue ? 'Hide sequence' : 'Show sequence',
577
- redoLabel: newValue ? 'Hide sequence again' : 'Show sequence again',
578
- });
579
- }, [
580
- codeHiddenStatus,
581
- propStatusesForOverride,
582
- nodePath,
583
- previewServerState,
584
- sequence.controls,
585
- setPropStatuses,
586
- validatedLocation,
587
- ]);
588
- const outerHeight = (0, react_1.useMemo)(() => (0, timeline_layout_1.getTimelineLayerHeight)(sequence.type) + timeline_layout_1.TIMELINE_ITEM_BORDER_BOTTOM, [sequence.type]);
589
- const inner = (0, react_1.useMemo)(() => {
590
- return {
591
- height: timeline_layout_1.TIMELINE_LIST_ITEM_ROW_HEIGHT,
592
- color: 'white',
593
- fontFamily: 'Arial, Helvetica, sans-serif',
594
- wordBreak: 'break-all',
595
- textAlign: 'left',
596
- flexShrink: 0,
597
- };
598
- }, []);
599
- const rowStyle = (0, react_1.useMemo)(() => {
600
- return effectDropHovered
601
- ? {
602
- ...inner,
603
- ...effectDropHighlight,
604
- }
605
- : inner;
606
- }, [effectDropHovered, inner]);
607
- const hasExpandableContent = Boolean(sequence.controls) || sequence.effects.length > 0;
608
- const canToggleVisibility = previewConnected &&
609
- Boolean(sequence.controls) &&
610
- nodePath !== null &&
611
- validatedLocation !== null &&
612
- codeHiddenStatus !== undefined &&
613
- codeHiddenStatus !== null &&
614
- codeHiddenStatus.status === 'static';
615
783
  const canDropEffect = previewServerState.type === 'connected' &&
616
784
  nodePath !== null &&
617
785
  validatedLocation !== null &&
618
- ((_b = sequence.controls) === null || _b === void 0 ? void 0 : _b.supportsEffects) === true;
786
+ ((_c = sequence.controls) === null || _c === void 0 ? void 0 : _c.supportsEffects) === true;
619
787
  const sequenceReorderLineStyle = (0, react_1.useMemo)(() => {
620
788
  if (!sequenceDropIndicator) {
621
789
  return null;
@@ -628,7 +796,7 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
628
796
  const onEffectDragOver = (0, react_1.useCallback)((e) => {
629
797
  if (!canDropEffect ||
630
798
  isSequenceReorderDrag(e.dataTransfer) ||
631
- !hasEffectDragType(e.dataTransfer)) {
799
+ !(0, effect_drag_and_drop_1.hasEffectDragType)(e.dataTransfer)) {
632
800
  return;
633
801
  }
634
802
  e.preventDefault();
@@ -647,43 +815,35 @@ const TimelineSequenceItem = ({ nestedDepth, sequence, nodePathInfo, keyframeDis
647
815
  nodePath === null ||
648
816
  validatedLocation === null ||
649
817
  isSequenceReorderDrag(e.dataTransfer) ||
650
- !hasEffectDragType(e.dataTransfer)) {
818
+ !(0, effect_drag_and_drop_1.hasEffectDragType)(e.dataTransfer)) {
651
819
  return;
652
820
  }
653
- e.preventDefault();
654
- e.stopPropagation();
655
- setEffectDropHovered(false);
656
- const dragData = getEffectDragData(e.dataTransfer);
821
+ const dragData = (0, effect_drag_and_drop_1.getEffectDragData)(e.dataTransfer);
657
822
  if (!dragData) {
658
- (0, NotificationCenter_1.showNotification)('Could not read effect drag data', 3000);
659
- return;
660
- }
661
- try {
662
- const requiredPackage = (0, studio_shared_1.getRequiredPackageForEffectImportPath)(dragData.effect.importPath);
663
- await (0, install_required_package_1.installRequiredPackages)(requiredPackage ? [requiredPackage] : []);
664
- const result = await (0, call_api_1.callApi)('/api/add-effect', {
665
- fileName: validatedLocation.source,
666
- sequenceNodePath: nodePath,
667
- effectName: dragData.effect.name,
668
- effectImportPath: dragData.effect.importPath,
669
- effectConfig: dragData.effect.config,
670
- clientId: previewServerState.clientId,
671
- });
672
- if (result.success) {
673
- (0, NotificationCenter_1.showNotification)(`Added ${dragData.effect.name}()`, 2000);
674
- }
675
- else {
676
- (0, NotificationCenter_1.showNotification)(result.reason, 4000);
823
+ if ((0, effect_drag_and_drop_1.hasExplicitEffectDragType)(e.dataTransfer)) {
824
+ e.preventDefault();
825
+ e.stopPropagation();
826
+ setEffectDropHovered(false);
827
+ (0, NotificationCenter_1.showNotification)('Could not read effect drag data', 3000);
677
828
  }
829
+ return;
678
830
  }
679
- catch (err) {
680
- (0, NotificationCenter_1.showNotification)(err.message, 4000);
681
- }
831
+ e.preventDefault();
832
+ e.stopPropagation();
833
+ setEffectDropHovered(false);
834
+ await (0, effect_drag_and_drop_1.addEffectFromDragData)({
835
+ dragData,
836
+ fileName: validatedLocation.source,
837
+ nodePath,
838
+ clientId: previewServerState.clientId,
839
+ });
682
840
  }, [canDropEffect, nodePath, previewServerState, validatedLocation]);
683
- const trackRow = (jsx_runtime_1.jsx(TimelineRowChrome_1.TimelineRowChrome, { depth: nestedDepth, eye: canToggleVisibility ? (jsx_runtime_1.jsx(TimelineLayerEye_1.TimelineLayerEye, { type: sequence.type === 'audio' ? 'speaker' : 'eye', hidden: isItemHidden, onInvoked: onToggleVisibility })) : (jsx_runtime_1.jsx(TimelineLayerEye_1.TimelineLayerEyeSpacer, {})), arrow: hasExpandableContent ? (jsx_runtime_1.jsx(TimelineExpandArrowButton_1.TimelineExpandArrowButton, { isExpanded: isExpanded, onClick: onToggleExpand, label: "track properties", disabled: !previewConnected || nodePathInfo === null })) : (jsx_runtime_1.jsx(TimelineExpandArrowButton_1.TimelineExpandArrowSpacer, {})), style: rowStyle, selected: selected, selectable: selectable, onSelect: onSelect, showSelectedBackground: true, containsSelection: containsSelection, outerHeight: outerHeight, onDragLeave: canDropEffect ? onEffectDragLeave : undefined, onDragOver: canDropEffect ? onEffectDragOver : undefined, onDrop: canDropEffect ? onEffectDrop : undefined, onDoubleClick: TimelineSelection_1.SELECTION_ENABLED && canOpenInEditor
684
- ? onShowInEditorDoubleClick
685
- : undefined, children: jsx_runtime_1.jsxs("div", { style: labelContainerStyle, children: [
686
- jsx_runtime_1.jsx(TimelineSequenceName_1.TimelineSequenceName, { sequence: sequence, selected: selected, containsSelection: containsSelection }), mediaSrc ? jsx_runtime_1.jsx(TimelineMediaInfo_1.TimelineMediaInfo, { src: mediaSrc }) : null, jsx_runtime_1.jsx(TimelineItemStack_1.TimelineItemStack, { originalLocation: originalLocation })
841
+ const trackRow = (jsx_runtime_1.jsx(TimelineRowChrome_1.TimelineRowChrome, { depth: nestedDepth, eye: canToggleVisibility ? (jsx_runtime_1.jsx(TimelineLayerEye_1.TimelineLayerEye, { type: sequence.type === 'audio' ? 'speaker' : 'eye', hidden: isItemHidden, onInvoked: onToggleVisibility })) : (jsx_runtime_1.jsx(TimelineLayerEye_1.TimelineLayerEyeSpacer, {})), arrow: hasExpandableContent ? (jsx_runtime_1.jsx(TimelineExpandArrowButton_1.TimelineExpandArrowButton, { isExpanded: isExpanded, onClick: onToggleExpand, label: "track properties", disabled: !previewConnected || nodePathInfo === null })) : (jsx_runtime_1.jsx(TimelineExpandArrowButton_1.TimelineExpandArrowSpacer, {})), style: rowStyle, selected: selected, selectable: selectable, onSelect: onSelect, showSelectedBackground: true, containsSelection: containsSelection, outerHeight: outerHeight, onDragLeave: canDropEffect ? onEffectDragLeave : undefined, onDragOver: canDropEffect ? onEffectDragOver : undefined, onDrop: canDropEffect ? onEffectDrop : undefined, onDoubleClick: canOpenInEditor ? onShowInEditorDoubleClick : undefined, children: jsx_runtime_1.jsxs("div", { style: labelContainerStyle, children: [
842
+ jsx_runtime_1.jsx(TimelineSequenceName_1.TimelineSequenceName, { displayName: displayName, selected: selected, containsSelection: containsSelection, editing: isRenaming, onCancelEditing: onCancelRenaming, onSaveName: onSaveName }), mediaSrc ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
843
+ jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }),
844
+ " ",
845
+ jsx_runtime_1.jsx(TimelineMediaInfo_1.TimelineMediaInfo, { src: mediaSrc })
846
+ ] })) : null, jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(TimelineItemStack_1.TimelineItemStack, { originalLocation: originalLocation })
687
847
  ] }) }));
688
848
  const draggableTrackRow = canHandleSequenceDrag ? (jsx_runtime_1.jsxs("div", { draggable: canReorderSequence, onDragStart: onSequenceDragStart, onDragEnd: onSequenceDragEnd, onDragOver: onSequenceDragOver, onDragLeave: onSequenceDragLeave, onDrop: onSequenceDrop, style: sequenceReorderWrapper, children: [sequenceReorderLineStyle ? (jsx_runtime_1.jsx("div", { style: sequenceReorderLineStyle })) : null, sequenceDropRejection ? (jsx_runtime_1.jsx("div", { style: sequenceReorderRejectionStyle, children: sequenceDropRejection })) : null, trackRow] })) : (trackRow);
689
849
  return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [previewConnected ? (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { values: contextMenuValues, onOpen: selectable ? onSelect : null, children: draggableTrackRow })) : (draggableTrackRow), previewConnected &&
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
- import type { TSequence } from 'remotion';
3
2
  export declare const TimelineSequenceName: React.FC<{
4
- readonly sequence: TSequence;
3
+ readonly displayName: string;
5
4
  readonly selected: boolean;
6
5
  readonly containsSelection: boolean;
6
+ readonly editing: boolean;
7
+ readonly onCancelEditing: () => void;
8
+ readonly onSaveName: (name: string) => Promise<void>;
7
9
  }>;