@remotion/studio 4.0.498 → 4.0.500

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 (167) hide show
  1. package/dist/components/AssetSelector.js +8 -6
  2. package/dist/components/AssetSelectorItem.d.ts +24 -0
  3. package/dist/components/AssetSelectorItem.js +144 -83
  4. package/dist/components/Canvas.js +162 -7
  5. package/dist/components/CompositionSelector.js +15 -42
  6. package/dist/components/CompositionSelectorItem.js +21 -13
  7. package/dist/components/ControlButton.js +1 -0
  8. package/dist/components/EditorContent.js +1 -1
  9. package/dist/components/EditorRuler/Ruler.js +5 -3
  10. package/dist/components/ExplorerPanel.js +2 -1
  11. package/dist/components/ExplorerPanelRef.d.ts +2 -0
  12. package/dist/components/ForceSpecificCursor.js +13 -1
  13. package/dist/components/GlobalKeybindings.js +7 -1
  14. package/dist/components/InlineAction.d.ts +2 -1
  15. package/dist/components/InlineAction.js +2 -2
  16. package/dist/components/InlineDropdown.d.ts +1 -1
  17. package/dist/components/InlineDropdown.js +3 -2
  18. package/dist/components/InspectorPanel/AlignmentControls.d.ts +2 -2
  19. package/dist/components/InspectorPanel/AlignmentControls.js +5 -2
  20. package/dist/components/InspectorPanel/CompositionInspector.js +8 -7
  21. package/dist/components/InspectorPanel/CompositionMetadata.js +170 -57
  22. package/dist/components/InspectorPanel/ConnectedCompositionsSection.d.ts +2 -2
  23. package/dist/components/InspectorPanel/SequenceInspectorHeader.d.ts +3 -3
  24. package/dist/components/InspectorPanel/SequenceSelectionInspector.js +7 -7
  25. package/dist/components/InspectorPanel/common.d.ts +17 -4
  26. package/dist/components/InspectorPanel/common.js +60 -6
  27. package/dist/components/InspectorPanel/use-composition-actions.js +1 -0
  28. package/dist/components/InspectorPanel/use-track-for-selection.d.ts +1 -1
  29. package/dist/components/InspectorSequenceSection.js +43 -19
  30. package/dist/components/KeyboardShortcutsExplainer.js +4 -2
  31. package/dist/components/Menu/MenuItem.js +2 -1
  32. package/dist/components/MenuCompositionName.js +30 -7
  33. package/dist/components/MenuToolbar.d.ts +0 -1
  34. package/dist/components/MenuToolbar.js +8 -7
  35. package/dist/components/MobilePanel.d.ts +2 -1
  36. package/dist/components/MobilePanel.js +29 -25
  37. package/dist/components/ModalContainer.d.ts +1 -0
  38. package/dist/components/ModalContainer.js +2 -2
  39. package/dist/components/Modals.js +1 -1
  40. package/dist/components/NewComposition/DismissableModal.d.ts +1 -0
  41. package/dist/components/NewComposition/DismissableModal.js +2 -2
  42. package/dist/components/NewComposition/InputDragger.d.ts +34 -0
  43. package/dist/components/NewComposition/InputDragger.js +262 -23
  44. package/dist/components/OutlineToggle.d.ts +1 -3
  45. package/dist/components/OutlineToggle.js +2 -2
  46. package/dist/components/PreviewToolbar.js +10 -4
  47. package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.d.ts +7 -0
  48. package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.js +44 -0
  49. package/dist/components/QuickSwitcher/NoResults.d.ts +1 -1
  50. package/dist/components/QuickSwitcher/NoResults.js +1 -0
  51. package/dist/components/QuickSwitcher/QuickSwitcher.d.ts +5 -0
  52. package/dist/components/QuickSwitcher/QuickSwitcher.js +6 -2
  53. package/dist/components/QuickSwitcher/QuickSwitcherContent.d.ts +5 -0
  54. package/dist/components/QuickSwitcher/QuickSwitcherContent.js +76 -12
  55. package/dist/components/QuickSwitcher/QuickSwitcherResult.d.ts +4 -0
  56. package/dist/components/QuickSwitcher/QuickSwitcherResult.js +11 -8
  57. package/dist/components/QuickSwitcher/asset-search.d.ts +9 -0
  58. package/dist/components/QuickSwitcher/asset-search.js +42 -0
  59. package/dist/components/SelectedOutlineCropControls.d.ts +8 -0
  60. package/dist/components/SelectedOutlineCropControls.js +299 -0
  61. package/dist/components/SelectedOutlineElement.js +83 -43
  62. package/dist/components/SelectedOutlineOverlay.d.ts +2 -2
  63. package/dist/components/SelectedOutlineOverlay.js +130 -8
  64. package/dist/components/SequencePropsSubscriptionProvider.d.ts +2 -0
  65. package/dist/components/SequencePropsSubscriptionProvider.js +31 -3
  66. package/dist/components/SidebarCollapserControls.d.ts +3 -1
  67. package/dist/components/SidebarCollapserControls.js +34 -29
  68. package/dist/components/SnappingToggle.d.ts +1 -3
  69. package/dist/components/SnappingToggle.js +2 -2
  70. package/dist/components/Splitter/SplitterContainer.d.ts +2 -0
  71. package/dist/components/Splitter/SplitterContainer.js +5 -1
  72. package/dist/components/Splitter/SplitterContext.d.ts +2 -0
  73. package/dist/components/Splitter/SplitterContext.js +2 -0
  74. package/dist/components/Splitter/SplitterElement.js +6 -1
  75. package/dist/components/Splitter/SplitterHandle.js +27 -2
  76. package/dist/components/Timeline/Timeline.js +1 -1
  77. package/dist/components/Timeline/TimelineAssetField.d.ts +9 -1
  78. package/dist/components/Timeline/TimelineAssetField.js +52 -100
  79. package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +7 -3
  80. package/dist/components/Timeline/TimelineClipboardKeybindings.js +65 -38
  81. package/dist/components/Timeline/TimelineColorField.js +20 -1
  82. package/dist/components/Timeline/TimelineEffectPropItem.js +8 -77
  83. package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +1 -0
  84. package/dist/components/Timeline/TimelineHeightContainer.d.ts +2 -2
  85. package/dist/components/Timeline/TimelineInOutDragHandler.js +25 -1
  86. package/dist/components/Timeline/TimelineKeyframeTracksContext.d.ts +3 -3
  87. package/dist/components/Timeline/TimelineLayerEye.js +4 -1
  88. package/dist/components/Timeline/TimelineList.d.ts +2 -2
  89. package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +7 -1
  90. package/dist/components/Timeline/TimelineSelection.d.ts +5 -5
  91. package/dist/components/Timeline/TimelineSelection.js +8 -6
  92. package/dist/components/Timeline/TimelineSequence.js +7 -6
  93. package/dist/components/Timeline/TimelineSequenceItem.js +57 -10
  94. package/dist/components/Timeline/TimelineSequenceName.js +1 -0
  95. package/dist/components/Timeline/TimelineSequencePropItem.js +27 -75
  96. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +5 -1
  97. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +29 -12
  98. package/dist/components/Timeline/TimelineTrack.d.ts +2 -2
  99. package/dist/components/Timeline/TimelineTracks.d.ts +2 -2
  100. package/dist/components/Timeline/find-track-for-node-path-info.d.ts +1 -1
  101. package/dist/components/Timeline/get-sequence-context-menu-items.js +14 -12
  102. package/dist/components/Timeline/reset-selected-timeline-props.js +18 -10
  103. package/dist/components/Timeline/save-effect-prop.d.ts +10 -0
  104. package/dist/components/Timeline/save-effect-prop.js +52 -1
  105. package/dist/components/Timeline/should-show-track-in-timeline.d.ts +2 -2
  106. package/dist/components/Timeline/timeline-asset-link.js +17 -1
  107. package/dist/components/Timeline/use-sequence-freeze-frame-menu-item.d.ts +4 -0
  108. package/dist/components/Timeline/use-sequence-freeze-frame-menu-item.js +9 -3
  109. package/dist/components/Timeline/use-timeline-height.d.ts +2 -2
  110. package/dist/components/Timeline/use-timeline-keyframe-drag.js +6 -4
  111. package/dist/components/TopPanel.js +3 -2
  112. package/dist/components/UndoRedoButtons.js +27 -5
  113. package/dist/components/composition-drop-preview.d.ts +33 -0
  114. package/dist/components/composition-drop-preview.js +68 -0
  115. package/dist/components/drop-handler-data.d.ts +1 -1
  116. package/dist/components/drop-handler-data.js +27 -60
  117. package/dist/components/effect-drag-and-drop.d.ts +1 -1
  118. package/dist/components/effect-drag-and-drop.js +7 -55
  119. package/dist/components/element-drag-and-drop.d.ts +1 -1
  120. package/dist/components/element-drag-and-drop.js +5 -17
  121. package/dist/components/handle-drop.js +0 -1
  122. package/dist/components/import-assets.d.ts +7 -8
  123. package/dist/components/import-assets.js +2 -9
  124. package/dist/components/menu-toolbar-height.d.ts +1 -0
  125. package/dist/components/menu-toolbar-height.js +4 -0
  126. package/dist/components/selected-outline-drag.d.ts +41 -4
  127. package/dist/components/selected-outline-drag.js +179 -2
  128. package/dist/components/selected-outline-geometry.d.ts +1 -0
  129. package/dist/components/selected-outline-measurement.d.ts +11 -0
  130. package/dist/components/selected-outline-measurement.js +64 -3
  131. package/dist/components/selected-outline-types.d.ts +44 -1
  132. package/dist/components/selected-outline-types.js +21 -1
  133. package/dist/error-overlay/remotion-overlay/Overlay.js +3 -3
  134. package/dist/error-overlay/remotion-overlay/ShortcutHint.js +2 -3
  135. package/dist/esm/{chunk-7a6q9hk2.js → chunk-dr1y1vm3.js} +11851 -9494
  136. package/dist/esm/internals.mjs +11851 -9494
  137. package/dist/esm/previewEntry.mjs +55150 -52795
  138. package/dist/esm/renderEntry.mjs +1 -1
  139. package/dist/helpers/calculate-timeline.d.ts +2 -2
  140. package/dist/helpers/calculate-timeline.js +8 -28
  141. package/dist/helpers/get-effective-translation.d.ts +13 -1
  142. package/dist/helpers/get-effective-translation.js +12 -6
  143. package/dist/helpers/get-timeline-sequence-sort-key.d.ts +3 -10
  144. package/dist/helpers/get-timeline-sequence-sort-key.js +5 -13
  145. package/dist/helpers/interactivity-enabled.d.ts +1 -0
  146. package/dist/helpers/interactivity-enabled.js +7 -2
  147. package/dist/helpers/is-mac.d.ts +1 -0
  148. package/dist/helpers/is-mac.js +4 -0
  149. package/dist/helpers/open-in-editor.d.ts +5 -1
  150. package/dist/helpers/open-in-editor.js +15 -1
  151. package/dist/helpers/ruler-canvas-size.d.ts +7 -0
  152. package/dist/helpers/ruler-canvas-size.js +14 -1
  153. package/dist/helpers/sort-by-nonce-history.js +97 -19
  154. package/dist/helpers/use-image-metadata.d.ts +1 -0
  155. package/dist/helpers/use-image-metadata.js +8 -5
  156. package/dist/helpers/use-keybinding.js +2 -3
  157. package/dist/helpers/use-media-metadata.d.ts +1 -0
  158. package/dist/helpers/use-media-metadata.js +8 -5
  159. package/dist/helpers/use-menu-structure.js +10 -1
  160. package/dist/icons/caret.d.ts +1 -0
  161. package/dist/icons/caret.js +2 -2
  162. package/dist/icons/pen.d.ts +5 -0
  163. package/dist/icons/pen.js +8 -0
  164. package/dist/state/modals.d.ts +5 -0
  165. package/package.json +13 -12
  166. package/dist/helpers/get-timeline-sequence-hash.d.ts +0 -6
  167. package/dist/helpers/get-timeline-sequence-hash.js +0 -33
