@remotion/studio 4.0.468 → 4.0.470

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 (134) hide show
  1. package/dist/Studio.js +1 -1
  2. package/dist/api/save-render-output.js +3 -12
  3. package/dist/components/AudioWaveform.d.ts +1 -0
  4. package/dist/components/AudioWaveform.js +41 -23
  5. package/dist/components/CompositionSelectorItem.js +1 -1
  6. package/dist/components/ContextMenu.d.ts +1 -0
  7. package/dist/components/ContextMenu.js +8 -3
  8. package/dist/components/EditorContent.js +5 -4
  9. package/dist/components/EditorGuides/Guide.js +1 -1
  10. package/dist/components/ExpandedTracksProvider.js +3 -8
  11. package/dist/components/Menu/MenuItem.d.ts +1 -1
  12. package/dist/components/Menu/MenuItem.js +2 -2
  13. package/dist/components/Menu/MenuSubItem.js +5 -5
  14. package/dist/components/MenuBuildIndicator.js +0 -1
  15. package/dist/components/NewComposition/InputDragger.js +1 -0
  16. package/dist/components/Preview.js +4 -1
  17. package/dist/components/PreviewToolbar.js +2 -4
  18. package/dist/components/SelectedOutlineOverlay.d.ts +18 -0
  19. package/dist/components/SelectedOutlineOverlay.js +645 -0
  20. package/dist/components/Timeline/Timeline.js +18 -3
  21. package/dist/components/Timeline/TimelineDeleteKeybindings.d.ts +2 -0
  22. package/dist/components/Timeline/TimelineDeleteKeybindings.js +86 -0
  23. package/dist/components/Timeline/TimelineDragHandler.js +19 -244
  24. package/dist/components/Timeline/{TimelineEffectGroupRow.d.ts → TimelineEffectItem.d.ts} +1 -1
  25. package/dist/components/Timeline/{TimelineEffectGroupRow.js → TimelineEffectItem.js} +61 -35
  26. package/dist/components/Timeline/{TimelineEffectFieldRow.d.ts → TimelineEffectPropItem.d.ts} +4 -1
  27. package/dist/components/Timeline/{TimelineEffectFieldRow.js → TimelineEffectPropItem.js} +100 -16
  28. package/dist/components/Timeline/TimelineExpandArrowButton.js +5 -1
  29. package/dist/components/Timeline/TimelineExpandedKeyframeRow.d.ts +11 -0
  30. package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +55 -0
  31. package/dist/components/Timeline/TimelineExpandedRow.d.ts +1 -0
  32. package/dist/components/Timeline/TimelineExpandedRow.js +29 -11
  33. package/dist/components/Timeline/TimelineExpandedSection.d.ts +1 -0
  34. package/dist/components/Timeline/TimelineExpandedSection.js +4 -4
  35. package/dist/components/Timeline/TimelineExpandedTrackKeyframes.d.ts +1 -1
  36. package/dist/components/Timeline/TimelineExpandedTrackKeyframes.js +9 -120
  37. package/dist/components/Timeline/TimelineFieldLabel.d.ts +6 -0
  38. package/dist/components/Timeline/TimelineFieldLabel.js +30 -0
  39. package/dist/components/Timeline/TimelineInOutDragHandler.d.ts +2 -0
  40. package/dist/components/Timeline/TimelineInOutDragHandler.js +324 -0
  41. package/dist/components/Timeline/TimelineInOutPointer.js +3 -1
  42. package/dist/components/Timeline/TimelineInOutPointerHandle.d.ts +1 -0
  43. package/dist/components/Timeline/TimelineInOutPointerHandle.js +5 -4
  44. package/dist/components/Timeline/TimelineItemStack.d.ts +5 -0
  45. package/dist/components/Timeline/TimelineItemStack.js +82 -0
  46. package/dist/components/Timeline/TimelineKeyframeControls.d.ts +17 -0
  47. package/dist/components/Timeline/TimelineKeyframeControls.js +217 -0
  48. package/dist/components/Timeline/TimelineKeyframeDiamond.d.ts +7 -0
  49. package/dist/components/Timeline/TimelineKeyframeDiamond.js +88 -0
  50. package/dist/components/Timeline/TimelineKeyframedValue.d.ts +8 -0
  51. package/dist/components/Timeline/TimelineKeyframedValue.js +36 -0
  52. package/dist/components/Timeline/TimelineLayerEye.js +1 -0
  53. package/dist/components/Timeline/TimelineList.js +3 -11
  54. package/dist/components/Timeline/TimelineMediaInfo.d.ts +13 -1
  55. package/dist/components/Timeline/TimelineMediaInfo.js +33 -80
  56. package/dist/components/Timeline/TimelineRowChrome.d.ts +10 -1
  57. package/dist/components/Timeline/TimelineRowChrome.js +64 -6
  58. package/dist/components/Timeline/TimelineSchemaField.js +7 -2
  59. package/dist/components/Timeline/TimelineSelection.d.ts +85 -0
  60. package/dist/components/Timeline/TimelineSelection.js +417 -0
  61. package/dist/components/Timeline/TimelineSequence.d.ts +2 -0
  62. package/dist/components/Timeline/TimelineSequence.js +18 -6
  63. package/dist/components/Timeline/TimelineSequenceFrame.js +1 -0
  64. package/dist/components/Timeline/{TimelineListItem.d.ts → TimelineSequenceItem.d.ts} +2 -2
  65. package/dist/components/Timeline/{TimelineListItem.js → TimelineSequenceItem.js} +148 -63
  66. package/dist/components/Timeline/TimelineSequenceName.d.ts +7 -0
  67. package/dist/components/Timeline/TimelineSequenceName.js +50 -0
  68. package/dist/components/Timeline/{TimelineFieldRow.d.ts → TimelineSequencePropItem.d.ts} +5 -3
  69. package/dist/components/Timeline/TimelineSequencePropItem.js +183 -0
  70. package/dist/components/Timeline/TimelineTimeIndicators.js +0 -1
  71. package/dist/components/Timeline/TimelineTrack.d.ts +5 -0
  72. package/dist/components/Timeline/TimelineTrack.js +66 -0
  73. package/dist/components/Timeline/TimelineTracks.js +2 -16
  74. package/dist/components/Timeline/TimelineTranslateField.js +14 -22
  75. package/dist/components/Timeline/TimelineUvCoordinateField.d.ts +11 -0
  76. package/dist/components/Timeline/TimelineUvCoordinateField.js +126 -0
  77. package/dist/components/Timeline/TimelineVideoInfo.js +11 -12
  78. package/dist/components/Timeline/call-add-keyframe.d.ts +23 -0
  79. package/dist/components/Timeline/call-add-keyframe.js +54 -0
  80. package/dist/components/Timeline/call-delete-keyframe.d.ts +21 -0
  81. package/dist/components/Timeline/call-delete-keyframe.js +50 -0
  82. package/dist/components/Timeline/delete-selected-keyframe.d.ts +11 -0
  83. package/dist/components/Timeline/delete-selected-keyframe.js +51 -0
  84. package/dist/components/Timeline/delete-selected-timeline-item.d.ts +17 -0
  85. package/dist/components/Timeline/delete-selected-timeline-item.js +183 -0
  86. package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +13 -0
  87. package/dist/components/Timeline/duplicate-selected-timeline-item.js +66 -0
  88. package/dist/components/Timeline/find-track-for-node-path-info.d.ts +7 -0
  89. package/dist/components/Timeline/find-track-for-node-path-info.js +13 -0
  90. package/dist/components/Timeline/get-keyframe-navigation.d.ts +9 -0
  91. package/dist/components/Timeline/get-keyframe-navigation.js +26 -0
  92. package/dist/components/Timeline/get-node-keyframes.d.ts +11 -0
  93. package/dist/components/Timeline/get-node-keyframes.js +23 -0
  94. package/dist/components/Timeline/get-timeline-keyframes.js +6 -8
  95. package/dist/components/Timeline/parse-keyframe-field-from-node-path.d.ts +8 -0
  96. package/dist/components/Timeline/parse-keyframe-field-from-node-path.js +26 -0
  97. package/dist/components/Timeline/save-sequence-prop.d.ts +14 -2
  98. package/dist/components/Timeline/save-sequence-prop.js +42 -7
  99. package/dist/components/Timeline/timeline-field-row-layout.d.ts +1 -0
  100. package/dist/components/Timeline/timeline-field-row-layout.js +11 -1
  101. package/dist/components/Timeline/timeline-row-layout.d.ts +1 -0
  102. package/dist/components/Timeline/timeline-row-layout.js +2 -1
  103. package/dist/components/Timeline/timeline-translate-utils.d.ts +2 -0
  104. package/dist/components/Timeline/timeline-translate-utils.js +20 -0
  105. package/dist/components/Timeline/use-expanded-track-keyframe-rows.d.ts +17 -0
  106. package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +52 -0
  107. package/dist/components/Timeline/use-open-sequence-in-editor.d.ts +6 -0
  108. package/dist/components/Timeline/use-open-sequence-in-editor.js +31 -0
  109. package/dist/components/composition-menu-items.js +32 -1
  110. package/dist/error-overlay/remotion-overlay/OpenInEditor.js +0 -1
  111. package/dist/esm/{chunk-8q828zk7.js → chunk-dny42qnq.js} +10566 -6221
  112. package/dist/esm/internals.mjs +10566 -6221
  113. package/dist/esm/previewEntry.mjs +10548 -6203
  114. package/dist/esm/renderEntry.mjs +3 -1
  115. package/dist/helpers/colors.d.ts +1 -1
  116. package/dist/helpers/colors.js +1 -1
  117. package/dist/helpers/format-file-location.d.ts +9 -0
  118. package/dist/helpers/format-file-location.js +27 -0
  119. package/dist/helpers/get-box-quads-polyfill-internals.d.ts +82 -0
  120. package/dist/helpers/get-box-quads-polyfill-internals.js +2395 -0
  121. package/dist/helpers/get-box-quads-ponyfill.d.ts +10 -0
  122. package/dist/helpers/get-box-quads-ponyfill.js +23 -0
  123. package/dist/helpers/open-in-editor.d.ts +1 -1
  124. package/dist/helpers/open-in-editor.js +11 -26
  125. package/dist/helpers/timeline-layout.d.ts +8 -7
  126. package/dist/helpers/timeline-layout.js +9 -8
  127. package/dist/helpers/timeline-node-path-key.d.ts +2 -0
  128. package/dist/helpers/timeline-node-path-key.js +10 -0
  129. package/dist/helpers/use-menu-structure.js +8 -16
  130. package/dist/renderEntry.js +2 -2
  131. package/package.json +10 -10
  132. package/dist/components/Timeline/TimelineFieldRow.js +0 -113
  133. package/dist/components/Timeline/TimelineStack/index.d.ts +0 -8
  134. package/dist/components/Timeline/TimelineStack/index.js +0 -119
