@remotion/studio 4.0.516 → 4.0.518

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 (157) hide show
  1. package/dist/components/AssetSelector.js +63 -22
  2. package/dist/components/AssetSelectorItem.d.ts +2 -1
  3. package/dist/components/AssetSelectorItem.js +41 -10
  4. package/dist/components/Canvas.js +15 -12
  5. package/dist/components/CanvasCaptureDropHandler.d.ts +4 -0
  6. package/dist/components/CanvasCaptureDropHandler.js +42 -0
  7. package/dist/components/CanvasOrLoading.js +4 -3
  8. package/dist/components/CaptionInspector.js +1 -1
  9. package/dist/components/CaptionTextEditor.js +32 -8
  10. package/dist/components/CheckboardToggle.js +1 -1
  11. package/dist/components/Checkbox.d.ts +0 -1
  12. package/dist/components/Checkbox.js +2 -19
  13. package/dist/components/CompositionContextButton.js +2 -1
  14. package/dist/components/CompositionSelector.js +1 -1
  15. package/dist/components/ConfigureLicenseModal.js +79 -46
  16. package/dist/components/CurrentAsset.d.ts +1 -1
  17. package/dist/components/CurrentAsset.js +9 -4
  18. package/dist/components/Editor.js +2 -1
  19. package/dist/components/EditorContent.js +11 -5
  20. package/dist/components/EditorContexts.js +2 -1
  21. package/dist/components/EditorRuler/Ruler.d.ts +1 -0
  22. package/dist/components/EditorRuler/Ruler.js +9 -8
  23. package/dist/components/EditorRuler/index.d.ts +1 -0
  24. package/dist/components/EditorRuler/index.js +3 -4
  25. package/dist/components/EditorRuler/use-is-ruler-visible.d.ts +1 -1
  26. package/dist/components/EditorRuler/use-is-ruler-visible.js +8 -2
  27. package/dist/components/ElementInstallConfirmation.d.ts +5 -0
  28. package/dist/components/ElementInstallConfirmation.js +25 -1
  29. package/dist/components/ElementLibraryModal.d.ts +5 -0
  30. package/dist/components/ElementLibraryModal.js +40 -0
  31. package/dist/components/FilePreview.js +71 -0
  32. package/dist/components/InlineCaptionInspector.js +13 -2
  33. package/dist/components/InlineEditableTitle.js +2 -2
  34. package/dist/components/InspectorPanel/CompositionInspector.js +11 -38
  35. package/dist/components/InspectorPanel/CompositionInspectorHeader.js +2 -2
  36. package/dist/components/InspectorPanel/CompositionMetadata.js +11 -4
  37. package/dist/components/InspectorPanel/EasingInspector.js +2 -2
  38. package/dist/components/InspectorPanel/ElementLibraryButton.d.ts +2 -0
  39. package/dist/components/InspectorPanel/ElementLibraryButton.js +139 -0
  40. package/dist/components/InspectorPanel/KeyframeInspector.js +1 -1
  41. package/dist/components/InspectorPanel/SequenceInspectorHeader.js +12 -5
  42. package/dist/components/InspectorPanel/SequenceSelectionInspector.js +1 -3
  43. package/dist/components/InspectorPanel/common.d.ts +0 -1
  44. package/dist/components/InspectorPanel/common.js +3 -7
  45. package/dist/components/InspectorPanel/inspector-selection.d.ts +2 -2
  46. package/dist/components/InspectorPanel/styles.d.ts +0 -1
  47. package/dist/components/InspectorPanel/styles.js +3 -4
  48. package/dist/components/InspectorPanel/use-track-for-selection.d.ts +1 -2
  49. package/dist/components/InspectorSequenceSection.d.ts +1 -2
  50. package/dist/components/InspectorSourceLocation.js +1 -1
  51. package/dist/components/Menu/MenuItem.js +15 -6
  52. package/dist/components/MenuToolbar.js +7 -3
  53. package/dist/components/Modals.js +51 -1
  54. package/dist/components/PlaybackRateSelector.js +3 -6
  55. package/dist/components/Preview.js +83 -5
  56. package/dist/components/PreviewToolbar.js +10 -4
  57. package/dist/components/PreviewToolbarOverflowButton.d.ts +1 -0
  58. package/dist/components/PreviewToolbarOverflowButton.js +9 -2
  59. package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.d.ts +2 -0
  60. package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.js +28 -8
  61. package/dist/components/RadioButton.d.ts +6 -0
  62. package/dist/components/RadioButton.js +62 -0
  63. package/dist/components/RenderButton.js +2 -1
  64. package/dist/components/RulersAndGuidesToggle.d.ts +3 -1
  65. package/dist/components/RulersAndGuidesToggle.js +18 -7
  66. package/dist/components/SelectedOutlineKeyboardControls.d.ts +2 -2
  67. package/dist/components/SelectedOutlineOverlay.d.ts +1 -3
  68. package/dist/components/SelectedOutlineOverlay.js +21 -17
  69. package/dist/components/SelectedOutlinePolygon.d.ts +1 -2
  70. package/dist/components/SelectedOutlineRenderer.d.ts +2 -3
  71. package/dist/components/SelectedOutlineRenderer.js +9 -78
  72. package/dist/components/SelectedOutlineUvControls.d.ts +1 -1
  73. package/dist/components/SettingsModal.js +1 -1
  74. package/dist/components/SettingsModalFooter.d.ts +3 -1
  75. package/dist/components/SettingsModalFooter.js +19 -4
  76. package/dist/components/ShowPixelGridProvider.d.ts +4 -0
  77. package/dist/components/ShowPixelGridProvider.js +24 -0
  78. package/dist/components/SidebarCollapserControls.js +2 -2
  79. package/dist/components/SidebarRenderButton.js +2 -1
  80. package/dist/components/Timeline/Timeline.js +41 -0
  81. package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +6 -7
  82. package/dist/components/Timeline/TimelineDragHandler.js +11 -4
  83. package/dist/components/Timeline/TimelineKeyframeControls.d.ts +1 -2
  84. package/dist/components/Timeline/TimelinePlayCursorSyncer.js +4 -2
  85. package/dist/components/Timeline/TimelineSelection.d.ts +29 -66
  86. package/dist/components/Timeline/TimelineSelection.js +30 -170
  87. package/dist/components/Timeline/TimelineSequenceItem.d.ts +1 -0
  88. package/dist/components/Timeline/TimelineSequenceItem.js +8 -6
  89. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +3 -4
  90. package/dist/components/Timeline/delete-selected-timeline-item.d.ts +3 -4
  91. package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +3 -4
  92. package/dist/components/Timeline/find-track-for-node-path-info.d.ts +1 -1
  93. package/dist/components/Timeline/keyframe-clipboard.d.ts +2 -3
  94. package/dist/components/Timeline/reset-selected-timeline-props.d.ts +2 -3
  95. package/dist/components/Timeline/sequence-prop-clipboard.d.ts +2 -3
  96. package/dist/components/Timeline/split-selected-timeline-item.d.ts +2 -3
  97. package/dist/components/Timeline/timeline-expanded-filter.d.ts +1 -2
  98. package/dist/components/Timeline/timeline-scroll-logic.d.ts +7 -5
  99. package/dist/components/Timeline/timeline-scroll-logic.js +12 -7
  100. package/dist/components/Timeline/update-selected-easing.d.ts +7 -7
  101. package/dist/components/Timeline/use-timeline-asset-drop.js +24 -1
  102. package/dist/components/Timeline/use-timeline-keyframe-drag.d.ts +6 -7
  103. package/dist/components/WebMcp.d.ts +2 -0
  104. package/dist/components/WebMcp.js +945 -0
  105. package/dist/components/canvas-capture-drop.d.ts +4 -0
  106. package/dist/components/canvas-capture-drop.js +22 -0
  107. package/dist/components/composition-menu-items.js +26 -0
  108. package/dist/components/selected-outline-geometry.d.ts +2 -21
  109. package/dist/components/selected-outline-geometry.js +5 -16
  110. package/dist/components/selected-outline-measurement.d.ts +8 -37
  111. package/dist/components/selected-outline-measurement.js +1 -231
  112. package/dist/components/selected-outline-types.d.ts +2 -15
  113. package/dist/components/selected-outline-uv.js +3 -106
  114. package/dist/esm/{chunk-w4244j4n.js → chunk-7prjt5n5.js} +32831 -26820
  115. package/dist/esm/internals.mjs +32831 -26820
  116. package/dist/esm/previewEntry.mjs +17304 -11293
  117. package/dist/esm/renderEntry.mjs +1 -1
  118. package/dist/helpers/calculate-timeline.d.ts +1 -7
  119. package/dist/helpers/calculate-timeline.js +2 -146
  120. package/dist/helpers/create-folder-tree.js +16 -1
  121. package/dist/helpers/editor-ruler.js +6 -5
  122. package/dist/helpers/format-file-location.d.ts +8 -0
  123. package/dist/helpers/format-file-location.js +14 -3
  124. package/dist/helpers/get-asset-metadata.d.ts +19 -0
  125. package/dist/helpers/get-asset-metadata.js +51 -6
  126. package/dist/helpers/get-connected-compositions.d.ts +1 -6
  127. package/dist/helpers/get-connected-compositions.js +2 -8
  128. package/dist/helpers/get-sequence-visible-range.d.ts +1 -5
  129. package/dist/helpers/get-sequence-visible-range.js +6 -51
  130. package/dist/helpers/get-timeline-max-zoom.d.ts +8 -0
  131. package/dist/helpers/get-timeline-max-zoom.js +17 -6
  132. package/dist/helpers/get-timeline-nestedness.d.ts +1 -2
  133. package/dist/helpers/get-timeline-nestedness.js +2 -12
  134. package/dist/helpers/get-timeline-sequence-sort-key.d.ts +2 -22
  135. package/dist/helpers/get-timeline-sequence-sort-key.js +2 -16
  136. package/dist/helpers/hoverable.d.ts +1 -0
  137. package/dist/helpers/hoverable.js +4 -1
  138. package/dist/helpers/is-current-selected-still.js +4 -2
  139. package/dist/helpers/sort-by-nonce-history.d.ts +1 -5
  140. package/dist/helpers/sort-by-nonce-history.js +3 -148
  141. package/dist/helpers/timeline-node-path-key.d.ts +1 -2
  142. package/dist/helpers/timeline-node-path-key.js +2 -2
  143. package/dist/helpers/use-menu-structure.js +20 -0
  144. package/dist/icons/enter.d.ts +4 -0
  145. package/dist/icons/enter.js +10 -0
  146. package/dist/state/editor-pixel-grid.d.ts +8 -0
  147. package/dist/state/editor-pixel-grid.js +18 -0
  148. package/dist/state/modals.d.ts +4 -0
  149. package/dist/state/playbackrate.d.ts +1 -0
  150. package/dist/state/playbackrate.js +4 -1
  151. package/package.json +14 -12
  152. package/dist/components/selected-outline-order.d.ts +0 -12
  153. package/dist/components/selected-outline-order.js +0 -251
  154. package/dist/helpers/get-box-quads-polyfill-internals.d.ts +0 -82
  155. package/dist/helpers/get-box-quads-polyfill-internals.js +0 -2403
  156. package/dist/helpers/get-box-quads-ponyfill.d.ts +0 -10
  157. package/dist/helpers/get-box-quads-ponyfill.js +0 -23