@@ -5,7 +5,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
7
  const colors_1 = require("../../helpers/colors");
8
+ const get_preview_file_type_1 = require("../../helpers/get-preview-file-type");
8
9
  const is_composition_still_1 = require("../../helpers/is-composition-still");
10
+ const url_state_1 = require("../../helpers/url-state");
9
11
  const use_keybinding_1 = require("../../helpers/use-keybinding");
10
12
  const use_menu_structure_1 = require("../../helpers/use-menu-structure");
11
13
  const modals_1 = require("../../state/modals");
@@ -14,14 +16,18 @@ const KeyboardShortcutsExplainer_1 = require("../KeyboardShortcutsExplainer");
14
16
  const layout_1 = require("../layout");
15
17
  const is_menu_item_1 = require("../Menu/is-menu-item");
16
18
  const RemInput_1 = require("../NewComposition/RemInput");
19
+ const use_select_asset_1 = require("../use-select-asset");
20
+ const use_static_files_1 = require("../use-static-files");
17
21
  const algolia_search_1 = require("./algolia-search");
18
22
  const AlgoliaCredit_1 = require("./AlgoliaCredit");
23
+ const asset_search_1 = require("./asset-search");
19
24
  const fuzzy_search_1 = require("./fuzzy-search");
20
25
  const NoResults_1 = require("./NoResults");
