@remotion/studio 4.0.475 → 4.0.477

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 (88) hide show
  1. package/dist/components/Canvas.js +40 -1
  2. package/dist/components/ColorPicker/ColorPickerPopup.d.ts +6 -0
  3. package/dist/components/ColorPicker/ColorPickerPopup.js +11 -6
  4. package/dist/components/ControlButton.d.ts +1 -0
  5. package/dist/components/ControlButton.js +7 -2
  6. package/dist/components/EditorGuides/Guide.js +122 -20
  7. package/dist/components/EditorRuler/Ruler.js +21 -15
  8. package/dist/components/EditorRuler/index.js +18 -10
  9. package/dist/components/GlobalKeybindings.js +12 -0
  10. package/dist/components/KeyboardShortcutsExplainer.js +24 -0
  11. package/dist/components/NewComposition/InputDragger.d.ts +6 -0
  12. package/dist/components/NewComposition/InputDragger.js +40 -14
  13. package/dist/components/NewComposition/RenameComposition.js +8 -1
  14. package/dist/components/NewComposition/RenameFolder.js +8 -1
  15. package/dist/components/NewComposition/RenameStaticFile.js +11 -1
  16. package/dist/components/Notifications/Notification.js +5 -4
  17. package/dist/components/Notifications/NotificationCenter.js +1 -1
  18. package/dist/components/ObserveDefaultPropsContext.js +6 -2
  19. package/dist/components/OutlineToggle.js +1 -1
  20. package/dist/components/PlayPause.js +22 -66
  21. package/dist/components/PreviewToolbar.js +15 -1
  22. package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +2 -1
  23. package/dist/components/SelectedOutlineElement.d.ts +17 -0
  24. package/dist/components/SelectedOutlineElement.js +938 -0
  25. package/dist/components/SelectedOutlineOverlay.d.ts +4 -174
  26. package/dist/components/SelectedOutlineOverlay.js +310 -1392
  27. package/dist/components/SelectedOutlineUvControls.js +1 -1
  28. package/dist/components/ShowGuidesProvider.js +4 -4
  29. package/dist/components/Timeline/SubscribeToNodePaths.d.ts +2 -1
  30. package/dist/components/Timeline/SubscribeToNodePaths.js +2 -1
  31. package/dist/components/Timeline/Timeline.js +3 -1
  32. package/dist/components/Timeline/TimelineClipboardKeybindings.js +9 -10
  33. package/dist/components/Timeline/TimelineDeleteKeybindings.js +15 -4
  34. package/dist/components/Timeline/TimelineKeyframeEasingLine.js +7 -11
  35. package/dist/components/Timeline/TimelineList.js +1 -1
  36. package/dist/components/Timeline/TimelineRotationField.js +17 -17
  37. package/dist/components/Timeline/TimelineScaleField.js +1 -1
  38. package/dist/components/Timeline/TimelineSelection.d.ts +27 -13
  39. package/dist/components/Timeline/TimelineSelection.js +47 -28
  40. package/dist/components/Timeline/TimelineSequence.js +169 -8
  41. package/dist/components/Timeline/TimelineSequenceFrame.d.ts +1 -0
  42. package/dist/components/Timeline/TimelineSequenceFrame.js +17 -6
  43. package/dist/components/Timeline/TimelineSequenceItem.d.ts +1 -0
  44. package/dist/components/Timeline/TimelineSequenceItem.js +294 -142
  45. package/dist/components/Timeline/TimelineSequenceName.d.ts +4 -2
  46. package/dist/components/Timeline/TimelineSequenceName.js +67 -2
  47. package/dist/components/Timeline/TimelineTransformOriginField.js +1 -1
  48. package/dist/components/Timeline/TimelineTranslateField.js +1 -1
  49. package/dist/components/Timeline/TimelineUvCoordinateField.js +1 -1
  50. package/dist/components/Timeline/delete-selected-timeline-item.js +4 -0
  51. package/dist/components/Timeline/disable-sequence-interactivity.d.ts +8 -0
  52. package/dist/components/Timeline/disable-sequence-interactivity.js +24 -0
  53. package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +1 -2
  54. package/dist/components/Timeline/get-sequence-context-menu-items.d.ts +20 -0
  55. package/dist/components/Timeline/get-sequence-context-menu-items.js +160 -0
  56. package/dist/components/Timeline/reset-selected-timeline-props.js +2 -2
  57. package/dist/components/Timeline/sequence-props-subscription-store.d.ts +2 -1
  58. package/dist/components/Timeline/sequence-props-subscription-store.js +11 -3
  59. package/dist/components/Timeline/should-clear-selection-on-pointer-down.d.ts +2 -0
  60. package/dist/components/Timeline/should-clear-selection-on-pointer-down.js +16 -2
  61. package/dist/components/Timeline/timeline-rotation-utils.d.ts +1 -1
  62. package/dist/components/Timeline/timeline-rotation-utils.js +4 -2
  63. package/dist/components/Timeline/update-selected-easing.d.ts +4 -6
  64. package/dist/components/Timeline/use-sequence-props-subscription.d.ts +2 -1
  65. package/dist/components/Timeline/use-sequence-props-subscription.js +3 -1
  66. package/dist/components/Timeline/use-timeline-keyframe-drag.d.ts +37 -1
  67. package/dist/components/Timeline/use-timeline-keyframe-drag.js +290 -14
  68. package/dist/components/import-assets.d.ts +36 -8
  69. package/dist/components/import-assets.js +170 -10
  70. package/dist/components/selected-outline-drag.d.ts +117 -0
  71. package/dist/components/selected-outline-drag.js +427 -0
  72. package/dist/components/selected-outline-measurement.d.ts +67 -0
  73. package/dist/components/selected-outline-measurement.js +355 -0
  74. package/dist/components/selected-outline-types.d.ts +121 -0
  75. package/dist/components/selected-outline-types.js +15 -0
  76. package/dist/components/selected-outline-uv.d.ts +1 -0
  77. package/dist/components/selected-outline-uv.js +12 -0
  78. package/dist/esm/{chunk-qaqqvw4q.js → chunk-t8fjnw2d.js} +14059 -12029
  79. package/dist/esm/internals.mjs +14059 -12029
  80. package/dist/esm/previewEntry.mjs +14066 -12036
  81. package/dist/esm/renderEntry.mjs +1 -1
  82. package/dist/helpers/editor-guide-selection.d.ts +31 -0
  83. package/dist/helpers/editor-guide-selection.js +58 -0
  84. package/dist/helpers/editor-ruler.d.ts +3 -3
  85. package/dist/helpers/editor-ruler.js +16 -18
  86. package/dist/state/editor-guides.d.ts +2 -2
  87. package/dist/state/editor-guides.js +2 -2
  88. package/package.json +11 -11