@@ -0,0 +1,4 @@
1
+ export declare const handleCanvasCaptureDrop: ({ files, setSelectedModal, }: {
2
+ readonly files: readonly File[];
3
+ readonly setSelectedModal: import("react").Dispatch<import("react").SetStateAction<import("../state/modals").ModalState | null>>;
4
+ }) => Promise<boolean>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleCanvasCaptureDrop = void 0;
4
+ const get_canvas_capture_import_1 = require("../helpers/get-canvas-capture-import");
5
+ const handleCanvasCaptureDrop = async ({ files, setSelectedModal, }) => {
6
+ if (files.length !== 1) {
7
+ return false;
8
+ }
9
+ const canvasCapture = await (0, get_canvas_capture_import_1.getCanvasCaptureImport)(files[0]);
10
+ if (canvasCapture === null) {
11
+ return false;
12
+ }
13
+ setSelectedModal({
14
+ type: 'new-comp',
15
+ canvasCapture,
16
+ folderName: null,
17
+ parentName: null,
18
+ stack: null,
19
+ });
20
+ return true;
21
+ };
22
+ exports.handleCanvasCaptureDrop = handleCanvasCaptureDrop;
@@ -7,10 +7,16 @@ const open_in_editor_1 = require("../helpers/open-in-editor");
7
7
  const NotificationCenter_1 = require("./Notifications/NotificationCenter");