21
26
  const QuickSwitcherResult_1 = require("./QuickSwitcherResult");
22
27
  const shared_1 = require("./shared");
23
28
  const input = {
24
29
  width: '100%',
30
+ borderRadius: 4,
25
31
  };
26
32
  const modeSelector = {
27
33
  paddingLeft: 16,
@@ -57,8 +63,12 @@ const content = {
57
63
  flexDirection: 'row',
58
64
  alignItems: 'center',
59
65
  };
66
+ const contentWithoutModeSelector = {
67
+ ...content,
68
+ paddingTop: 16,
69
+ };
60
70
  const stripQuery = (query) => {
61
- if (query.startsWith('>') || query.startsWith('?')) {
71
+ if (query.startsWith('$') || query.startsWith('>') || query.startsWith('?')) {
62
72
  return query.substring(1).trim();
63
73
  }
64
74
  return query.trim();
@@ -68,9 +78,14 @@ const mapQueryToMode = (query) => {
68
78
  ? 'commands'
69
79
  : query.startsWith('?')
70
80
  ? 'docs'
71
- : 'compositions';
81
+ : query.startsWith('$')
82
+ ? 'assets'
83
+ : 'compositions';
72
84
  };
73
85
  const mapModeToQuery = (mode) => {
86
+ if (mode === 'assets') {
87
+ return '$ ';
88
+ }
74
89
  if (mode === 'commands') {
75
90
  return '> ';
76
91
  }
@@ -82,28 +97,34 @@ const mapModeToQuery = (mode) => {
82
97
  }
83
98
  throw new Error('no mode' + mode);
84
99
  };
85
- const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio }) => {
100
+ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio, assetSelection }) => {
86
101
  const { compositions } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
102
+ const staticFiles = (0, use_static_files_1.useStaticFiles)();
87
103
  const [state, setState] = (0, react_1.useState)(() => {
88
104
  return {
89
- query: mapModeToQuery(initialMode),
105
+ query: assetSelection === null
106
+ ? mapModeToQuery(initialMode)
107
+ : assetSelection.initialQuery,
90
108
  selectedIndex: 0,
91
109
  };
92
110
  });
93
111
  (0, react_1.useEffect)(() => {
94
112
  setState({
95
- query: mapModeToQuery(initialMode),
113
+ query: assetSelection === null
114
+ ? mapModeToQuery(initialMode)
115
+ : assetSelection.initialQuery,
96
116
  selectedIndex: 0,
97
117
  });
98
- }, [initialMode, invocationTimestamp]);
118
+ }, [assetSelection, initialMode, invocationTimestamp]);
99
119
  const inputRef = (0, react_1.useRef)(null);
100
120
  const selectComposition = (0, InitialCompositionLoader_1.useSelectComposition)();
121
+ const selectAsset = (0, use_select_asset_1.useSelectAsset)();
101
122
  const closeMenu = (0, react_1.useCallback)(() => undefined, []);
102
123
  const actions = (0, use_menu_structure_1.useMenuStructure)(closeMenu, readOnlyStudio);
103
124
  const [docResults, setDocResults] = (0, react_1.useState)({ type: 'initial' });