@@ -0,0 +1,355 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.outlinesAreEqual = exports.measureOutlines = exports.getSequencesWithSelectableOutlines = exports.getSelectedTransformOriginInfo = exports.getSelectedEffectFieldsBySequenceKey = exports.getOutlineSelectionInteraction = exports.getSequenceKeysContainingSelection = exports.getSelectedSequenceKeys = 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");
5
+ const get_box_quads_ponyfill_1 = require("../helpers/get-box-quads-ponyfill");
6
+ const selected_outline_geometry_1 = require("./selected-outline-geometry");
7
+ const selected_outline_types_1 = require("./selected-outline-types");
8
+ const selected_outline_uv_1 = require("./selected-outline-uv");
9
+ const parse_keyframe_field_from_node_path_1 = require("./Timeline/parse-keyframe-field-from-node-path");
10
+ const TimelineSelection_1 = require("./Timeline/TimelineSelection");
11
+ const transform_origin_utils_1 = require("./Timeline/transform-origin-utils");
12
+ const pointToString = (point) => `${point.x},${point.y}`;
13
+ exports.pointToString = pointToString;
14
+ const midpoint = (from, to) => {
15
+ return (0, selected_outline_geometry_1.mixPoint)(from, to, 0.5);
16
+ };
17
+ exports.midpoint = midpoint;
18
+ const getOutlineCenter = (points) => {
19
+ const [tl, tr, br, bl] = points;
20
+ return {
21
+ x: (tl.x + tr.x + br.x + bl.x) / 4,
22
+ y: (tl.y + tr.y + br.y + bl.y) / 4,
23
+ };
24
+ };
25
+ exports.getOutlineCenter = getOutlineCenter;
26
+ const dot = (left, right) => {
27
+ return left.x * right.x + left.y * right.y;
28
+ };
29
+ exports.dot = dot;
30
+ const vectorLength = (vector) => {
31
+ return Math.hypot(vector.x, vector.y);
32
+ };
33
+ exports.vectorLength = vectorLength;
34
+ const vectorBetween = (from, to) => {
35
+ return { x: to.x - from.x, y: to.y - from.y };
36
+ };
37
+ exports.vectorBetween = vectorBetween;
38
+ const getAngleDegrees = (from, to) => {
39
+ return Math.atan2(to.y - from.y, to.x - from.x) * (180 / Math.PI);
40
+ };
41
+ exports.getAngleDegrees = getAngleDegrees;
42
+ const getSelectedOutlineRotationDeltaDegrees = ({ from, to, }) => {
43
+ return ((((to - from) % 360) + 540) % 360) - 180;
44
+ };
45
+ exports.getSelectedOutlineRotationDeltaDegrees = getSelectedOutlineRotationDeltaDegrees;
46
+ const normalizeRotationCursorDegrees = (rotation) => {
47
+ const normalizedRotation = ((rotation % 360) + 360) % 360;
48
+ return Number(normalizedRotation.toFixed(3));
49
+ };
50
+ const getRotationCursor = (rotation) => {
51
+ const normalizedRotation = normalizeRotationCursorDegrees(rotation);
52
+ const transform = normalizedRotation === 0
53
+ ? ''
54
+ : `<g transform="rotate(${normalizedRotation} 32 32)">`;
55
+ const transformEnd = normalizedRotation === 0 ? '' : '</g>';
56
+ const svg = `<svg width="24" height="24" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">${transform}<g transform="scale(0.876712329)" filter="url(#filter0_d_1_14)"><path d="M10.9111 17.7687C10.3413 18.3701 10.367 19.3195 10.9684 19.8893L20.7687 29.1738C21.3701 29.7436 22.3195 29.7179 22.8893 29.1165C23.459 28.5151 23.4334 27.5657 22.832 26.996L14.1206 18.7431L22.3735 10.0316C22.9432 9.43022 22.9176 8.48082 22.3162 7.91107C21.7148 7.34133 20.7654 7.36699 20.1956 7.96839L10.9111 17.7687ZM49.3923 58.3118C49.9509 58.9235 50.8996 58.9667 51.5114 58.4081L61.481 49.3055C62.0927 48.7469 62.1359 47.7981 61.5773 47.1863C61.0187 46.5745 60.0699 46.5314 59.4581 47.09L50.5963 55.1812L42.5051 46.3194C41.9465 45.7076 40.9977 45.6645 40.386 46.2231C39.7742 46.7817 39.7311 47.7304 40.2896 48.3422L49.3923 58.3118ZM12.6747 18.7431L13 19.8893C22.1283 19.6426 30.7584 21.4283 37.8564 26.6927C44.8518 31.8809 49.734 39.8538 49 56H50.5963H51.5114C52.2774 39.1461 47.6482 30.2198 39.6436 24.2831C31.7416 18.4224 22.3717 17.2467 13 17.5L12.6747 18.7431Z" fill="black"/><path d="M19.1064 6.93652C20.2459 5.73379 22.1448 5.68278 23.3477 6.82227C24.5505 7.96181 24.6022 9.86076 23.4629 11.0635L18.7373 16.0508C26.3487 16.4239 33.9128 18.1651 40.5371 23.0781C44.7339 26.1907 48.0794 30.1189 50.2568 35.4834C51.9666 39.6958 52.9327 44.7395 53.0742 50.8867L58.4463 45.9824C59.6697 44.8654 61.5673 44.9514 62.6846 46.1748C63.8018 47.3985 63.7155 49.296 62.4922 50.4131L52.5225 59.5156C51.337 60.5979 49.5196 60.5507 48.3916 59.4346L48.2842 59.3232L39.1816 49.3535C38.0648 48.1301 38.1507 46.2324 39.374 45.1152C40.5975 43.9979 42.4961 44.0841 43.6133 45.3076L47.4756 49.5381C47.1908 44.7613 46.2876 40.9448 44.9482 37.8291C43.0666 33.4521 40.2851 30.3614 36.9629 27.8975C31.8259 24.0875 25.8071 22.1663 19.2891 21.5732L23.8633 25.9072C25.0662 27.0468 25.1178 28.9457 23.9785 30.1484C22.8746 31.3135 21.0576 31.3982 19.8516 30.3662L19.7373 30.2627L9.93652 20.9785C8.73384 19.839 8.6828 17.9401 9.82227 16.7373L19.1064 6.93652Z" stroke="white" stroke-width="3"/></g>${transformEnd}<defs><filter id="filter0_d_1_14" x="0" y="0" width="72.4696" height="72.3004" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="3"/><feGaussianBlur stdDeviation="3.75"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1_14"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1_14" result="shape"/></filter></defs></svg>`;
57
+ return `url("data:image/svg+xml,${encodeURIComponent(svg)}") 12 12, alias`;
58
+ };
59
+ exports.getRotationCursor = getRotationCursor;
60
+ const rotationCursorBaseDegrees = {
61
+ 'top-left': 270,
62
+ 'top-right': 0,
63
+ 'bottom-right': 90,
64
+ 'bottom-left': 180,
65
+ };
66
+ const getOutlineRotationDegrees = (points) => {
67
+ const [tl, tr] = points;
68
+ return (0, exports.getAngleDegrees)(tl, tr);
69
+ };
70
+ const getRotationCursorDegrees = (points, corner) => normalizeRotationCursorDegrees(getOutlineRotationDegrees(points) + rotationCursorBaseDegrees[corner]);
71
+ const getSelectedOutlineRotationCornerInfo = (points, corner) => {
72
+ const [tl, tr, br, bl] = points;
73
+ const point = {
74
+ 'top-left': tl,
75
+ 'top-right': tr,
76
+ 'bottom-right': br,
77
+ 'bottom-left': bl,
78
+ }[corner];
79
+ const center = (0, exports.getOutlineCenter)(points);
80
+ const cursorDegrees = getRotationCursorDegrees(points, corner);
81
+ return {
82
+ center,
83
+ cursor: (0, exports.getRotationCursor)(cursorDegrees),
84
+ cursorDegrees,
85
+ point,
86
+ };
87
+ };
88
+ exports.getSelectedOutlineRotationCornerInfo = getSelectedOutlineRotationCornerInfo;
89
+ const getSelectedOutlineRotationPivot = ({ dimensions, points, transformOriginValue, }) => {
90
+ if (dimensions === null) {
91
+ return (0, exports.getOutlineCenter)(points);
92
+ }
93
+ const parsed = (0, transform_origin_utils_1.parseTransformOrigin)(transformOriginValue);
94
+ if (parsed === null) {
95
+ return (0, exports.getOutlineCenter)(points);
96
+ }
97
+ const uv = (0, transform_origin_utils_1.parsedTransformOriginToUv)({
98
+ parsed,
99
+ width: dimensions.width,
100
+ height: dimensions.height,
101
+ });
102
+ if (uv === null) {
103
+ return (0, exports.getOutlineCenter)(points);
104
+ }
105
+ return (0, selected_outline_uv_1.getUvHandlePosition)(points, uv);
106
+ };
107
+ exports.getSelectedOutlineRotationPivot = getSelectedOutlineRotationPivot;
108
+ const rectToPoints = (elementRect, containerRect) => {
109
+ const left = elementRect.left - containerRect.left;
110
+ const top = elementRect.top - containerRect.top;
111
+ const right = elementRect.right - containerRect.left;
112
+ const bottom = elementRect.bottom - containerRect.top;
113
+ return [
114
+ { x: left, y: top },
115
+ { x: right, y: top },
116
+ { x: right, y: bottom },
117
+ { x: left, y: bottom },
118
+ ];
119
+ };
120
+ const getTransformedSvgViewportPoints = ({ viewport, ctm, containerRect, }) => {
121
+ const transformPoint = (x, y) => ({
122
+ x: ctm.a * x + ctm.c * y + ctm.e - containerRect.left,
123
+ y: ctm.b * x + ctm.d * y + ctm.f - containerRect.top,
124
+ });
125
+ const left = viewport.x;
126
+ const top = viewport.y;
127
+ const right = viewport.x + viewport.width;
128
+ const bottom = viewport.y + viewport.height;
129
+ return [
130
+ transformPoint(left, top),
131
+ transformPoint(right, top),
132
+ transformPoint(right, bottom),
133
+ transformPoint(left, bottom),
134
+ ];
135
+ };
136
+ exports.getTransformedSvgViewportPoints = getTransformedSvgViewportPoints;
137
+ const quadToPoints = (quad, containerRect) => {
138
+ // `getBoxQuads`/the ponyfill returns the quad in viewport coordinates.
139
+ // The overlay <svg> is unscaled (the canvas `scale()`/pan live on a sibling
140
+ // container, not the svg), so 1 user unit == 1 px and we only need to move
141
+ // the quad into the svg's local space by subtracting its viewport origin.
142
+ // We deliberately do not pass `relativeTo` to the ponyfill: when the target
143
+ // is not an ancestor of the element, the polyfill cannot resolve the
144
+ // coordinate space and leaves the quad in viewport coordinates.
145
+ return [
146
+ { x: quad.p1.x - containerRect.left, y: quad.p1.y - containerRect.top },
147
+ { x: quad.p2.x - containerRect.left, y: quad.p2.y - containerRect.top },
148
+ { x: quad.p3.x - containerRect.left, y: quad.p3.y - containerRect.top },
149
+ { x: quad.p4.x - containerRect.left, y: quad.p4.y - containerRect.top },
150
+ ];
151
+ };
152
+ const isSvgSvgElement = (element) => {
153
+ var _a;
154
+ const ownerSvgSvgElement = (_a = element.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.SVGSVGElement;
155
+ return ((typeof SVGSVGElement !== 'undefined' &&
156
+ element instanceof SVGSVGElement) ||
157
+ (ownerSvgSvgElement !== undefined && element instanceof ownerSvgSvgElement));
158
+ };
159
+ const getSvgSvgElementViewport = (element) => {
160
+ const viewBox = element.viewBox.baseVal;
161
+ if (viewBox.width > 0 && viewBox.height > 0) {
162
+ return {
163
+ x: viewBox.x,
164
+ y: viewBox.y,
165
+ width: viewBox.width,
166
+ height: viewBox.height,
167
+ };
168
+ }
169
+ return {
170
+ x: 0,
171
+ y: 0,
172
+ width: element.width.baseVal.value,
173
+ height: element.height.baseVal.value,
174
+ };
175
+ };
176
+ const getSvgSvgElementOutlinePoints = (element, containerRect) => {
177
+ const ctm = element.getScreenCTM();
178
+ const viewport = getSvgSvgElementViewport(element);
179
+ if (ctm === null || (viewport.width === 0 && viewport.height === 0)) {
180
+ return null;
181
+ }
182
+ return (0, exports.getTransformedSvgViewportPoints)({
183
+ viewport,
184
+ ctm,
185
+ containerRect,
186
+ });
187
+ };
188
+ const getElementOutlinePoints = (element, containerRect) => {
189
+ const elementRect = element.getBoundingClientRect();
190
+ if (elementRect.width === 0 && elementRect.height === 0) {
191
+ return null;
192
+ }
193
+ if (isSvgSvgElement(element)) {
194
+ return getSvgSvgElementOutlinePoints(element, containerRect);
195
+ }
196
+ const quads = (0, get_box_quads_ponyfill_1.getBoxQuadsPonyfill)(element, {
197
+ box: 'border',
198
+ });
199
+ const quad = quads === null || quads === void 0 ? void 0 : quads[0];
200
+ if (!quad) {
201
+ return rectToPoints(elementRect, containerRect);
202
+ }
203
+ return quadToPoints(quad, containerRect);
204
+ };
205
+ const getSelectedSequenceKeys = (selectedItems) => {
206
+ return new Set(selectedItems
207
+ .filter((item) => item.type === 'sequence')
208
+ .map((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo)));
209
+ };
210
+ exports.getSelectedSequenceKeys = getSelectedSequenceKeys;
211
+ const getSequenceKeysContainingSelection = (selectedItems) => {
212
+ return new Set(selectedItems
213
+ .filter((item) => item.type !== 'guide')
214
+ .map((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo)));
215
+ };
216
+ exports.getSequenceKeysContainingSelection = getSequenceKeysContainingSelection;
217
+ const getOutlineSelectionInteraction = ({ shiftKey, metaKey, ctrlKey, }) => ({
218
+ shiftKey,
219
+ toggleKey: metaKey || ctrlKey,
220
+ });
221
+ exports.getOutlineSelectionInteraction = getOutlineSelectionInteraction;
222
+ const getSelectedEffectFieldsBySequenceKey = (selectedItems) => {
223
+ var _a, _b;
224
+ const selectedEffects = new Map();
225
+ for (const item of selectedItems) {
226
+ if (item.type !== 'sequence-effect' &&
227
+ item.type !== 'sequence-effect-prop') {
228
+ continue;
229
+ }
230
+ const sequenceKey = (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo);
231
+ const effectsForSequence = (_a = selectedEffects.get(sequenceKey)) !== null && _a !== void 0 ? _a : new Map();
232
+ const selectedFields = (_b = effectsForSequence.get(item.i)) !== null && _b !== void 0 ? _b : {
233
+ allFields: false,
234
+ fieldKeys: new Set(),
235
+ };
236
+ if (item.type === 'sequence-effect') {
237
+ selectedFields.allFields = true;
238
+ }
239
+ else {
240
+ selectedFields.fieldKeys.add(item.key);
241
+ }
242
+ effectsForSequence.set(item.i, selectedFields);
243
+ selectedEffects.set(sequenceKey, effectsForSequence);
244
+ }
245
+ return selectedEffects;
246
+ };
247
+ exports.getSelectedEffectFieldsBySequenceKey = getSelectedEffectFieldsBySequenceKey;
248
+ const getSelectedTransformOriginInfo = (selectedItems) => {
249
+ if (selectedItems.length !== 1) {
250
+ return null;
251
+ }
252
+ const [selectedItem] = selectedItems;
253
+ if (selectedItem.type === 'sequence-prop' &&
254
+ selectedItem.key === selected_outline_types_1.transformOriginFieldKey) {
255
+ return {
256
+ sequenceKey: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(selectedItem.nodePathInfo),
257
+ displayFrame: null,
258
+ };
259
+ }
260
+ if (selectedItem.type !== 'keyframe') {
261
+ return null;
262
+ }
263
+ const field = (0, parse_keyframe_field_from_node_path_1.parseKeyframeFieldFromNodePath)(selectedItem.nodePathInfo.auxiliaryKeys);
264
+ if ((field === null || field === void 0 ? void 0 : field.type) !== 'sequence' ||
265
+ field.fieldKey !== selected_outline_types_1.transformOriginFieldKey) {
266
+ return null;
267
+ }
268
+ return {
269
+ sequenceKey: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(selectedItem.nodePathInfo),
270
+ displayFrame: selectedItem.frame,
271
+ };
272
+ };
273
+ exports.getSelectedTransformOriginInfo = getSelectedTransformOriginInfo;
274
+ const getSequencesWithSelectableOutlines = ({ sequences, overrideIdsToNodePaths, }) => {
275
+ return (0, calculate_timeline_1.calculateTimeline)({
276
+ sequences: [...sequences],
277
+ overrideIdsToNodePaths,
278
+ })
279
+ .filter((track) => {
280
+ if (track.nodePathInfo === null) {
281
+ return false;
282
+ }
283
+ return (track.sequence.showInTimeline &&
284
+ track.nodePathInfo.auxiliaryKeys.length === 0);
285
+ })
286
+ .filter((track) => track.sequence.refForOutline !== null)
287
+ .sort((a, b) => a.depth - b.depth)
288
+ .map((track) => {
289
+ if (track.nodePathInfo === null) {
290
+ throw new Error('Expected selected outline to have a node path');
291
+ }
292
+ return {
293
+ depth: track.depth,
294
+ keyframeDisplayOffset: track.keyframeDisplayOffset,
295
+ key: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(track.nodePathInfo),
296
+ nodePathInfo: track.nodePathInfo,
297
+ sequence: track.sequence,
298
+ };
299
+ });
300
+ };
301
+ exports.getSequencesWithSelectableOutlines = getSequencesWithSelectableOutlines;
302
+ const measureOutlines = (container, targets) => {
303
+ const containerRect = container.getBoundingClientRect();
304
+ const outlines = [];
305
+ for (const target of targets) {
306
+ const element = target.ref.current;
307
+ if (element === null) {
308
+ continue;
309
+ }
310
+ const points = getElementOutlinePoints(element, containerRect);
311
+ if (points === null) {
312
+ continue;
313
+ }
314
+ outlines.push({
315
+ key: target.key,
316
+ dimensions: element instanceof HTMLElement
317
+ ? {
318
+ width: element.offsetWidth,
319
+ height: element.offsetHeight,
320
+ }
321
+ : element instanceof SVGSVGElement
322
+ ? {
323
+ width: element.width.baseVal.value,
324
+ height: element.height.baseVal.value,
325
+ }
326
+ : null,
327
+ points,
328
+ });
329
+ }
330
+ return outlines;
331
+ };
332
+ exports.measureOutlines = measureOutlines;
333
+ const outlinesAreEqual = (a, b) => {
334
+ var _a, _b, _c, _d;
335
+ if (a.length !== b.length) {
336
+ return false;
337
+ }
338
+ for (let i = 0; i < a.length; i++) {
339
+ if (a[i].key !== b[i].key) {
340
+ return false;
341
+ }
342
+ 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) ||
343
+ ((_c = a[i].dimensions) === null || _c === void 0 ? void 0 : _c.height) !== ((_d = b[i].dimensions) === null || _d === void 0 ? void 0 : _d.height)) {
344
+ return false;
345
+ }
346
+ for (let j = 0; j < a[i].points.length; j++) {
347
+ if (Math.abs(a[i].points[j].x - b[i].points[j].x) > 0.01 ||
348
+ Math.abs(a[i].points[j].y - b[i].points[j].y) > 0.01) {
349
+ return false;
350
+ }
351
+ }
352
+ }
353
+ return true;
354
+ };
355
+ exports.outlinesAreEqual = outlinesAreEqual;
@@ -0,0 +1,121 @@
1
+ import type { CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusStatic, SequenceFieldSchema, SequencePropsSubscriptionKey, SequenceSchema, TSequence } from 'remotion';
2
+ import type { SequenceNodePathInfo } from '../helpers/get-timeline-sequence-sort-key';
3
+ import type { ComboboxValue } from './NewComposition/ComboBox';
4
+ import type { SelectedOutlineUvHandle } from './selected-outline-uv';
5
+ import type { TimelineSelection } from './Timeline/TimelineSelection';
6
+ export type SelectedOutlineContextMenuOpenResult = false | void | readonly ComboboxValue[];
7
+ export type SelectedOutlineContextMenuOpenHandler = () => SelectedOutlineContextMenuOpenResult | Promise<SelectedOutlineContextMenuOpenResult>;
8
+ export type SelectedOutlineTarget = {
9
+ readonly key: string;
10
+ readonly containsSelection: boolean;
11
+ readonly effectDrop: SelectedOutlineEffectDropTarget | null;
12
+ readonly nodePathInfo: SequenceNodePathInfo;
13
+ readonly ref: React.RefObject<Element | null>;
14
+ readonly selected: boolean;
15
+ readonly selection: TimelineSelection;
16
+ readonly sequence: TSequence;
17
+ readonly drag: SelectedOutlineDragTarget | null;
18
+ readonly scaleDrag: SelectedOutlineScaleDragTarget | null;
19
+ readonly rotationDrag: SelectedOutlineRotationDragTarget | null;
20
+ readonly transformOriginDrag: SelectedOutlineTransformOriginDragTarget | null;
21
+ readonly uvHandles: readonly SelectedOutlineUvHandle[];
22
+ };
23
+ export type SelectedOutlineEffectDropTarget = {
24
+ readonly clientId: string;
25
+ readonly fileName: string;
26
+ readonly nodePath: SequencePropsSubscriptionKey;
27
+ };
28
+ export type SelectedOutlineDragTarget = {
29
+ readonly propStatus: CanUpdateSequencePropStatusStatic | CanUpdateSequencePropStatusKeyframed;
30
+ readonly clientId: string;
31
+ readonly fieldDefault: string | undefined;
32
+ readonly keyframeDisplayOffset: number;
33
+ readonly nodePath: SequencePropsSubscriptionKey;
34
+ readonly schema: SequenceSchema;
35
+ };
36
+ export type SelectedOutlineTransformOriginDragTarget = {
37
+ readonly clientId: string;
38
+ readonly keyframeDisplayOffset: number;
39
+ readonly nodePath: SequencePropsSubscriptionKey;
40
+ readonly originDefault: string | undefined;
41
+ readonly originPropStatus: CanUpdateSequencePropStatusStatic | CanUpdateSequencePropStatusKeyframed;
42
+ readonly originValue: string;
43
+ readonly rotateValue: string;
44
+ readonly scaleValue: number | string;
45
+ readonly schema: SequenceSchema;
46
+ readonly sourceFrame: number;
47
+ readonly translateDefault: string | undefined;
48
+ readonly translatePropStatus: CanUpdateSequencePropStatusStatic | CanUpdateSequencePropStatusKeyframed;
49
+ readonly translateValue: string;
50
+ };
51
+ export type ScaleFieldSchema = Extract<SequenceFieldSchema, {
52
+ type: 'scale';
53
+ }>;
54
+ export type RotationFieldSchema = Extract<SequenceFieldSchema, {
55
+ type: 'rotation-css';
56
+ }>;
57
+ export type SelectedOutlineScaleDragTarget = {
58
+ readonly propStatus: CanUpdateSequencePropStatusStatic | CanUpdateSequencePropStatusKeyframed;
59
+ readonly clientId: string;
60
+ readonly fieldDefault: number | string | undefined;
61
+ readonly fieldSchema: ScaleFieldSchema;
62
+ readonly keyframeDisplayOffset: number;
63
+ readonly linked: boolean;
64
+ readonly nodePath: SequencePropsSubscriptionKey;
65
+ readonly schema: SequenceSchema;
66
+ };
67
+ export type SelectedOutlineRotationDragTarget = {
68
+ readonly propStatus: CanUpdateSequencePropStatusStatic | CanUpdateSequencePropStatusKeyframed;
69
+ readonly clientId: string;
70
+ readonly fieldDefault: string | undefined;
71
+ readonly fieldSchema: RotationFieldSchema;
72
+ readonly keyframeDisplayOffset: number;
73
+ readonly nodePath: SequencePropsSubscriptionKey;
74
+ readonly schema: SequenceSchema;
75
+ readonly transformOriginValue: string;
76
+ };
77
+ export type SelectedOutlineDragState = {
78
+ readonly defaultValue: string | null;
79
+ readonly key: string;
80
+ readonly sourceFrame: number;
81
+ readonly startX: number;
82
+ readonly startY: number;
83
+ readonly target: SelectedOutlineDragTarget;
84
+ };
85
+ export type SelectedOutlineScaleDragState = {
86
+ readonly defaultValue: string | null;
87
+ readonly key: string;
88
+ readonly sourceFrame: number;
89
+ readonly startX: number;
90
+ readonly startY: number;
91
+ readonly startZ: number;
92
+ readonly target: SelectedOutlineScaleDragTarget;
93
+ };
94
+ export type SelectedOutlineRotationDragState = {
95
+ readonly defaultValue: string | null;
96
+ readonly key: string;
97
+ readonly sourceFrame: number;
98
+ readonly startDegrees: number;
99
+ readonly target: SelectedOutlineRotationDragTarget;
100
+ };
101
+ export type SequenceWithSelectedOutline = {
102
+ readonly depth: number;
103
+ readonly keyframeDisplayOffset: number;
104
+ readonly key: string;
105
+ readonly nodePathInfo: SequenceNodePathInfo;
106
+ readonly sequence: TSequence;
107
+ };
108
+ export declare const translateFieldKey = "style.translate";
109
+ export declare const scaleFieldKey = "style.scale";
110
+ export declare const rotateFieldKey = "style.rotate";
111
+ export declare const transformOriginFieldKey = "style.transformOrigin";
112
+ export declare const selectedOutlineDragThresholdPx = 4;
113
+ export declare const outlineContainer: React.CSSProperties;
114
+ export declare const emptyContextMenuValues: readonly ComboboxValue[];
115
+ export type SelectedOutlineKeyboardNudgeSession = {
116
+ readonly dragStates: readonly SelectedOutlineDragState[];
117
+ readonly clientId: string;
118
+ deltaX: number;
119
+ deltaY: number;
120
+ lastValues: ReadonlyMap<string, string>;
121
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyContextMenuValues = exports.outlineContainer = exports.selectedOutlineDragThresholdPx = exports.transformOriginFieldKey = exports.rotateFieldKey = exports.scaleFieldKey = exports.translateFieldKey = void 0;
4
+ exports.translateFieldKey = 'style.translate';
5
+ exports.scaleFieldKey = 'style.scale';
6
+ exports.rotateFieldKey = 'style.rotate';
7
+ exports.transformOriginFieldKey = 'style.transformOrigin';
8
+ exports.selectedOutlineDragThresholdPx = 4;
9
+ exports.outlineContainer = {
10
+ position: 'absolute',
11
+ inset: 0,
12
+ pointerEvents: 'none',
13
+ overflow: 'visible',
14
+ };
15
+ exports.emptyContextMenuValues = [];
@@ -34,6 +34,7 @@ export declare const getUvHandleConnectionLines: ({ handles, points, }: {
34
34
  }) => UvHandleConnectionLine[];
35
35
  export declare const getUvCoordinateForPoint: (points: readonly [OutlinePoint, OutlinePoint, OutlinePoint, OutlinePoint], point: OutlinePoint) => UvCoordinate;
36
36
  export declare function constrainUv(value: UvCoordinate, schema: UvCoordinateFieldSchema): UvCoordinate;
37
+ export declare function roundUvCoordinate(value: UvCoordinate, schema: UvCoordinateFieldSchema): UvCoordinate;
37
38
  export declare const getSelectedUvHandles: ({ propStatuses, clientId, getEffectDragOverrides, nodePath, selectedEffects, sequence, sourceFrame, }: {
38
39
  readonly propStatuses: PropStatuses;
39
40
  readonly clientId: string | null;
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSelectedUvHandles = exports.getUvCoordinateForPoint = exports.getUvHandleConnectionLines = exports.getUvHandlePosition = exports.tuplesEqual = void 0;
4
4
  exports.constrainUv = constrainUv;
5
+ exports.roundUvCoordinate = roundUvCoordinate;
5
6
  const remotion_1 = require("remotion");
6
7
  const selected_outline_geometry_1 = require("./selected-outline-geometry");
8
+ const timeline_field_utils_1 = require("./Timeline/timeline-field-utils");
7
9
  const parseUvCoordinate = (value) => {
8
10
  if (Array.isArray(value) &&
9
11
  value.length === 2 &&
@@ -166,6 +168,16 @@ function constrainUv(value, schema) {
166
168
  const max = (_b = schema.max) !== null && _b !== void 0 ? _b : Infinity;
167
169
  return [(0, selected_outline_geometry_1.clamp)(value[0], min, max), (0, selected_outline_geometry_1.clamp)(value[1], min, max)];
168
170
  }
171
+ function roundUvCoordinate(value, schema) {
172
+ const decimalPlaces = (0, timeline_field_utils_1.getTimelineDisplayDecimalPlaces)({
173
+ defaultDecimalPlaces: 3,
174
+ step: schema.step,
175
+ });
176
+ return [
177
+ (0, timeline_field_utils_1.roundToDecimalPlaces)(value[0], decimalPlaces),
178
+ (0, timeline_field_utils_1.roundToDecimalPlaces)(value[1], decimalPlaces),
179
+ ];
180
+ }
169
181
  const getSelectedUvHandles = ({ propStatuses, clientId, getEffectDragOverrides, nodePath, selectedEffects, sequence, sourceFrame, }) => {
170
182
  if (clientId === null || selectedEffects === undefined) {
171
183
  return [];