8
8
  const open_in_new_window_1 = require("./open-in-new-window");
9
9
  const getCompositionMenuItems = ({ composition, connectionStatus, resolvedLocation, setSelectedModal, closeMenu, readOnlyStudio, includeCompositionManagementItems, editorId, editorName, }) => {
10
+ var _a;
10
11
  const fileLocation = (0, format_file_location_1.formatFileLocation)({
11
12
  location: resolvedLocation,
12
13
  root: window.remotion_cwd,
13
14
  });
15
+ const contextForAgents = (0, format_file_location_1.formatContextForAgents)({
16
+ location: resolvedLocation,
17
+ name: (_a = composition === null || composition === void 0 ? void 0 : composition.id) !== null && _a !== void 0 ? _a : null,
18
+ root: window.remotion_cwd,
19
+ });
14
20
  const showInEditorDisabled = !editorId ||
15
21
  !composition ||
16
22
  connectionStatus !== 'connected' ||
@@ -154,6 +160,26 @@ const getCompositionMenuItems = ({ composition, connectionStatus, resolvedLocati
154
160
  id: 'copy-actions-divider',
155
161
  }
156
162
  : null,
163
+ {
164
+ id: 'copy-context-for-agents',
165
+ keyHint: null,
166
+ label: `Copy context for agents`,
167
+ leftItem: null,
168
+ onClick: () => {
169
+ closeMenu();
170
+ if (!contextForAgents) {
171
+ return;
172
+ }
173
+ navigator.clipboard.writeText(contextForAgents).catch((err) => {
174
+ (0, NotificationCenter_1.showNotification)(`Could not copy to clipboard: ${err.message}`, 1000);
175
+ });
176
+ },
177
+ quickSwitcherLabel: null,
178
+ subMenu: null,
179
+ type: 'item',
180
+ value: 'copy-context-for-agents',
181
+ disabled: !contextForAgents,
182
+ },
157
183
  {
158
184
  id: 'copy-file-location',
159
185
  keyHint: null,
@@ -1,21 +1,2 @@
1
- export type OutlinePoint = {
2
- readonly x: number;
3
- readonly y: number;
4
- };
5
- export type SelectedOutline = {
6
- readonly key: string;
7
- readonly dimensions: {
8
- readonly width: number;
9
- readonly height: number;
10
- } | null;
11
- readonly uncroppedPoints: readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint] | null;
12
- readonly points: readonly [
13
- OutlinePoint,
14
- OutlinePoint,
15
- OutlinePoint,
16
- OutlinePoint
17
- ];
18
- };
19
- export declare const clamp: (value: number, min: number, max: number) => number;
20
- export declare const mix: (from: number, to: number, progress: number) => number;
21
- export declare const mixPoint: (from: OutlinePoint, to: OutlinePoint, progress: number) => OutlinePoint;
1
+ export { clampCanvasOutlineValue as clamp, mixCanvasOutlinePoints as mixPoint, mixCanvasOutlineValues as mix, } from '@remotion/canvas';
2
+ export type { CanvasOutline as SelectedOutline, CanvasOutlinePoint as OutlinePoint, } from '@remotion/canvas';
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mixPoint = exports.mix = exports.clamp = void 0;
4
- const clamp = (value, min, max) => {
5
- return Math.min(max, Math.max(min, value));
6
- };
7
- exports.clamp = clamp;
8
- const mix = (from, to, progress) => {
9
- return from + (to - from) * progress;
10
- };
11
- exports.mix = mix;
12
- const mixPoint = (from, to, progress) => {
13
- return {
14
- x: (0, exports.mix)(from.x, to.x, progress),
15
- y: (0, exports.mix)(from.y, to.y, progress),
16
- };
17
- };
18
- exports.mixPoint = mixPoint;
3
+ exports.mix = exports.mixPoint = exports.clamp = void 0;
4
+ const canvas_1 = require("@remotion/canvas");
5
+ Object.defineProperty(exports, "clamp", { enumerable: true, get: function () { return canvas_1.clampCanvasOutlineValue; } });
6
+ Object.defineProperty(exports, "mixPoint", { enumerable: true, get: function () { return canvas_1.mixCanvasOutlinePoints; } });
7
+ Object.defineProperty(exports, "mix", { enumerable: true, get: function () { return canvas_1.mixCanvasOutlineValues; } });
@@ -1,7 +1,4 @@
1
- import type { OverrideIdToNodePaths, TSequence } from 'remotion';
2
- import type { OutlinePoint, SelectedOutline } from './selected-outline-geometry';
3
- import type { SelectedOutlineLayoutTarget, SequenceWithSelectedOutline } from './selected-outline-types';
4
- import { type TimelineSelection, type TimelineSelectionInteraction } from './Timeline/TimelineSelection';
1
+ import type { OutlinePoint } from './selected-outline-geometry';
5
2
  export declare const pointToString: (point: OutlinePoint) => string;
6
3
  export declare const midpoint: (from: OutlinePoint, to: OutlinePoint) => OutlinePoint;
7
4
  export declare const getOutlineCenter: (points: readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint]) => OutlinePoint;
@@ -29,36 +26,18 @@ export declare const getSelectedOutlineRotationPivot: ({ dimensions, points, tra
29
26
  readonly points: readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint];
30
27
  readonly transformOriginValue: string;
31
28
  }) => OutlinePoint;