104
125
  const { setSelectedModal } = (0, react_1.useContext)(modals_1.ModalsContext);
105
126
  const keybindings = (0, use_keybinding_1.useKeybinding)();
106
- const mode = mapQueryToMode(state.query);
127
+ const mode = assetSelection !== null ? 'assets' : mapQueryToMode(state.query);
107
128
  const actualQuery = (0, react_1.useMemo)(() => {
108
129
  return stripQuery(state.query);
109
130
  }, [state.query]);
@@ -113,6 +134,12 @@ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio
113
134
  }
114
135
  return (0, use_menu_structure_1.makeSearchResults)(actions, setSelectedModal);
115
136
  }, [actions, mode, setSelectedModal]);
137
+ const assetSearch = (0, react_1.useMemo)(() => {
138
+ return (0, asset_search_1.filterAssetsByType)({
139
+ assets: staticFiles,
140
+ query: actualQuery,
141
+ });
142
+ }, [actualQuery, staticFiles]);
116
143
  const resultsArray = (0, react_1.useMemo)(() => {
117
144
  if (mode === 'commands') {
118
145
  return (0, fuzzy_search_1.fuzzySearch)(actualQuery, menuActions);
@@ -120,6 +147,26 @@ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio
120
147
  if (mode === 'docs' && docResults.type === 'results') {
121
148
  return docResults.results;
122
149
  }
150
+ if (mode === 'assets') {
151
+ return (0, fuzzy_search_1.fuzzySearch)(assetSearch.query, assetSearch.assets.map((asset) => {
152
+ return {
153
+ id: 'asset-' + asset.name,
154
+ title: asset.name,
155
+ type: 'asset',
156
+ fileType: (0, get_preview_file_type_1.getPreviewFileType)(asset.name),
157
+ onSelected: () => {
158
+ if (assetSelection !== null) {
159
+ assetSelection.onSelected(asset);
160
+ }
161
+ else {
162
+ selectAsset(asset.name);
163
+ (0, url_state_1.pushUrl)(`/assets/${asset.name}`);
164
+ }
165
+ setSelectedModal(null);
166
+ },
167
+ };
168
+ }));
169
+ }
123
170
  return (0, fuzzy_search_1.fuzzySearch)(actualQuery, compositions.map((c) => {
124
171
  return {
125
172
  id: 'composition-' + c.id,
@@ -146,6 +193,9 @@ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio
146
193
  compositions,
147
194
  menuActions,
148
195
  docResults,
196
+ assetSearch,
197
+ assetSelection,
198
+ selectAsset,
149
199
  selectComposition,
150
200
  setSelectedModal,
151
201
  ]);
@@ -244,6 +294,14 @@ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio
244
294
  }));
245
295
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
246
296
  }, []);