@@ -1,12 +1,24 @@
1
1
  import type { CanUpdateSequencePropsResponse, SequencePropsSubscriptionKey, SequenceSchema } from 'remotion';
2
2
  export type SetCodeValues = (nodePath: SequencePropsSubscriptionKey, values: (prev: CanUpdateSequencePropsResponse) => CanUpdateSequencePropsResponse) => void;
3
- export declare const saveSequenceProp: ({ fileName, nodePath, fieldKey, value, defaultValue, schema, setCodeValues, clientId, }: {
3
+ export type SaveSequencePropChange = {
4
4
  fileName: string;
5
5
  nodePath: SequencePropsSubscriptionKey;
6
6
  fieldKey: string;
7
7
  value: unknown;
8
8
  defaultValue: string | null;
9
9
  schema: SequenceSchema;
10
+ };
11
+ type SaveSequencePropsOptions = {
12
+ changes: SaveSequencePropChange[];
10
13
  setCodeValues: SetCodeValues;
11
14
  clientId: string;
12
- }) => Promise<void>;
15
+ undoLabel: string | null;
16
+ redoLabel: string | null;
17
+ };
18
+ type SaveSequencePropOptions = SaveSequencePropChange & {
19
+ setCodeValues: SetCodeValues;
20
+ clientId: string;
21
+ };
22
+ export declare const saveSequenceProps: ({ changes, setCodeValues, clientId, undoLabel, redoLabel, }: SaveSequencePropsOptions) => Promise<void>;
23
+ export declare const saveSequenceProp: ({ fileName, nodePath, fieldKey, value, defaultValue, schema, setCodeValues, clientId, }: SaveSequencePropOptions) => Promise<void>;
24
+ export {};
@@ -1,9 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveSequenceProp = void 0;
3
+ exports.saveSequenceProp = exports.saveSequenceProps = void 0;
4
4
  const studio_shared_1 = require("@remotion/studio-shared");