32
- type SvgViewport = {
33
- readonly x: number;
34
- readonly y: number;
35
- readonly width: number;
36
- readonly height: number;
37
- };
38
- type SvgScreenCtm = Pick<DOMMatrixReadOnly, 'a' | 'b' | 'c' | 'd' | 'e' | 'f'>;
39
- export declare const getTransformedSvgViewportPoints: ({ viewport, ctm, containerRect, }: {
40
- readonly viewport: SvgViewport;
41
- readonly ctm: SvgScreenCtm;
42
- readonly containerRect: Pick<DOMRect, "left" | "top">;
43
- }) => readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint];
44
- export declare const cropOutlinePoints: (points: readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint], crop: {
45
- readonly left: number;
46
- readonly right: number;
47
- readonly top: number;
48
- readonly bottom: number;
49
- }) => readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint];
50
- export declare const getSelectedSequenceKeys: (selectedItems: readonly TimelineSelection[]) => Set<string>;
51
- export declare const getSequenceKeysContainingSelection: (selectedItems: readonly TimelineSelection[]) => Set<string>;
29
+ export declare const getSelectedSequenceKeys: (selectedItems: readonly import("@remotion/canvas").CanvasSelectionItem[]) => Set<string>;
30
+ export declare const getSequenceKeysContainingSelection: (selectedItems: readonly import("@remotion/canvas").CanvasSelectionItem[]) => Set<string>;
52
31
  export declare const getOutlineSelectionInteraction: ({ shiftKey, metaKey, ctrlKey, }: {
53
32
  readonly shiftKey: boolean;
54
33
  readonly metaKey: boolean;
55
34
  readonly ctrlKey: boolean;
56
- }) => TimelineSelectionInteraction;
35
+ }) => import("@remotion/canvas").CanvasSelectionInteraction;
57
36
  type SelectedEffectFields = {
58
37
  allFields: boolean;
59
38
  fieldKeys: Set<string>;
60
39
  };