297
+ const onAssetsSelected = (0, react_1.useCallback)(() => {
298
+ var _a;
299
+ setState((s) => ({
300
+ query: `$ ${stripQuery(s.query)}`,
301
+ selectedIndex: 0,
302
+ }));
303
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
304
+ }, []);
247
305
  const onDocSearchSelected = (0, react_1.useCallback)(() => {
248
306
  var _a;
249
307
  setState((s) => ({
@@ -255,6 +313,13 @@ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio
255
313
  }, []);
256
314
  const showKeyboardShortcuts = mode === 'docs' && actualQuery.trim() === '';
257
315
  const showSearchLoadingState = mode === 'docs' && docResults.type === 'loading';
316
+ const placeholder = mode === 'assets'
317
+ ? 'Search assets...'
318
+ : mode === 'commands'
319
+ ? 'Search actions...'
320
+ : mode === 'docs'
321
+ ? 'Search documentation...'
322
+ : 'Search compositions...';
258
323
  const container = (0, react_1.useMemo)(() => {
259
324
  return {
260
325
  width: showKeyboardShortcuts ? 800 : 500,
@@ -272,11 +337,10 @@ const QuickSwitcherContent = ({ initialMode, invocationTimestamp, readOnlyStudio
272
337
  height: 300,
273
338
  };
274
339
  }, [showKeyboardShortcuts]);
275
- return (jsx_runtime_1.jsxs("div", { style: container, children: [
276
- jsx_runtime_1.jsxs("div", { style: modeSelector, children: [
277
- jsx_runtime_1.jsx("button", { onClick: onCompositionsSelected, style: mode === 'compositions' ? modeActive : modeInactive, type: "button", children: "Compositions" }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("button", { onClick: onActionsSelected, style: mode === 'commands' ? modeActive : modeInactive, type: "button", children: "Actions" }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("button", { onClick: onDocSearchSelected, style: mode === 'docs' ? modeActive : modeInactive, type: "button", children: "Documentation" })
278
- ] }), jsx_runtime_1.jsxs("div", { style: content, children: [
279
- jsx_runtime_1.jsx(RemInput_1.RemotionInput, { ref: inputRef, type: "text", style: input, autoFocus: true, status: "ok", value: state.query, onChange: onTextChange, placeholder: "Search compositions...", rightAlign: false }), showKeyboardShortcuts ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
340
+ return (jsx_runtime_1.jsxs("div", { style: container, children: [assetSelection === null && (jsx_runtime_1.jsxs("div", { style: modeSelector, children: [
341
+ jsx_runtime_1.jsx("button", { onClick: onCompositionsSelected, style: mode === 'compositions' ? modeActive : modeInactive, type: "button", children: "Compositions" }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("button", { onClick: onAssetsSelected, style: mode === 'assets' ? modeActive : modeInactive, type: "button", children: "Assets" }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("button", { onClick: onActionsSelected, style: mode === 'commands' ? modeActive : modeInactive, type: "button", children: "Actions" }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("button", { onClick: onDocSearchSelected, style: mode === 'docs' ? modeActive : modeInactive, type: "button", children: "Documentation" })
342
+ ] })), jsx_runtime_1.jsxs("div", { style: assetSelection === null ? content : contentWithoutModeSelector, children: [
343
+ jsx_runtime_1.jsx(RemInput_1.RemotionInput, { ref: inputRef, type: "text", style: input, autoFocus: true, status: "ok", value: state.query, onChange: onTextChange, placeholder: placeholder, rightAlign: false }), showKeyboardShortcuts ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
280
344
  jsx_runtime_1.jsx(layout_1.Spacing, { x: 2 }),
281
345
  " ",
282
346
  jsx_runtime_1.jsx(AlgoliaCredit_1.AlgoliaCredit, {})
@@ -1,5 +1,9 @@
1
1
  import React from 'react';
2
+ import type { AssetFileType } from '../../helpers/get-preview-file-type';
2
3
  type QuickSwitcherResultDetail = {
4
+ type: 'asset';
5
+ fileType: AssetFileType;
6
+ } | {
3
7
  type: 'composition';
4
8
  compositionType: 'composition' | 'still';
5
9
  } | {
@@ -7,6 +7,7 @@ const colors_1 = require("../../helpers/colors");
7
7
  const use_keybinding_1 = require("../../helpers/use-keybinding");
8
8
  const still_1 = require("../../icons/still");
9
9
  const video_1 = require("../../icons/video");
10
+ const AssetFileIcon_1 = require("../AssetFileIcon");
10
11
  const layout_1 = require("../layout");
11
12
  const shared_1 = require("./shared");
12
13
  const container = {
@@ -15,7 +16,11 @@ const container = {
15
16
  display: 'flex',
16
17
  flexDirection: 'row',
17
18
  alignItems: 'center',
18
- cursor: 'pointer',
19
+ cursor: 'default',
20
+ marginBottom: 1,
21
+ marginLeft: 4,
22
+ marginRight: 4,
23
+ borderRadius: 4,
19
24
  };
20
25
  const label = {
21
26
  whiteSpace: 'nowrap',
@@ -26,8 +31,9 @@ const searchLabel = {
26
31
  lineHeight: 1.25,
27
32
  };
28
33
  const iconStyle = {
29
- width: 14,
30
- height: 14,
34
+ width: 18,
35
+ height: 18,
36
+ flexShrink: 0,
31
37
  };
32
38
  const labelContainer = {
33
39
  overflow: 'hidden',
@@ -75,10 +81,7 @@ const QuickSwitcherResult = ({ result, selected }) => {
75
81
  const style = (0, react_1.useMemo)(() => {
76
82
  return {
77
83
  ...container,
78
- backgroundColor: (0, colors_1.getBackgroundFromHoverState)({
79
- hovered,
80
- selected,
81
- }),
84
+ backgroundColor: hovered || selected ? colors_1.WHITE_ALPHA_06 : colors_1.TRANSPARENT,
82
85
  };
83
86
  }, [hovered, selected]);
84
87
  const labelStyle = (0, react_1.useMemo)(() => {
@@ -92,7 +95,7 @@ const QuickSwitcherResult = ({ result, selected }) => {
92
95
  fontSize: shared_1.QUICK_SWITCHER_RESULT_LABEL_FONT_SIZE,
93
96
  };
94
97
  }, [hovered, result.type, selected]);
95
- return (jsx_runtime_1.jsxs("div", { ref: ref, style: style, onClick: result.onSelected, children: [result.type === 'composition' ? (result.compositionType === 'still' ? (jsx_runtime_1.jsx(still_1.StillIcon, { color: selected ? colors_1.WHITE : colors_1.LIGHT_TEXT, style: iconStyle })) : (jsx_runtime_1.jsx(video_1.FilmIcon, { color: selected ? colors_1.WHITE : colors_1.LIGHT_TEXT, style: iconStyle }))) : null, jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: labelContainer, children: result.type === 'search-result' ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
98
+ return (jsx_runtime_1.jsxs("div", { ref: ref, style: style, onClick: result.onSelected, children: [result.type === 'composition' ? (result.compositionType === 'still' ? (jsx_runtime_1.jsx(still_1.StillIcon, { color: selected || hovered ? colors_1.WHITE : colors_1.LIGHT_TEXT, style: iconStyle })) : (jsx_runtime_1.jsx(video_1.FilmIcon, { color: selected || hovered ? colors_1.WHITE : colors_1.LIGHT_TEXT, style: iconStyle }))) : result.type === 'asset' ? (jsx_runtime_1.jsx(AssetFileIcon_1.AssetFileIcon, { fileType: result.fileType, color: selected || hovered ? colors_1.WHITE : colors_1.LIGHT_TEXT, style: iconStyle })) : null, jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: labelContainer, children: result.type === 'search-result' ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
96
99
  jsx_runtime_1.jsx("div", {
97
100
  // eslint-disable-next-line react/no-danger
98
101
  dangerouslySetInnerHTML: {
@@ -0,0 +1,9 @@
1
+ import type { StaticFile } from '../../api/get-static-files';
2
+ export declare const filterAssetsByType: ({ assets, query, }: {
3
+ readonly assets: StaticFile[];
4
+ readonly query: string;
5
+ }) => {
6
+ readonly assets: StaticFile[];
7
+ readonly query: string;
8
+ };
9
+ export declare const getAssetSearchQueryForComponent: (componentIdentity: string | null) => string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAssetSearchQueryForComponent = exports.filterAssetsByType = void 0;
4
+ const get_preview_file_type_1 = require("../../helpers/get-preview-file-type");
5
+ const typeFilterRegex = /(^|\s)type:([^\s]+)/gi;
6
+ const filterAssetsByType = ({ assets, query, }) => {
7
+ const typeFilters = [];
8
+ const queryWithoutTypeFilters = query
9
+ .replace(typeFilterRegex, (_match, whitespace, type) => {
10
+ typeFilters.push(type.toLowerCase());
11
+ return whitespace;
12
+ })
13
+ .replace(/\s+/g, ' ')
14
+ .trim();
15
+ if (typeFilters.length === 0) {
16
+ return {
17
+ assets,
18
+ query: queryWithoutTypeFilters,
19
+ };
20
+ }
21
+ return {
22
+ assets: assets.filter((asset) => {
23
+ return typeFilters.includes((0, get_preview_file_type_1.getPreviewFileType)(asset.name));
24
+ }),
25
+ query: queryWithoutTypeFilters,
26
+ };
27
+ };
28
+ exports.filterAssetsByType = filterAssetsByType;
29
+ const componentAssetTypes = {
30
+ 'dev.remotion.media.Audio': 'audio',
31
+ 'dev.remotion.media.Video': 'video',
32
+ 'dev.remotion.remotion.AnimatedImage': 'image',
33
+ 'dev.remotion.remotion.Img': 'image',
34
+ };
35
+ const getAssetSearchQueryForComponent = (componentIdentity) => {
36
+ if (componentIdentity === null) {
37
+ return '';
38
+ }
39
+ const assetType = componentAssetTypes[componentIdentity];
40
+ return assetType ? `type:${assetType} ` : '';
41
+ };
42
+ exports.getAssetSearchQueryForComponent = getAssetSearchQueryForComponent;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { SelectedOutline } from './selected-outline-geometry';
3
+ import { type SelectedOutlineTarget } from './selected-outline-types';
4
+ export declare const SelectedOutlineCropControls: React.FC<{
5
+ readonly outline: SelectedOutline;
6
+ readonly onDraggingChange: (dragging: boolean) => void;
7
+ readonly target: SelectedOutlineTarget | undefined;
8
+ }>;
@@ -0,0 +1,299 @@
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SelectedOutlineCropControls = void 0;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const react_1 = __importStar(require("react"));
39
+ const remotion_1 = require("remotion");
40
+ const colors_1 = require("../helpers/colors");
41
+ const ForceSpecificCursor_1 = require("./ForceSpecificCursor");
42
+ const NotificationCenter_1 = require("./Notifications/NotificationCenter");
43
+ const selected_outline_drag_1 = require("./selected-outline-drag");
44
+ const selected_outline_measurement_1 = require("./selected-outline-measurement");
45
+ const selected_outline_types_1 = require("./selected-outline-types");
46
+ const selected_outline_uv_1 = require("./selected-outline-uv");
47
+ const call_add_keyframe_1 = require("./Timeline/call-add-keyframe");
48
+ const focus_inspector_field_1 = require("./Timeline/focus-inspector-field");
49
+ const save_sequence_prop_1 = require("./Timeline/save-sequence-prop");
50
+ const CROP_HANDLE_THICKNESS = 5;
51
+ const CROP_HANDLE_LENGTH = 20;
52
+ const CROP_HANDLE_HIT_WIDTH = 14;
53
+ const CROPPED_AWAY_OPACITY = 0.35;
54
+ const cropHandles = [
55
+ 'top-left',
56
+ 'top-right',
57
+ 'bottom-left',
58
+ 'bottom-right',
59
+ 'top',
60
+ 'right',
61
+ 'bottom',
62
+ 'left',
63
+ ];
64
+ const cursorForHandle = (handle) => {
65
+ if (handle === 'top' || handle === 'bottom') {
66
+ return 'ns-resize';
67
+ }
68
+ if (handle === 'left' || handle === 'right') {
69
+ return 'ew-resize';
70
+ }
71
+ return handle === 'top-left' || handle === 'bottom-right'
72
+ ? 'nwse-resize'
73
+ : 'nesw-resize';
74
+ };
75
+ const moveTowards = (from, to, distance) => {
76
+ const vector = (0, selected_outline_measurement_1.vectorBetween)(from, to);
77
+ const length = (0, selected_outline_measurement_1.vectorLength)(vector);
78
+ if (length === 0) {
79
+ return from;
80
+ }
81
+ const progress = Math.min(1, distance / length);
82
+ return {
83
+ x: from.x + vector.x * progress,
84
+ y: from.y + vector.y * progress,
85
+ };
86
+ };
87
+ const pointString = (point) => `${point.x} ${point.y}`;
88
+ const getCropHandlePath = ({ handle, points, }) => {
89
+ const [topLeft, topRight, bottomRight, bottomLeft] = points;
90
+ const cornerInfo = {
91
+ 'top-left': { corner: topLeft, first: topRight, second: bottomLeft },
92
+ 'top-right': { corner: topRight, first: topLeft, second: bottomRight },
93
+ 'bottom-left': { corner: bottomLeft, first: topLeft, second: bottomRight },
94
+ 'bottom-right': { corner: bottomRight, first: topRight, second: bottomLeft },
95
+ };
96
+ if (handle in cornerInfo) {
97
+ const info = cornerInfo[handle];
98
+ const length = Math.min(CROP_HANDLE_LENGTH, (0, selected_outline_measurement_1.vectorLength)((0, selected_outline_measurement_1.vectorBetween)(info.corner, info.first)) / 4, (0, selected_outline_measurement_1.vectorLength)((0, selected_outline_measurement_1.vectorBetween)(info.corner, info.second)) / 4);
99
+ const first = moveTowards(info.corner, info.first, length);
100
+ const second = moveTowards(info.corner, info.second, length);
101
+ return `M ${pointString(first)} L ${pointString(info.corner)} L ${pointString(second)}`;
102
+ }
103
+ const edgeInfo = {
104
+ top: [topLeft, topRight],
105
+ right: [topRight, bottomRight],
106
+ bottom: [bottomLeft, bottomRight],
107
+ left: [topLeft, bottomLeft],
108
+ };
109
+ const [start, end] = edgeInfo[handle];
110
+ const center = (0, selected_outline_measurement_1.midpoint)(start, end);
111
+ const halfLength = Math.min(CROP_HANDLE_LENGTH / 2, (0, selected_outline_measurement_1.vectorLength)((0, selected_outline_measurement_1.vectorBetween)(start, end)) / 8);
112
+ const pathStart = moveTowards(center, start, halfLength);
113
+ const pathEnd = moveTowards(center, end, halfLength);
114
+ return `M ${pointString(pathStart)} L ${pointString(pathEnd)}`;
115
+ };
116
+ const getCropValues = (target) => ({
117
+ cropLeft: target.fields.cropLeft.value,
118
+ cropRight: target.fields.cropRight.value,
119
+ cropTop: target.fields.cropTop.value,
120
+ cropBottom: target.fields.cropBottom.value,
121
+ });
122
+ const makeCropPreviewMask = (crop) => {
123
+ const x = crop.left * 100;
124
+ const y = crop.top * 100;
125
+ const width = Math.max(0, 1 - crop.left - crop.right) * 100;
126
+ const height = Math.max(0, 1 - crop.top - crop.bottom) * 100;
127
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none"><rect width="100" height="100" fill="white" fill-opacity="${CROPPED_AWAY_OPACITY}"/><rect x="${x}" y="${y}" width="${width}" height="${height}" fill="white"/></svg>`;
128
+ return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
129
+ };
130
+ const cropPreviewAttribute = 'data-remotion-studio-crop-preview';
131
+ let cropPreviewId = 0;
132
+ const useCropPreview = (target) => {
133
+ (0, react_1.useLayoutEffect)(() => {
134
+ var _a;
135
+ if (target === undefined || target.cropDrag === null) {
136
+ return;
137
+ }
138
+ const element = target.ref.current;
139
+ if (!(element instanceof HTMLElement || element instanceof SVGElement)) {
140
+ return;
141
+ }
142
+ const mask = makeCropPreviewMask(target.crop);
143
+ const previewId = String(++cropPreviewId);
144
+ const styleElement = element.ownerDocument.createElement('style');
145
+ styleElement.textContent = `
146
+ [${cropPreviewAttribute}="${previewId}"] {
147
+ clip-path: none !important;
148
+ mask-image: ${mask} !important;
149
+ -webkit-mask-image: ${mask} !important;
150
+ mask-position: 0 0 !important;
151
+ -webkit-mask-position: 0 0 !important;
152
+ mask-repeat: no-repeat !important;
153
+ -webkit-mask-repeat: no-repeat !important;
154
+ mask-size: 100% 100% !important;
155
+ -webkit-mask-size: 100% 100% !important;
156
+ }`;
157
+ // Do not mutate the inline crop style: React would still consider its
158
+ // clipPath prop applied and may not restore it when crop mode is closed.
159
+ element.setAttribute(cropPreviewAttribute, previewId);
160
+ ((_a = element.ownerDocument.head) !== null && _a !== void 0 ? _a : element.ownerDocument.documentElement).append(styleElement);
161
+ return () => {
162
+ if (element.getAttribute(cropPreviewAttribute) === previewId) {
163
+ element.removeAttribute(cropPreviewAttribute);
164
+ }
165
+ styleElement.remove();
166
+ };
167
+ }, [target]);
168
+ };
169
+ const CropHandle = ({ handle, outline, onDraggingChange, target }) => {
170
+ const { setPropStatuses, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
171
+ const { cropDrag } = target;
172
+ const cursor = cursorForHandle(handle);
173
+ const path = (0, react_1.useMemo)(() => getCropHandlePath({ handle, points: outline.points }), [handle, outline.points]);
174
+ const onPointerDown = react_1.default.useCallback((event) => {
175
+ var _a;
176
+ if (event.button !== 0 || cropDrag === null) {
177
+ return;
178
+ }
179
+ event.preventDefault();
180
+ event.stopPropagation();
181
+ if ((0, focus_inspector_field_1.commitPendingInspectorFields)()) {
182
+ return;
183
+ }
184
+ const svg = event.currentTarget.ownerSVGElement;
185
+ if (svg === null) {
186
+ return;
187
+ }
188
+ const svgRect = svg.getBoundingClientRect();
189
+ const uncroppedPoints = (_a = outline.uncroppedPoints) !== null && _a !== void 0 ? _a : outline.points;
190
+ const initialValues = getCropValues(cropDrag);
191
+ let lastValues = initialValues;
192
+ let dragStarted = false;
193
+ const onPointerMove = (moveEvent) => {
194
+ moveEvent.preventDefault();
195
+ if (!dragStarted) {
196
+ dragStarted = true;
197
+ onDraggingChange(true);
198
+ (0, ForceSpecificCursor_1.forceSpecificCursor)(cursor !== null && cursor !== void 0 ? cursor : 'default');
199
+ }
200
+ const uv = (0, selected_outline_uv_1.getUvCoordinateForPoint)(uncroppedPoints, {
201
+ x: moveEvent.clientX - svgRect.left,
202
+ y: moveEvent.clientY - svgRect.top,
203
+ });
204
+ lastValues = (0, selected_outline_drag_1.getSelectedOutlineCropDragValues)({
205
+ crop: initialValues,
206
+ dimensions: outline.dimensions,
207
+ handle,
208
+ uv,
209
+ });
210
+ const transformOrigin = (0, selected_outline_drag_1.getSelectedOutlineCropFollowingTransformOrigin)({
211
+ dimensions: outline.dimensions,
212
+ initialCrop: initialValues,
213
+ nextCrop: lastValues,
214
+ transformOrigin: cropDrag.transformOrigin,
215
+ });
216
+ for (const fieldKey of Object.values(selected_outline_types_1.cropFieldKeys)) {
217
+ const field = cropDrag.fields[fieldKey];
218
+ const value = lastValues[fieldKey];
219
+ if (value === field.value) {
220
+ continue;
221
+ }
222
+ setDragOverrides(cropDrag.nodePath, fieldKey, field.propStatus.status === 'keyframed'
223
+ ? remotion_1.Internals.makeKeyframedDragOverride({
224
+ status: field.propStatus,
225
+ frame: cropDrag.sourceFrame,
226
+ value,
227
+ })
228
+ : remotion_1.Internals.makeStaticDragOverride(value));
229
+ }
230
+ if (transformOrigin !== null) {
231
+ setDragOverrides(cropDrag.nodePath, selected_outline_types_1.transformOriginFieldKey, remotion_1.Internals.makeStaticDragOverride(transformOrigin));
232
+ }
233
+ };
234
+ const onPointerUp = () => {
235
+ window.removeEventListener('pointermove', onPointerMove);
236
+ window.removeEventListener('pointerup', onPointerUp);
237
+ window.removeEventListener('pointercancel', onPointerUp);
238
+ if (dragStarted) {
239
+ (0, ForceSpecificCursor_1.stopForcingSpecificCursor)();
240
+ onDraggingChange(false);
241
+ }
242
+ const changes = (0, selected_outline_drag_1.getSelectedOutlineCropDragChanges)({
243
+ dimensions: outline.dimensions,
244
+ target: cropDrag,
245
+ values: lastValues,
246
+ });
247
+ const staticChanges = changes.filter((change) => change.type === 'static');
248
+ const keyframedChanges = changes.filter((change) => change.type === 'keyframed');
249
+ const promise = staticChanges.length === 0
250
+ ? (0, call_add_keyframe_1.callAddKeyframes)({
251
+ sequenceKeyframes: keyframedChanges,
252
+ effectKeyframes: [],
253
+ setPropStatuses,
254
+ clientId: cropDrag.clientId,
255
+ })
256
+ : (0, save_sequence_prop_1.saveSequenceProps)({
257
+ changes: staticChanges,
258
+ addedKeyframes: keyframedChanges,
259
+ movedKeyframes: null,
260
+ setPropStatuses,
261
+ clientId: cropDrag.clientId,
262
+ undoLabel: 'Crop sequence',
263
+ redoLabel: 'Crop sequence back',
264
+ });
265
+ promise
266
+ .catch((err) => {
267
+ (0, NotificationCenter_1.showNotification)(`Could not save crop: ${err instanceof Error ? err.message : String(err)}`, 4000);
268
+ })
269
+ .finally(() => {
270
+ clearDragOverrides(cropDrag.nodePath);
271
+ });
272
+ };
273
+ window.addEventListener('pointermove', onPointerMove);
274
+ window.addEventListener('pointerup', onPointerUp);
275
+ window.addEventListener('pointercancel', onPointerUp);
276
+ }, [
277
+ clearDragOverrides,
278
+ cropDrag,
279
+ cursor,
280
+ handle,
281
+ onDraggingChange,
282
+ outline.dimensions,
283
+ outline.points,
284
+ outline.uncroppedPoints,
285
+ setDragOverrides,
286
+ setPropStatuses,
287
+ ]);
288
+ return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
289
+ jsx_runtime_1.jsx("path", { d: path, fill: "none", stroke: colors_1.TRANSPARENT, strokeWidth: CROP_HANDLE_HIT_WIDTH, strokeLinejoin: "miter", vectorEffect: "non-scaling-stroke", pointerEvents: "stroke", cursor: cursor, onPointerDown: onPointerDown }), jsx_runtime_1.jsx("path", { d: path, fill: "none", stroke: colors_1.BLUE, strokeWidth: CROP_HANDLE_THICKNESS, strokeLinejoin: "miter", strokeLinecap: "butt", vectorEffect: "non-scaling-stroke", pointerEvents: "none", style: { filter: colors_1.SELECTED_OUTLINE_DROP_SHADOW } })
290
+ ] }));
291
+ };
292
+ const SelectedOutlineCropControls = ({ outline, onDraggingChange, target }) => {
293
+ useCropPreview(target);
294
+ if ((target === null || target === void 0 ? void 0 : target.cropDrag) === null || (target === null || target === void 0 ? void 0 : target.cropDrag) === undefined) {
295
+ return null;
296
+ }
297
+ return (jsx_runtime_1.jsx("g", { "aria-hidden": "true", children: cropHandles.map((handle) => (jsx_runtime_1.jsx(CropHandle, { handle: handle, outline: outline, onDraggingChange: onDraggingChange, target: target }, handle))) }));
298
+ };
299
+ exports.SelectedOutlineCropControls = SelectedOutlineCropControls;