5
5
  const call_api_1 = require("../call-api");
6
6
  const save_prop_queue_1 = require("./save-prop-queue");
7
+ const saveSequenceProps = ({ changes, setCodeValues, clientId, undoLabel, redoLabel, }) => {
8
+ if (changes.length === 0) {
9
+ return Promise.resolve();
10
+ }
11
+ for (const change of changes) {
12
+ setCodeValues(change.nodePath, (prev) => (0, studio_shared_1.optimisticUpdateForCodeValues)({
13
+ previous: prev,
14
+ fieldKey: change.fieldKey,
15
+ value: change.value,
16
+ schema: change.schema,
17
+ }));
18
+ }
19
+ return (0, call_api_1.callApi)('/api/save-sequence-props', {
20
+ edits: changes.map((change) => {
21
+ return {
22
+ fileName: change.fileName,
23
+ nodePath: change.nodePath,
24
+ key: change.fieldKey,
25
+ value: JSON.stringify(change.value),
26
+ defaultValue: change.defaultValue,
27
+ schema: change.schema,
28
+ };
29
+ }),
30
+ clientId,
31
+ undoLabel,
32
+ redoLabel,
33
+ }).then(() => undefined);
34
+ };
35
+ exports.saveSequenceProps = saveSequenceProps;
7
36
  const saveSequenceProp = ({ fileName, nodePath, fieldKey, value, defaultValue, schema, setCodeValues, clientId, }) => {
8
37
  return (0, save_prop_queue_1.enqueueSavePropChange)({
9
38
  nodePath,
@@ -15,13 +44,19 @@ const saveSequenceProp = ({ fileName, nodePath, fieldKey, value, defaultValue, s
15
44
  schema,
16
45
  }),
17
46
  apiCall: () => (0, call_api_1.callApi)('/api/save-sequence-props', {
18
- fileName,
19
- nodePath,
20
- key: fieldKey,
21
- value: JSON.stringify(value),
22
- defaultValue,
23
- schema,
47
+ edits: [
48
+ {
49
+ fileName,
50
+ nodePath,
51
+ key: fieldKey,
52
+ value: JSON.stringify(value),
53
+ defaultValue,
54
+ schema,
55
+ },
56
+ ],
24
57
  clientId,
58
+ undoLabel: null,
59
+ redoLabel: null,
25
60
  }),
26
61
  errorLabel: 'Could not save sequence prop',
27
62
  });
@@ -1,2 +1,3 @@
1
1
  import type React from 'react';
2
2
  export declare const getTimelineFieldLabelRowStyle: (depth: number) => React.CSSProperties;
3
+ export declare const timelineFieldValueColumnStyle: React.CSSProperties;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTimelineFieldLabelRowStyle = void 0;
3
+ exports.timelineFieldValueColumnStyle = exports.getTimelineFieldLabelRowStyle = void 0;
4
+ const timeline_layout_1 = require("../../helpers/timeline-layout");
4
5
  const timeline_row_layout_1 = require("./timeline-row-layout");
5
6
  const getTimelineFieldLabelRowStyle = (depth) => {
6
7
  return {
7
8
  flex: `0 0 ${(0, timeline_row_layout_1.getTimelineFieldLabelFlexBasis)(depth)}`,
9
+ minWidth: 0,
8
10
  display: 'flex',
9
11
  flexDirection: 'row',
10
12
  alignItems: 'center',
@@ -12,3 +14,11 @@ const getTimelineFieldLabelRowStyle = (depth) => {
12
14
  };
13
15
  };
14
16
  exports.getTimelineFieldLabelRowStyle = getTimelineFieldLabelRowStyle;
17
+ exports.timelineFieldValueColumnStyle = {
18
+ alignItems: 'center',
19
+ alignSelf: 'stretch',
20
+ display: 'flex',
21
+ flex: 1,
22
+ minWidth: 0,
23
+ paddingRight: timeline_layout_1.EXPANDED_SECTION_PADDING_RIGHT,
24
+ };
@@ -1,6 +1,7 @@
1
1
  export declare const TIMELINE_ROW_BASE_PADDING = 5;
2
2
  export declare const TIMELINE_EYE_COLUMN_WIDTH = 22;
3
3
  export declare const TIMELINE_ARROW_COLUMN_WIDTH = 16;
4
+ export declare const TIMELINE_KEYFRAME_CONTROLS_WIDTH = 38;
4
5
  export declare const TIMELINE_FIELD_LABEL_EXTRA_WIDTH = 15;
5
6
  export declare const getTimelineRowIndentWidth: (depth: number) => number;
6
7
  export declare const getTimelineRowLeftChromeWidth: (depth: number) => number;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExpandedRowDepth = exports.getTimelineFieldLabelFlexBasis = exports.getTimelineRowLeftChromeWidth = exports.getTimelineRowIndentWidth = exports.TIMELINE_FIELD_LABEL_EXTRA_WIDTH = exports.TIMELINE_ARROW_COLUMN_WIDTH = exports.TIMELINE_EYE_COLUMN_WIDTH = exports.TIMELINE_ROW_BASE_PADDING = void 0;
3
+ exports.getExpandedRowDepth = exports.getTimelineFieldLabelFlexBasis = exports.getTimelineRowLeftChromeWidth = exports.getTimelineRowIndentWidth = exports.TIMELINE_FIELD_LABEL_EXTRA_WIDTH = exports.TIMELINE_KEYFRAME_CONTROLS_WIDTH = exports.TIMELINE_ARROW_COLUMN_WIDTH = exports.TIMELINE_EYE_COLUMN_WIDTH = exports.TIMELINE_ROW_BASE_PADDING = void 0;
4
4
  const timeline_indent_1 = require("./timeline-indent");
5
5
  exports.TIMELINE_ROW_BASE_PADDING = 5;
6
6
  exports.TIMELINE_EYE_COLUMN_WIDTH = 22;
7
7
  exports.TIMELINE_ARROW_COLUMN_WIDTH = 16;
8
+ exports.TIMELINE_KEYFRAME_CONTROLS_WIDTH = 38;
8
9
  exports.TIMELINE_FIELD_LABEL_EXTRA_WIDTH = 15;
9
10
  const getTimelineRowIndentWidth = (depth) => {
10
11
  return depth * timeline_indent_1.TIMELINE_INDENT;
@@ -0,0 +1,2 @@
1
+ export declare const parseTranslate: (value: string) => [number, number];
2
+ export declare const serializeTranslate: (x: number, y: number) => string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeTranslate = exports.parseTranslate = void 0;
4
+ const PIXEL_PATTERN = /^(-?\d+(?:\.\d+)?)px(?:\s+(-?\d+(?:\.\d+)?)px)?$/;
5
+ const parseTranslate = (value) => {
6
+ const m = value.match(PIXEL_PATTERN);
7
+ if (!m) {
8
+ return [0, 0];
9
+ }
10
+ return [Number(m[1]), m[2] !== undefined ? Number(m[2]) : 0];
11
+ };
12
+ exports.parseTranslate = parseTranslate;
13
+ const formatTranslateCoordinate = (value) => {
14
+ const rounded = Math.round(value * 1000) / 1000;
15
+ return String(Object.is(rounded, -0) ? 0 : rounded);
16
+ };
17
+ const serializeTranslate = (x, y) => {
18
+ return `${formatTranslateCoordinate(x)}px ${formatTranslateCoordinate(y)}px`;
19
+ };
20
+ exports.serializeTranslate = serializeTranslate;
@@ -0,0 +1,17 @@
1
+ import { type TSequence } from 'remotion';
2
+ import type { SequenceNodePathInfo } from '../../helpers/get-timeline-sequence-sort-key';
3
+ import type { getTimelineKeyframes } from './get-timeline-keyframes';
4
+ export type ExpandedTrackKeyframeRow = {
5
+ readonly height: number;
6
+ readonly keyframes: ReturnType<typeof getTimelineKeyframes>;
7
+ readonly nodePathInfo: SequenceNodePathInfo;
8
+ readonly rowKey: string;
9
+ };
10
+ export declare const useExpandedTrackKeyframeRows: ({ sequence, nodePathInfo, keyframeDisplayOffset, }: {
11
+ sequence: TSequence;
12
+ nodePathInfo: SequenceNodePathInfo;
13
+ keyframeDisplayOffset: number;
14
+ }) => {
15
+ readonly rows: ExpandedTrackKeyframeRow[];
16
+ readonly expandedHeight: number;
17
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useExpandedTrackKeyframeRows = void 0;
4
+ const react_1 = require("react");
5
+ const remotion_1 = require("remotion");
6
+ const timeline_layout_1 = require("../../helpers/timeline-layout");
7
+ const timeline_node_path_key_1 = require("../../helpers/timeline-node-path-key");
8
+ const ExpandedTracksProvider_1 = require("../ExpandedTracksProvider");
9
+ const get_node_keyframes_1 = require("./get-node-keyframes");
10
+ const useExpandedTrackKeyframeRows = ({ sequence, nodePathInfo, keyframeDisplayOffset, }) => {
11
+ const { getIsExpanded } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksGetterContext);
12
+ const { codeValues } = (0, react_1.useContext)(remotion_1.Internals.VisualModeCodeValuesContext);
13
+ const { getDragOverrides, getEffectDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
14
+ const tree = (0, react_1.useMemo)(() => (0, timeline_layout_1.buildTimelineTree)({
15
+ sequence,
16
+ nodePathInfo,
17
+ getDragOverrides,
18
+ getEffectDragOverrides,
19
+ codeValues,
20
+ }), [
21
+ codeValues,
22
+ getDragOverrides,
23
+ getEffectDragOverrides,
24
+ nodePathInfo,
25
+ sequence,
26
+ ]);
27
+ const flat = (0, react_1.useMemo)(() => (0, timeline_layout_1.flattenVisibleTreeNodes)({ nodes: tree, getIsExpanded }), [tree, getIsExpanded]);
28
+ const expandedHeight = (0, react_1.useMemo)(() => (0, timeline_layout_1.getExpandedTrackHeight)({
29
+ sequence,
30
+ nodePathInfo,
31
+ getIsExpanded,
32
+ codeValues,
33
+ }), [codeValues, getIsExpanded, nodePathInfo, sequence]);
34
+ const rows = (0, react_1.useMemo)(() => flat.map(({ node }) => ({
35
+ height: (0, timeline_layout_1.getTreeRowHeight)(node),
36
+ keyframes: (0, get_node_keyframes_1.getNodeKeyframes)({
37
+ node,
38
+ nodePath: nodePathInfo.sequenceSubscriptionKey,
39
+ codeValues,
40
+ keyframeDisplayOffset,
41
+ }),
42
+ rowKey: (0, timeline_node_path_key_1.timelineNodePathInfoToKey)(node.nodePathInfo),
43
+ nodePathInfo: node.nodePathInfo,
44
+ })), [
45
+ codeValues,
46
+ flat,
47
+ keyframeDisplayOffset,
48
+ nodePathInfo.sequenceSubscriptionKey,
49
+ ]);
50
+ return { rows, expandedHeight };
51
+ };
52
+ exports.useExpandedTrackKeyframeRows = useExpandedTrackKeyframeRows;
@@ -0,0 +1,6 @@
1
+ import type { TSequence } from 'remotion';
2
+ export declare const useOpenSequenceInEditor: (sequence: TSequence) => {
3
+ canOpenInEditor: boolean;
4
+ openInEditor: () => Promise<void>;
5
+ originalLocation: import("remotion").ResolvedStackLocation | null;
6
+ };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOpenSequenceInEditor = void 0;
4
+ const react_1 = require("react");
5
+ const client_id_1 = require("../../helpers/client-id");
6
+ const open_in_editor_1 = require("../../helpers/open-in-editor");
7
+ const NotificationCenter_1 = require("../Notifications/NotificationCenter");
8
+ const use_resolved_stack_react_to_change_1 = require("./use-resolved-stack-react-to-change");
9
+ const useOpenSequenceInEditor = (sequence) => {
10
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
11
+ const previewConnected = previewServerState.type === 'connected';
12
+ const originalLocation = (0, use_resolved_stack_react_to_change_1.useResolveStackAndReactToChange)(sequence.getStack);
13
+ const canOpenInEditor = (0, react_1.useMemo)(() => Boolean(window.remotion_editorName && previewConnected && originalLocation), [originalLocation, previewConnected]);
14
+ const openInEditor = (0, react_1.useCallback)(async () => {
15
+ if (!canOpenInEditor || !originalLocation) {
16
+ return;
17
+ }
18
+ try {
19
+ await (0, open_in_editor_1.openOriginalPositionInEditor)(originalLocation);
20
+ }
21
+ catch (err) {
22
+ (0, NotificationCenter_1.showNotification)(err.message, 2000);
23
+ }
24
+ }, [canOpenInEditor, originalLocation]);
25
+ return {
26
+ canOpenInEditor,
27
+ openInEditor,
28
+ originalLocation,
29
+ };
30
+ };
31
+ exports.useOpenSequenceInEditor = useOpenSequenceInEditor;
@@ -2,12 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCompositionMenuItems = void 0;
4
4
  const no_react_1 = require("remotion/no-react");
5
+ const format_file_location_1 = require("../helpers/format-file-location");
5
6
  const open_in_editor_1 = require("../helpers/open-in-editor");
6
7
  const NotificationCenter_1 = require("./Notifications/NotificationCenter");
7
8
  const getCompositionMenuItems = ({ composition, connectionStatus, resolvedLocation, setSelectedModal, closeMenu, readOnlyStudio, }) => {
8
9
  const editorName = window.remotion_editorName;
10
+ const fileLocation = (0, format_file_location_1.formatFileLocation)({
11
+ location: resolvedLocation,
12
+ root: window.remotion_cwd,
13
+ });
9
14
  const showInEditorDisabled = !composition || connectionStatus !== 'connected' || !resolvedLocation;
10
15
  const openComponentInEditorDisabled = showInEditorDisabled || !(resolvedLocation === null || resolvedLocation === void 0 ? void 0 : resolvedLocation.source);
16
+ const copyFileLocationDisabled = !composition || !fileLocation;
11
17
  return [
12
18
  editorName
13
19
  ? {
@@ -34,6 +40,31 @@ const getCompositionMenuItems = ({ composition, connectionStatus, resolvedLocati
34
40
  disabled: showInEditorDisabled,
35
41
  }
36
42
  : null,
43
+ {
44
+ id: 'copy-file-location',
45
+ keyHint: null,
46
+ label: `Copy file location`,
47
+ leftItem: null,
48
+ onClick: () => {
49
+ closeMenu();
50
+ if (!fileLocation) {
51
+ return;
52
+ }
53
+ navigator.clipboard
54
+ .writeText(fileLocation)
55
+ .then(() => {
56
+ (0, NotificationCenter_1.showNotification)('Copied file location to clipboard', 1000);
57
+ })
58
+ .catch((err) => {
59
+ (0, NotificationCenter_1.showNotification)(`Could not copy to clipboard: ${err.message}`, 1000);
60
+ });
61
+ },
62
+ quickSwitcherLabel: 'Copy composition file location',
63
+ subMenu: null,
64
+ type: 'item',
65
+ value: 'copy-file-location',
66
+ disabled: copyFileLocationDisabled,
67
+ },
37
68
  editorName
38
69
  ? {
39
70
  id: 'open-component-in-editor',
@@ -62,7 +93,7 @@ const getCompositionMenuItems = ({ composition, connectionStatus, resolvedLocati
62
93
  disabled: openComponentInEditorDisabled,
63
94
  }
64
95
  : null,
65
- editorName
96
+ editorName || fileLocation
66
97
  ? {
67
98
  type: 'divider',
68
99
  id: 'show-in-editor-divider',
@@ -43,7 +43,6 @@ const OpenInEditor = ({ stack, canHaveKeyboardShortcuts }) => {
43
43
  const openInBrowser = (0, react_1.useCallback)(() => {
44
44
  dispatch({ type: 'start' });
45
45
  (0, open_in_editor_1.openInEditor)(stack)
46
- .then((res) => res.json())
47
46
  .then((data) => {
48
47
  if (data.success) {
49
48
  dispatchIfMounted({ type: 'succeed' });