61
- export declare const getSelectedEffectFieldsBySequenceKey: (selectedItems: readonly TimelineSelection[]) => Map<string, Map<number, SelectedEffectFields>>;
40
+ export declare const getSelectedEffectFieldsBySequenceKey: (selectedItems: readonly import("@remotion/canvas").CanvasSelectionItem[]) => Map<string, Map<number, SelectedEffectFields>>;
62
41
  type SelectedTransformOriginInfo = {
63
42
  readonly sequenceKey: string;
64
43
  readonly displayFrame: number | null;
@@ -71,15 +50,7 @@ export type SelectedCropInfo = {
71
50
  readonly sequenceKey: string;
72
51
  readonly displayFrame: number | null;
73
52
  };
74
- export declare const getSelectedCropInfo: (selectedItems: readonly TimelineSelection[]) => SelectedCropInfo | null;
75
- export declare const getSelectedTransformOriginInfo: (selectedItems: readonly TimelineSelection[]) => SelectedTransformOriginInfo | null;
76
- export declare const getSelectedRotationInfo: (selectedItems: readonly TimelineSelection[]) => SelectedRotationInfo | null;
77
- export declare const getSequencesWithSelectableOutlines: ({ sequences, overrideIdsToNodePaths, compositions, timelinePosition, }: {
78
- readonly sequences: readonly TSequence[];
79
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
80
- readonly compositions?: readonly import("remotion").AnyComposition[] | undefined;
81
- readonly timelinePosition: number;
82
- }) => SequenceWithSelectedOutline[];
83
- export declare const measureOutlines: (container: SVGSVGElement, targets: readonly SelectedOutlineLayoutTarget[], hoveredTimelineNodePathKey: string | null) => SelectedOutline[];
84
- export declare const outlinesAreEqual: (a: readonly SelectedOutline[], b: readonly SelectedOutline[]) => boolean;
53
+ export declare const getSelectedCropInfo: (selectedItems: readonly import("@remotion/canvas").CanvasSelectionItem[]) => SelectedCropInfo | null;
54
+ export declare const getSelectedTransformOriginInfo: (selectedItems: readonly import("@remotion/canvas").CanvasSelectionItem[]) => SelectedTransformOriginInfo | null;
55
+ export declare const getSelectedRotationInfo: (selectedItems: readonly import("@remotion/canvas").CanvasSelectionItem[]) => SelectedRotationInfo | null;
85
56
  export {};
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.outlinesAreEqual = exports.measureOutlines = exports.getSequencesWithSelectableOutlines = exports.getSelectedRotationInfo = exports.getSelectedTransformOriginInfo = exports.getSelectedCropInfo = exports.getSelectedEffectFieldsBySequenceKey = exports.getOutlineSelectionInteraction = exports.getSequenceKeysContainingSelection = exports.getSelectedSequenceKeys = exports.cropOutlinePoints = exports.getTransformedSvgViewportPoints = exports.getSelectedOutlineRotationPivot = exports.getSelectedOutlineRotationCornerInfo = exports.getRotationCursor = exports.getSelectedOutlineRotationDeltaDegrees = exports.getAngleDegrees = exports.vectorBetween = exports.vectorLength = exports.dot = exports.getOutlineCenter = exports.midpoint = exports.pointToString = void 0;
4
- const calculate_timeline_1 = require("../helpers/calculate-timeline");
3
+ exports.getSelectedRotationInfo = exports.getSelectedTransformOriginInfo = exports.getSelectedCropInfo = exports.getSelectedEffectFieldsBySequenceKey = exports.getOutlineSelectionInteraction = exports.getSequenceKeysContainingSelection = exports.getSelectedSequenceKeys = exports.getSelectedOutlineRotationPivot = exports.getSelectedOutlineRotationCornerInfo = exports.getRotationCursor = exports.getSelectedOutlineRotationDeltaDegrees = exports.getAngleDegrees = exports.vectorBetween = exports.vectorLength = exports.dot = exports.getOutlineCenter = exports.midpoint = exports.pointToString = void 0;
5
4
  const colors_1 = require("../helpers/colors");
6
- const get_box_quads_polyfill_internals_js_1 = require("../helpers/get-box-quads-polyfill-internals.js");
7
- const get_box_quads_ponyfill_1 = require("../helpers/get-box-quads-ponyfill");
8
- const timeline_node_path_key_1 = require("../helpers/timeline-node-path-key");
9
5
  const selected_outline_geometry_1 = require("./selected-outline-geometry");
10
6
  const selected_outline_types_1 = require("./selected-outline-types");
11
7
  const selected_outline_uv_1 = require("./selected-outline-uv");
@@ -108,128 +104,6 @@ const getSelectedOutlineRotationPivot = ({ dimensions, points, transformOriginVa
108
104
  return (0, selected_outline_uv_1.getUvHandlePosition)(points, uv);
109
105
  };
110
106
  exports.getSelectedOutlineRotationPivot = getSelectedOutlineRotationPivot;
111
- const rectToPoints = (elementRect, containerRect) => {
112
- const left = elementRect.left - containerRect.left;
113
- const top = elementRect.top - containerRect.top;
114
- const right = elementRect.right - containerRect.left;
115
- const bottom = elementRect.bottom - containerRect.top;
116
- return [
117
- { x: left, y: top },
118
- { x: right, y: top },
119
- { x: right, y: bottom },
120
- { x: left, y: bottom },
121
- ];
122
- };
123
- const getTransformedSvgViewportPoints = ({ viewport, ctm, containerRect, }) => {
124
- const transformPoint = (x, y) => ({
125
- x: ctm.a * x + ctm.c * y + ctm.e - containerRect.left,
126
- y: ctm.b * x + ctm.d * y + ctm.f - containerRect.top,
127
- });
128
- const left = viewport.x;
129
- const top = viewport.y;
130
- const right = viewport.x + viewport.width;
131
- const bottom = viewport.y + viewport.height;
132
- return [
133
- transformPoint(left, top),
134
- transformPoint(right, top),
135
- transformPoint(right, bottom),
136
- transformPoint(left, bottom),
137
- ];
138
- };
139
- exports.getTransformedSvgViewportPoints = getTransformedSvgViewportPoints;
140
- const quadToPoints = (quad, containerRect) => {
141
- // `getBoxQuads`/the ponyfill returns the quad in viewport coordinates.
142
- // The overlay <svg> is unscaled (the canvas `scale()`/pan live on a sibling
143
- // container, not the svg), so 1 user unit == 1 px and we only need to move
144
- // the quad into the svg's local space by subtracting its viewport origin.
145
- // We deliberately do not pass `relativeTo` to the ponyfill: when the target
146
- // is not an ancestor of the element, the polyfill cannot resolve the
147
- // coordinate space and leaves the quad in viewport coordinates.
148
- return [
149
- { x: quad.p1.x - containerRect.left, y: quad.p1.y - containerRect.top },
150
- { x: quad.p2.x - containerRect.left, y: quad.p2.y - containerRect.top },
151
- { x: quad.p3.x - containerRect.left, y: quad.p3.y - containerRect.top },
152
- { x: quad.p4.x - containerRect.left, y: quad.p4.y - containerRect.top },
153
- ];
154
- };
155
- const isSvgSvgElement = (element) => {
156
- var _a;
157
- const ownerSvgSvgElement = (_a = element.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.SVGSVGElement;
158
- return ((typeof SVGSVGElement !== 'undefined' &&
159
- element instanceof SVGSVGElement) ||
160
- (ownerSvgSvgElement !== undefined && element instanceof ownerSvgSvgElement));
161
- };
162
- const getSvgSvgElementViewport = (element) => {
163
- const viewBox = element.viewBox.baseVal;
164
- if (viewBox.width > 0 && viewBox.height > 0) {
165
- return {
166
- x: viewBox.x,
167
- y: viewBox.y,
168
- width: viewBox.width,
169
- height: viewBox.height,
170
- };
171
- }
172
- return {
173
- x: 0,
174
- y: 0,
175
- width: element.width.baseVal.value,
176
- height: element.height.baseVal.value,
177
- };
178
- };
179
- const getSvgSvgElementOutlinePoints = (element, containerRect) => {
180
- const ctm = element.getScreenCTM();
181
- const viewport = getSvgSvgElementViewport(element);
182
- if (ctm === null || (viewport.width === 0 && viewport.height === 0)) {
183
- return null;
184
- }
185
- return (0, exports.getTransformedSvgViewportPoints)({
186
- viewport,
187
- ctm,
188
- containerRect,
189
- });
190
- };
191
- const getElementOutlinePoints = (element, containerRect, includeOutsideContainer) => {
192
- const elementRect = element.getBoundingClientRect();
193
- if (elementRect.width === 0 && elementRect.height === 0) {
194
- return null;
195
- }
196
- if (!includeOutsideContainer &&
197
- (elementRect.right <= containerRect.left ||
198
- elementRect.left >= containerRect.right ||
199
- elementRect.bottom <= containerRect.top ||
200
- elementRect.top >= containerRect.bottom)) {
201
- return null;
202
- }
203
- if (isSvgSvgElement(element)) {
204
- return getSvgSvgElementOutlinePoints(element, containerRect);
205
- }
206
- const quads = (0, get_box_quads_ponyfill_1.getBoxQuadsPonyfill)(element, {
207
- box: 'border',
208
- });
209
- const quad = quads === null || quads === void 0 ? void 0 : quads[0];
210
- if (!quad) {
211
- return rectToPoints(elementRect, containerRect);
212
- }
213
- return quadToPoints(quad, containerRect);
214
- };
215
- const cropOutlinePoints = (points, crop) => {
216
- if (crop.left === 0 &&
217
- crop.right === 0 &&
218
- crop.top === 0 &&
219
- crop.bottom === 0) {
220
- return points;
221
- }
222
- const { left, top } = crop;
223
- const right = 1 - crop.right;
224
- const bottom = 1 - crop.bottom;
225
- return [
226
- (0, selected_outline_uv_1.getUvHandlePosition)(points, [left, top]),
227
- (0, selected_outline_uv_1.getUvHandlePosition)(points, [right, top]),
228
- (0, selected_outline_uv_1.getUvHandlePosition)(points, [right, bottom]),
229
- (0, selected_outline_uv_1.getUvHandlePosition)(points, [left, bottom]),
230
- ];
231
- };
232
- exports.cropOutlinePoints = cropOutlinePoints;
233
107
  const getSelectedSequenceKeys = (selectedItems) => {
234
108
  return new Set(selectedItems
235
109
  .filter((item) => item.type === 'sequence')
@@ -388,107 +262,3 @@ const getSelectedRotationInfo = (selectedItems) => {
388
262
  };
389
263
  };
390
264
  exports.getSelectedRotationInfo = getSelectedRotationInfo;
391
- const getSequencesWithSelectableOutlines = ({ sequences, overrideIdsToNodePaths, compositions = [], timelinePosition, }) => {
392
- return (0, calculate_timeline_1.calculateTimeline)({
393
- sequences: [...sequences],
394
- overrideIdsToNodePaths,
395
- compositions,
396
- })
397
- .filter((track) => {
398
- if (track.nodePathInfo === null) {
399
- return false;
400
- }
401
- return (track.sequence.showInTimeline &&
402
- timelinePosition >= track.sequence.from &&
403
- timelinePosition < track.sequence.from + track.sequence.duration &&
404
- track.nodePathInfo.auxiliaryKeys.length === 0);
405
- })
406
- .filter((track) => track.sequence.refForOutline !== null)
407
- .sort((a, b) => a.depth - b.depth)
408
- .map((track) => {
409
- if (track.nodePathInfo === null) {
410
- throw new Error('Expected selected outline to have a node path');
411
- }
412
- return {
413
- depth: track.depth,
414
- keyframeDisplayOffset: track.keyframeDisplayOffset,
415
- key: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(track.nodePathInfo),
416
- nodePathInfo: track.nodePathInfo,
417
- sequence: track.sequence,
418
- };
419
- });
420
- };
421
- exports.getSequencesWithSelectableOutlines = getSequencesWithSelectableOutlines;
422
- const measureOutlines = (container, targets, hoveredTimelineNodePathKey) => {
423
- // Reuse shared ancestor geometry within this synchronous batch only.
424
- (0, get_box_quads_polyfill_internals_js_1.useCache)();
425
- const containerRect = container.getBoundingClientRect();
426
- const outlines = [];
427
- for (const target of targets) {
428
- const element = target.ref.current;
429
- if (element === null) {
430
- continue;
431
- }
432
- const includeOutsideContainer = target.showSelectedOutline ||
433
- (0, timeline_node_path_key_1.timelineSequenceNodePathToKey)(target.nodePathInfo.sequenceSubscriptionKey) === hoveredTimelineNodePathKey;
434
- const uncroppedPoints = getElementOutlinePoints(element, containerRect, includeOutsideContainer);
435
- if (uncroppedPoints === null) {
436
- continue;
437
- }
438
- const points = (0, exports.cropOutlinePoints)(uncroppedPoints, target.crop);
439
- outlines.push({
440
- key: target.key,
441
- dimensions: element instanceof HTMLElement
442
- ? {
443
- width: element.offsetWidth,
444
- height: element.offsetHeight,
445
- }
446
- : element instanceof SVGSVGElement
447
- ? {
448
- width: element.width.baseVal.value,
449
- height: element.height.baseVal.value,
450
- }
451
- : null,
452
- uncroppedPoints,
453
- points,
454
- });
455
- }
456
- return outlines;
457
- };
458
- exports.measureOutlines = measureOutlines;
459
- const outlinesAreEqual = (a, b) => {
460
- var _a, _b, _c, _d;
461
- if (a.length !== b.length) {
462
- return false;
463
- }
464
- for (let i = 0; i < a.length; i++) {
465
- if (a[i].key !== b[i].key) {
466
- return false;
467
- }
468
- if (((_a = a[i].dimensions) === null || _a === void 0 ? void 0 : _a.width) !== ((_b = b[i].dimensions) === null || _b === void 0 ? void 0 : _b.width) ||
469
- ((_c = a[i].dimensions) === null || _c === void 0 ? void 0 : _c.height) !== ((_d = b[i].dimensions) === null || _d === void 0 ? void 0 : _d.height)) {
470
- return false;
471
- }
472
- const aUncropped = a[i].uncroppedPoints;
473
- const bUncropped = b[i].uncroppedPoints;
474
- if ((aUncropped === null) !== (bUncropped === null)) {
475
- return false;
476
- }
477
- if (aUncropped !== null && bUncropped !== null) {
478
- for (let j = 0; j < aUncropped.length; j++) {
479
- if (Math.abs(aUncropped[j].x - bUncropped[j].x) > 0.01 ||
480
- Math.abs(aUncropped[j].y - bUncropped[j].y) > 0.01) {
481
- return false;
482
- }
483
- }
484
- }
485
- for (let j = 0; j < a[i].points.length; j++) {
486
- if (Math.abs(a[i].points[j].x - b[i].points[j].x) > 0.01 ||
487
- Math.abs(a[i].points[j].y - b[i].points[j].y) > 0.01) {
488
- return false;
489
- }
490
- }
491
- }
492
- return true;
493
- };
494
- exports.outlinesAreEqual = outlinesAreEqual;
@@ -1,15 +1,15 @@
1
+ import type { CanvasOutlineTarget } from '@remotion/canvas';
1
2
  import type { CanUpdateSequencePropStatus, CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusStatic, InteractivitySchema, InteractivitySchemaField, SequencePropsSubscriptionKey, TSequence } from 'remotion';
2
3
  import type { SequenceNodePathInfo } from '../helpers/get-timeline-sequence-sort-key';
3
4
  import type { ComboboxValue } from './NewComposition/ComboBox';
4
5
  import type { TimelineSelection } from './Timeline/TimelineSelection';
5
6
  export type SelectedOutlineContextMenuOpenResult = false | readonly ComboboxValue[];
6
7
  export type SelectedOutlineContextMenuOpenHandler = () => SelectedOutlineContextMenuOpenResult | Promise<SelectedOutlineContextMenuOpenResult>;
7
- export type SelectedOutlineLayoutTarget = {
8
+ export type SelectedOutlineLayoutTarget = CanvasOutlineTarget & {
8
9
  readonly key: string;
9
10
  readonly containsSelection: boolean;
10
11
  readonly keyframeDisplayOffset: number;
11
12
  readonly nodePathInfo: SequenceNodePathInfo;
12
- readonly ref: React.RefObject<Element | null>;
13
13
  readonly selected: boolean;
14
14
  readonly selectedForCrop: boolean;
15
15
  readonly selectedForRotation: boolean;
@@ -19,12 +19,6 @@ export type SelectedOutlineLayoutTarget = {
19
19
  readonly transformOriginValue: string;
20
20
  readonly selection: TimelineSelection;
21
21
  readonly sequence: TSequence;
22
- readonly crop: {
23
- readonly left: number;
24
- readonly right: number;
25
- readonly top: number;
26
- readonly bottom: number;
27
- };
28
22
  };
29
23
  export type SelectedOutlineTarget = SelectedOutlineLayoutTarget & {
30
24
  readonly canCrop: boolean;
@@ -145,13 +139,6 @@ export type SelectedOutlineRotationDragState = {
145
139
  readonly startValue: string;
146
140
  readonly target: SelectedOutlineRotationDragTarget;
147
141
  };
148
- export type SequenceWithSelectedOutline = {
149
- readonly depth: number;
150
- readonly keyframeDisplayOffset: number;
151
- readonly key: string;
152
- readonly nodePathInfo: SequenceNodePathInfo;
153
- readonly sequence: TSequence;
154
- };
155
142
  export declare const translateFieldKey = "style.translate";
156
143
  export declare const scaleFieldKey = "style.scale";
157
144
  export declare const rotateFieldKey = "style.rotate";
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSelectedUvHandles = exports.roundNumericUvEllipseValue = exports.getUvCoordinateForPoint = exports.getUvEllipseInteractiveControls = exports.getUvHandleConnectionEllipses = exports.getUvHandleConnectionLines = exports.getUvHandlePosition = exports.tuplesEqual = void 0;
4
4
  exports.constrainUv = constrainUv;
5
5
  exports.roundUvCoordinate = roundUvCoordinate;
6
+ const canvas_1 = require("@remotion/canvas");
6
7
  const remotion_1 = require("remotion");
7
8
  const selected_outline_geometry_1 = require("./selected-outline-geometry");
8
9
  const timeline_field_utils_1 = require("./Timeline/timeline-field-utils");
@@ -91,55 +92,7 @@ const tuplesEqual = (left, right) => {
91
92
  return left[0] === right[0] && left[1] === right[1];
92
93
  };
93
94
  exports.tuplesEqual = tuplesEqual;
94
- const getBilinearUvHandlePosition = (points, uv) => {
95
- const [tl, tr, br, bl] = points;
96
- const top = (0, selected_outline_geometry_1.mixPoint)(tl, tr, uv[0]);
97
- const bottom = (0, selected_outline_geometry_1.mixPoint)(bl, br, uv[0]);
98
- return (0, selected_outline_geometry_1.mixPoint)(top, bottom, uv[1]);
99
- };
100
- const projectiveEpsilon = 0.000001;
101
- const getProjectiveTransform = (points) => {
102
- const [tl, tr, br, bl] = points;
103
- const dx1 = tr.x - br.x;
104
- const dx2 = bl.x - br.x;
105
- const dx3 = tl.x - tr.x + br.x - bl.x;
106
- const dy1 = tr.y - br.y;
107
- const dy2 = bl.y - br.y;
108
- const dy3 = tl.y - tr.y + br.y - bl.y;
109
- let g = 0;
110
- let h = 0;
111
- if (Math.abs(dx3) > projectiveEpsilon || Math.abs(dy3) > projectiveEpsilon) {
112
- const determinant = dx1 * dy2 - dx2 * dy1;
113
- if (Math.abs(determinant) < projectiveEpsilon) {
114
- return null;
115
- }
116
- g = (dx3 * dy2 - dx2 * dy3) / determinant;
117
- h = (dx1 * dy3 - dx3 * dy1) / determinant;
118
- }
119
- return {
120
- a: tr.x - tl.x + g * tr.x,
121
- b: bl.x - tl.x + h * bl.x,
122
- c: tl.x,
123
- d: tr.y - tl.y + g * tr.y,
124
- e: bl.y - tl.y + h * bl.y,
125
- f: tl.y,
126
- g,
127
- h,
128
- };
129
- };
130
- const applyProjectiveTransform = (transform, uv) => {
131
- const denominator = transform.g * uv[0] + transform.h * uv[1] + 1;
132
- return {
133
- x: (transform.a * uv[0] + transform.b * uv[1] + transform.c) / denominator,
134
- y: (transform.d * uv[0] + transform.e * uv[1] + transform.f) / denominator,
135
- };
136
- };
137
- const getUvHandlePosition = (points, uv) => {
138
- const transform = getProjectiveTransform(points);
139
- return transform === null
140
- ? getBilinearUvHandlePosition(points, uv)
141
- : applyProjectiveTransform(transform, uv);
142
- };
95
+ const getUvHandlePosition = (points, uv) => (0, canvas_1.getCanvasOutlinePointAtUv)(points, uv);
143
96
  exports.getUvHandlePosition = getUvHandlePosition;
144
97
  const getUvHandleConnectionLines = ({ handles, points, }) => {
145
98
  const handlesByField = new Map(handles.map((handle) => [
@@ -337,63 +290,7 @@ const getUvEllipseInteractiveControls = ({ handles, dimensions, points, }) => {
337
290
  return controls;
338
291
  };
339
292
  exports.getUvEllipseInteractiveControls = getUvEllipseInteractiveControls;
340
- const vectorBetween = (from, to) => {
341
- return { x: to.x - from.x, y: to.y - from.y };
342
- };
343
- const getBilinearUvCoordinateForPoint = (points, point) => {
344
- const [tl, tr, br, bl] = points;
345
- let u = 0.5;
346
- let v = 0.5;
347
- for (let i = 0; i < 8; i++) {
348
- const current = getBilinearUvHandlePosition(points, [u, v]);
349
- const errorX = current.x - point.x;
350
- const errorY = current.y - point.y;
351
- if (Math.abs(errorX) + Math.abs(errorY) < 0.001) {
352
- break;
353
- }
354
- const du = {
355
- x: (0, selected_outline_geometry_1.mix)(tr.x - tl.x, br.x - bl.x, v),
356
- y: (0, selected_outline_geometry_1.mix)(tr.y - tl.y, br.y - bl.y, v),
357
- };
358
- const dv = vectorBetween((0, selected_outline_geometry_1.mixPoint)(tl, tr, u), (0, selected_outline_geometry_1.mixPoint)(bl, br, u));
359
- const determinant = du.x * dv.y - du.y * dv.x;
360
- if (Math.abs(determinant) < 0.000001) {
361
- break;
362
- }
363
- u -= (errorX * dv.y - errorY * dv.x) / determinant;
364
- v -= (du.x * errorY - du.y * errorX) / determinant;
365
- }
366
- return [u, v];
367
- };
368
- const getUvCoordinateForPoint = (points, point) => {
369
- const transform = getProjectiveTransform(points);
370
- if (transform === null) {
371
- return getBilinearUvCoordinateForPoint(points, point);
372
- }
373
- const determinant = transform.a * (transform.e - transform.f * transform.h) -
374
- transform.b * (transform.d - transform.f * transform.g) +
375
- transform.c * (transform.d * transform.h - transform.e * transform.g);
376
- if (Math.abs(determinant) < projectiveEpsilon) {
377
- return getBilinearUvCoordinateForPoint(points, point);
378
- }
379
- const inverseA = transform.e - transform.f * transform.h;
380
- const inverseB = transform.c * transform.h - transform.b;
381
- const inverseC = transform.b * transform.f - transform.c * transform.e;
382
- const inverseD = transform.f * transform.g - transform.d;
383
- const inverseE = transform.a - transform.c * transform.g;
384
- const inverseF = transform.c * transform.d - transform.a * transform.f;
385
- const inverseG = transform.d * transform.h - transform.e * transform.g;
386
- const inverseH = transform.b * transform.g - transform.a * transform.h;
387
- const inverseI = transform.a * transform.e - transform.b * transform.d;
388
- const denominator = inverseG * point.x + inverseH * point.y + inverseI;
389
- if (Math.abs(denominator) < projectiveEpsilon) {
390
- return getBilinearUvCoordinateForPoint(points, point);
391
- }
392
- return [
393
- (inverseA * point.x + inverseB * point.y + inverseC) / denominator,
394
- (inverseD * point.x + inverseE * point.y + inverseF) / denominator,
395
- ];
396
- };
293
+ const getUvCoordinateForPoint = (points, point) => (0, canvas_1.getCanvasOutlineUvForPoint)(points, point);
397
294
  exports.getUvCoordinateForPoint = getUvCoordinateForPoint;
398
295
  function constrainUv(value, schema) {
399
296
  var _a, _b;