@remotion/studio 4.0.469 → 4.0.471
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.
- package/dist/Studio.js +1 -1
- package/dist/api/save-render-output.js +3 -12
- package/dist/components/AudioWaveform.js +19 -2
- package/dist/components/ContextMenu.d.ts +7 -2
- package/dist/components/ContextMenu.js +53 -9
- package/dist/components/EditorContent.js +5 -4
- package/dist/components/Menu/MenuItem.d.ts +1 -1
- package/dist/components/MenuBuildIndicator.js +0 -1
- package/dist/components/NewComposition/InputDragger.js +1 -0
- package/dist/components/Preview.js +6 -2
- package/dist/components/SelectedOutlineOverlay.d.ts +49 -0
- package/dist/components/SelectedOutlineOverlay.js +710 -0
- package/dist/components/Timeline/Timeline.js +102 -13
- package/dist/components/Timeline/TimelineDeleteKeybindings.d.ts +2 -0
- package/dist/components/Timeline/TimelineDeleteKeybindings.js +101 -0
- package/dist/components/Timeline/TimelineDragHandler.js +20 -244
- package/dist/components/Timeline/{TimelineEffectGroupRow.d.ts → TimelineEffectItem.d.ts} +1 -1
- package/dist/components/Timeline/TimelineEffectItem.js +323 -0
- package/dist/components/Timeline/{TimelineEffectFieldRow.d.ts → TimelineEffectPropItem.d.ts} +2 -1
- package/dist/components/Timeline/{TimelineEffectFieldRow.js → TimelineEffectPropItem.js} +97 -8
- package/dist/components/Timeline/TimelineExpandArrowButton.js +5 -1
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +37 -5
- package/dist/components/Timeline/TimelineExpandedRow.d.ts +1 -0
- package/dist/components/Timeline/TimelineExpandedRow.js +9 -7
- package/dist/components/Timeline/TimelineExpandedSection.d.ts +1 -0
- package/dist/components/Timeline/TimelineExpandedSection.js +2 -2
- package/dist/components/Timeline/TimelineInOutDragHandler.d.ts +2 -0
- package/dist/components/Timeline/TimelineInOutDragHandler.js +324 -0
- package/dist/components/Timeline/TimelineInOutPointer.js +3 -1
- package/dist/components/Timeline/TimelineInOutPointerHandle.d.ts +1 -0
- package/dist/components/Timeline/TimelineInOutPointerHandle.js +5 -4
- package/dist/components/Timeline/TimelineKeyframeControls.d.ts +17 -0
- package/dist/components/Timeline/TimelineKeyframeControls.js +222 -0
- package/dist/components/Timeline/TimelineKeyframeDiamond.js +7 -6
- package/dist/components/Timeline/TimelineKeyframedValue.d.ts +8 -0
- package/dist/components/Timeline/TimelineKeyframedValue.js +36 -0
- package/dist/components/Timeline/TimelineList.js +3 -15
- package/dist/components/Timeline/TimelineRowChrome.d.ts +6 -1
- package/dist/components/Timeline/TimelineRowChrome.js +25 -7
- package/dist/components/Timeline/TimelineSelection.d.ts +53 -9
- package/dist/components/Timeline/TimelineSelection.js +305 -48
- package/dist/components/Timeline/TimelineSequence.d.ts +2 -0
- package/dist/components/Timeline/TimelineSequence.js +18 -6
- package/dist/components/Timeline/TimelineSequenceFrame.js +1 -0
- package/dist/components/Timeline/{TimelineListItem.d.ts → TimelineSequenceItem.d.ts} +2 -1
- package/dist/components/Timeline/{TimelineListItem.js → TimelineSequenceItem.js} +140 -34
- package/dist/components/Timeline/{TimelineFieldRow.d.ts → TimelineSequencePropItem.d.ts} +2 -1
- package/dist/components/Timeline/{TimelineFieldRow.js → TimelineSequencePropItem.js} +81 -5
- package/dist/components/Timeline/TimelineTimeIndicators.js +0 -1
- package/dist/components/Timeline/TimelineTrack.js +3 -1
- package/dist/components/Timeline/TimelineTranslateField.js +14 -22
- package/dist/components/Timeline/call-add-keyframe.d.ts +23 -0
- package/dist/components/Timeline/call-add-keyframe.js +54 -0
- package/dist/components/Timeline/call-delete-keyframe.d.ts +37 -0
- package/dist/components/Timeline/call-delete-keyframe.js +122 -0
- package/dist/components/Timeline/delete-selected-keyframe.d.ts +21 -0
- package/dist/components/Timeline/delete-selected-keyframe.js +92 -0
- package/dist/components/Timeline/delete-selected-timeline-item.d.ts +17 -0
- package/dist/components/Timeline/delete-selected-timeline-item.js +178 -0
- package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +13 -0
- package/dist/components/Timeline/duplicate-selected-timeline-item.js +66 -0
- package/dist/components/Timeline/find-track-for-node-path-info.d.ts +7 -0
- package/dist/components/Timeline/find-track-for-node-path-info.js +13 -0
- package/dist/components/Timeline/get-keyframe-navigation.d.ts +9 -0
- package/dist/components/Timeline/get-keyframe-navigation.js +26 -0
- package/dist/components/Timeline/parse-keyframe-field-from-node-path.d.ts +8 -0
- package/dist/components/Timeline/parse-keyframe-field-from-node-path.js +26 -0
- package/dist/components/Timeline/reset-selected-timeline-props.d.ts +38 -0
- package/dist/components/Timeline/reset-selected-timeline-props.js +143 -0
- package/dist/components/Timeline/save-sequence-prop.d.ts +14 -2
- package/dist/components/Timeline/save-sequence-prop.js +42 -7
- package/dist/components/Timeline/sequence-props-subscription-store.d.ts +3 -2
- package/dist/components/Timeline/sequence-props-subscription-store.js +2 -1
- package/dist/components/Timeline/timeline-row-layout.d.ts +1 -0
- package/dist/components/Timeline/timeline-row-layout.js +2 -1
- package/dist/components/Timeline/timeline-scroll-logic.js +3 -3
- package/dist/components/Timeline/timeline-translate-utils.d.ts +2 -0
- package/dist/components/Timeline/timeline-translate-utils.js +20 -0
- package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +10 -3
- package/dist/components/Timeline/use-sequence-props-subscription.js +2 -1
- package/dist/components/composition-menu-items.js +32 -1
- package/dist/error-overlay/remotion-overlay/OpenInEditor.js +0 -1
- package/dist/esm/{chunk-1mp51e0w.js → chunk-z0z9d4r0.js} +10422 -5958
- package/dist/esm/internals.mjs +10422 -5958
- package/dist/esm/previewEntry.mjs +10419 -5953
- package/dist/esm/renderEntry.mjs +3 -1
- package/dist/helpers/format-file-location.d.ts +9 -0
- package/dist/helpers/format-file-location.js +27 -0
- package/dist/helpers/get-box-quads-polyfill-internals.d.ts +82 -0
- package/dist/helpers/get-box-quads-polyfill-internals.js +2395 -0
- package/dist/helpers/get-box-quads-ponyfill.d.ts +10 -0
- package/dist/helpers/get-box-quads-ponyfill.js +23 -0
- package/dist/helpers/get-left-of-timeline-slider.js +1 -1
- package/dist/helpers/get-timeline-sequence-layout.js +10 -11
- package/dist/helpers/open-in-editor.d.ts +20 -2
- package/dist/helpers/open-in-editor.js +53 -30
- package/dist/helpers/use-menu-structure.js +8 -17
- package/dist/renderEntry.js +2 -2
- package/dist/state/z-index.js +5 -2
- package/package.json +10 -10
- package/dist/components/Timeline/TimelineEffectGroupRow.js +0 -153
|
@@ -0,0 +1,710 @@
|
|
|
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.SelectedOutlineOverlay = exports.getSelectedOutlineDragChanges = exports.getSelectedOutlineDragValues = exports.getSelectedEffectFieldsBySequenceKey = exports.getUvCoordinateForPoint = exports.getUvHandlePosition = 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 calculate_timeline_1 = require("../helpers/calculate-timeline");
|
|
41
|
+
const client_id_1 = require("../helpers/client-id");
|
|
42
|
+
const colors_1 = require("../helpers/colors");
|
|
43
|
+
const get_box_quads_ponyfill_1 = require("../helpers/get-box-quads-ponyfill");
|
|
44
|
+
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
45
|
+
const save_effect_prop_1 = require("./Timeline/save-effect-prop");
|
|
46
|
+
const save_sequence_prop_1 = require("./Timeline/save-sequence-prop");
|
|
47
|
+
const timeline_field_utils_1 = require("./Timeline/timeline-field-utils");
|
|
48
|
+
const timeline_translate_utils_1 = require("./Timeline/timeline-translate-utils");
|
|
49
|
+
const TimelineSelection_1 = require("./Timeline/TimelineSelection");
|
|
50
|
+
const translateFieldKey = 'style.translate';
|
|
51
|
+
const outlineContainer = {
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
inset: 0,
|
|
54
|
+
pointerEvents: 'none',
|
|
55
|
+
overflow: 'visible',
|
|
56
|
+
};
|
|
57
|
+
const pointToString = (point) => `${point.x},${point.y}`;
|
|
58
|
+
const parseUvCoordinate = (value) => {
|
|
59
|
+
if (Array.isArray(value) &&
|
|
60
|
+
value.length === 2 &&
|
|
61
|
+
value.every((item) => typeof item === 'number' && Number.isFinite(item))) {
|
|
62
|
+
return [value[0], value[1]];
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
const tuplesEqual = (left, right) => {
|
|
67
|
+
if (!Array.isArray(left) || left.length !== 2) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return left[0] === right[0] && left[1] === right[1];
|
|
71
|
+
};
|
|
72
|
+
const mix = (from, to, progress) => {
|
|
73
|
+
return from + (to - from) * progress;
|
|
74
|
+
};
|
|
75
|
+
const mixPoint = (from, to, progress) => {
|
|
76
|
+
return {
|
|
77
|
+
x: mix(from.x, to.x, progress),
|
|
78
|
+
y: mix(from.y, to.y, progress),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const getBilinearUvHandlePosition = (points, uv) => {
|
|
82
|
+
const [tl, tr, br, bl] = points;
|
|
83
|
+
const top = mixPoint(tl, tr, uv[0]);
|
|
84
|
+
const bottom = mixPoint(bl, br, uv[0]);
|
|
85
|
+
return mixPoint(top, bottom, uv[1]);
|
|
86
|
+
};
|
|
87
|
+
const projectiveEpsilon = 0.000001;
|
|
88
|
+
const getProjectiveTransform = (points) => {
|
|
89
|
+
const [tl, tr, br, bl] = points;
|
|
90
|
+
const dx1 = tr.x - br.x;
|
|
91
|
+
const dx2 = bl.x - br.x;
|
|
92
|
+
const dx3 = tl.x - tr.x + br.x - bl.x;
|
|
93
|
+
const dy1 = tr.y - br.y;
|
|
94
|
+
const dy2 = bl.y - br.y;
|
|
95
|
+
const dy3 = tl.y - tr.y + br.y - bl.y;
|
|
96
|
+
let g = 0;
|
|
97
|
+
let h = 0;
|
|
98
|
+
if (Math.abs(dx3) > projectiveEpsilon || Math.abs(dy3) > projectiveEpsilon) {
|
|
99
|
+
const determinant = dx1 * dy2 - dx2 * dy1;
|
|
100
|
+
if (Math.abs(determinant) < projectiveEpsilon) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
g = (dx3 * dy2 - dx2 * dy3) / determinant;
|
|
104
|
+
h = (dx1 * dy3 - dx3 * dy1) / determinant;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
a: tr.x - tl.x + g * tr.x,
|
|
108
|
+
b: bl.x - tl.x + h * bl.x,
|
|
109
|
+
c: tl.x,
|
|
110
|
+
d: tr.y - tl.y + g * tr.y,
|
|
111
|
+
e: bl.y - tl.y + h * bl.y,
|
|
112
|
+
f: tl.y,
|
|
113
|
+
g,
|
|
114
|
+
h,
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const applyProjectiveTransform = (transform, uv) => {
|
|
118
|
+
const denominator = transform.g * uv[0] + transform.h * uv[1] + 1;
|
|
119
|
+
return {
|
|
120
|
+
x: (transform.a * uv[0] + transform.b * uv[1] + transform.c) / denominator,
|
|
121
|
+
y: (transform.d * uv[0] + transform.e * uv[1] + transform.f) / denominator,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
const getUvHandlePosition = (points, uv) => {
|
|
125
|
+
const transform = getProjectiveTransform(points);
|
|
126
|
+
return transform === null
|
|
127
|
+
? getBilinearUvHandlePosition(points, uv)
|
|
128
|
+
: applyProjectiveTransform(transform, uv);
|
|
129
|
+
};
|
|
130
|
+
exports.getUvHandlePosition = getUvHandlePosition;
|
|
131
|
+
const vectorBetween = (from, to) => {
|
|
132
|
+
return { x: to.x - from.x, y: to.y - from.y };
|
|
133
|
+
};
|
|
134
|
+
const getBilinearUvCoordinateForPoint = (points, point) => {
|
|
135
|
+
const [tl, tr, br, bl] = points;
|
|
136
|
+
let u = 0.5;
|
|
137
|
+
let v = 0.5;
|
|
138
|
+
for (let i = 0; i < 8; i++) {
|
|
139
|
+
const current = getBilinearUvHandlePosition(points, [u, v]);
|
|
140
|
+
const errorX = current.x - point.x;
|
|
141
|
+
const errorY = current.y - point.y;
|
|
142
|
+
if (Math.abs(errorX) + Math.abs(errorY) < 0.001) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
const du = {
|
|
146
|
+
x: mix(tr.x - tl.x, br.x - bl.x, v),
|
|
147
|
+
y: mix(tr.y - tl.y, br.y - bl.y, v),
|
|
148
|
+
};
|
|
149
|
+
const dv = vectorBetween(mixPoint(tl, tr, u), mixPoint(bl, br, u));
|
|
150
|
+
const determinant = du.x * dv.y - du.y * dv.x;
|
|
151
|
+
if (Math.abs(determinant) < 0.000001) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
u -= (errorX * dv.y - errorY * dv.x) / determinant;
|
|
155
|
+
v -= (du.x * errorY - du.y * errorX) / determinant;
|
|
156
|
+
}
|
|
157
|
+
return [u, v];
|
|
158
|
+
};
|
|
159
|
+
const getUvCoordinateForPoint = (points, point) => {
|
|
160
|
+
const transform = getProjectiveTransform(points);
|
|
161
|
+
if (transform === null) {
|
|
162
|
+
return getBilinearUvCoordinateForPoint(points, point);
|
|
163
|
+
}
|
|
164
|
+
const determinant = transform.a * (transform.e - transform.f * transform.h) -
|
|
165
|
+
transform.b * (transform.d - transform.f * transform.g) +
|
|
166
|
+
transform.c * (transform.d * transform.h - transform.e * transform.g);
|
|
167
|
+
if (Math.abs(determinant) < projectiveEpsilon) {
|
|
168
|
+
return getBilinearUvCoordinateForPoint(points, point);
|
|
169
|
+
}
|
|
170
|
+
const inverseA = transform.e - transform.f * transform.h;
|
|
171
|
+
const inverseB = transform.c * transform.h - transform.b;
|
|
172
|
+
const inverseC = transform.b * transform.f - transform.c * transform.e;
|
|
173
|
+
const inverseD = transform.f * transform.g - transform.d;
|
|
174
|
+
const inverseE = transform.a - transform.c * transform.g;
|
|
175
|
+
const inverseF = transform.c * transform.d - transform.a * transform.f;
|
|
176
|
+
const inverseG = transform.d * transform.h - transform.e * transform.g;
|
|
177
|
+
const inverseH = transform.b * transform.g - transform.a * transform.h;
|
|
178
|
+
const inverseI = transform.a * transform.e - transform.b * transform.d;
|
|
179
|
+
const denominator = inverseG * point.x + inverseH * point.y + inverseI;
|
|
180
|
+
if (Math.abs(denominator) < projectiveEpsilon) {
|
|
181
|
+
return getBilinearUvCoordinateForPoint(points, point);
|
|
182
|
+
}
|
|
183
|
+
return [
|
|
184
|
+
(inverseA * point.x + inverseB * point.y + inverseC) / denominator,
|
|
185
|
+
(inverseD * point.x + inverseE * point.y + inverseF) / denominator,
|
|
186
|
+
];
|
|
187
|
+
};
|
|
188
|
+
exports.getUvCoordinateForPoint = getUvCoordinateForPoint;
|
|
189
|
+
const clamp = (value, min, max) => {
|
|
190
|
+
return Math.min(max, Math.max(min, value));
|
|
191
|
+
};
|
|
192
|
+
const roundToStep = (value, step) => {
|
|
193
|
+
if (step === undefined || !Number.isFinite(step) || step <= 0) {
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
const decimals = (0, timeline_field_utils_1.getDecimalPlaces)(step);
|
|
197
|
+
return Number((Math.round(value / step) * step).toFixed(decimals));
|
|
198
|
+
};
|
|
199
|
+
const constrainUv = (value, schema) => {
|
|
200
|
+
var _a, _b;
|
|
201
|
+
const min = (_a = schema.min) !== null && _a !== void 0 ? _a : -Infinity;
|
|
202
|
+
const max = (_b = schema.max) !== null && _b !== void 0 ? _b : Infinity;
|
|
203
|
+
return [
|
|
204
|
+
clamp(roundToStep(value[0], schema.step), min, max),
|
|
205
|
+
clamp(roundToStep(value[1], schema.step), min, max),
|
|
206
|
+
];
|
|
207
|
+
};
|
|
208
|
+
const rectToPoints = (elementRect, containerRect) => {
|
|
209
|
+
const left = elementRect.left - containerRect.left;
|
|
210
|
+
const top = elementRect.top - containerRect.top;
|
|
211
|
+
const right = elementRect.right - containerRect.left;
|
|
212
|
+
const bottom = elementRect.bottom - containerRect.top;
|
|
213
|
+
return [
|
|
214
|
+
{ x: left, y: top },
|
|
215
|
+
{ x: right, y: top },
|
|
216
|
+
{ x: right, y: bottom },
|
|
217
|
+
{ x: left, y: bottom },
|
|
218
|
+
];
|
|
219
|
+
};
|
|
220
|
+
const quadToPoints = (quad, containerRect) => {
|
|
221
|
+
// `getBoxQuads`/the ponyfill returns the quad in viewport coordinates.
|
|
222
|
+
// The overlay <svg> is unscaled (the canvas `scale()`/pan live on a sibling
|
|
223
|
+
// container, not the svg), so 1 user unit == 1 px and we only need to move
|
|
224
|
+
// the quad into the svg's local space by subtracting its viewport origin.
|
|
225
|
+
// We deliberately do not pass `relativeTo` to the ponyfill: when the target
|
|
226
|
+
// is not an ancestor of the element, the polyfill cannot resolve the
|
|
227
|
+
// coordinate space and leaves the quad in viewport coordinates.
|
|
228
|
+
return [
|
|
229
|
+
{ x: quad.p1.x - containerRect.left, y: quad.p1.y - containerRect.top },
|
|
230
|
+
{ x: quad.p2.x - containerRect.left, y: quad.p2.y - containerRect.top },
|
|
231
|
+
{ x: quad.p3.x - containerRect.left, y: quad.p3.y - containerRect.top },
|
|
232
|
+
{ x: quad.p4.x - containerRect.left, y: quad.p4.y - containerRect.top },
|
|
233
|
+
];
|
|
234
|
+
};
|
|
235
|
+
const getElementOutlinePoints = (element, containerRect) => {
|
|
236
|
+
const elementRect = element.getBoundingClientRect();
|
|
237
|
+
if (elementRect.width === 0 && elementRect.height === 0) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const quads = (0, get_box_quads_ponyfill_1.getBoxQuadsPonyfill)(element, {
|
|
241
|
+
box: 'border',
|
|
242
|
+
});
|
|
243
|
+
const quad = quads === null || quads === void 0 ? void 0 : quads[0];
|
|
244
|
+
if (!quad) {
|
|
245
|
+
return rectToPoints(elementRect, containerRect);
|
|
246
|
+
}
|
|
247
|
+
return quadToPoints(quad, containerRect);
|
|
248
|
+
};
|
|
249
|
+
const getSelectedSequenceKeys = (selectedItems) => {
|
|
250
|
+
return new Set(selectedItems.map((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo)));
|
|
251
|
+
};
|
|
252
|
+
const getSelectedEffectFieldsBySequenceKey = (selectedItems) => {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
const selectedEffects = new Map();
|
|
255
|
+
for (const item of selectedItems) {
|
|
256
|
+
if (item.type !== 'sequence-effect' &&
|
|
257
|
+
item.type !== 'sequence-effect-prop') {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const sequenceKey = (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo);
|
|
261
|
+
const effectsForSequence = (_a = selectedEffects.get(sequenceKey)) !== null && _a !== void 0 ? _a : new Map();
|
|
262
|
+
const selectedFields = (_b = effectsForSequence.get(item.i)) !== null && _b !== void 0 ? _b : {
|
|
263
|
+
allFields: false,
|
|
264
|
+
fieldKeys: new Set(),
|
|
265
|
+
};
|
|
266
|
+
selectedFields.allFields = true;
|
|
267
|
+
effectsForSequence.set(item.i, selectedFields);
|
|
268
|
+
selectedEffects.set(sequenceKey, effectsForSequence);
|
|
269
|
+
}
|
|
270
|
+
return selectedEffects;
|
|
271
|
+
};
|
|
272
|
+
exports.getSelectedEffectFieldsBySequenceKey = getSelectedEffectFieldsBySequenceKey;
|
|
273
|
+
const getSequencesWithSelectedOutlines = ({ selectedItems, sequences, overrideIdsToNodePaths, }) => {
|
|
274
|
+
const selectedSequenceKeys = getSelectedSequenceKeys(selectedItems);
|
|
275
|
+
if (selectedSequenceKeys.size === 0) {
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
return (0, calculate_timeline_1.calculateTimeline)({
|
|
279
|
+
sequences: [...sequences],
|
|
280
|
+
overrideIdsToNodePaths,
|
|
281
|
+
})
|
|
282
|
+
.filter((track) => {
|
|
283
|
+
if (track.nodePathInfo === null) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
return selectedSequenceKeys.has((0, TimelineSelection_1.getTimelineSequenceSelectionKey)(track.nodePathInfo));
|
|
287
|
+
})
|
|
288
|
+
.filter((track) => track.sequence.refForOutline !== null)
|
|
289
|
+
.map((track) => {
|
|
290
|
+
if (track.nodePathInfo === null) {
|
|
291
|
+
throw new Error('Expected selected outline to have a node path');
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
key: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(track.nodePathInfo),
|
|
295
|
+
nodePathInfo: track.nodePathInfo,
|
|
296
|
+
sequence: track.sequence,
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
const getSelectedUvHandles = ({ codeValues, clientId, getEffectDragOverrides, nodePath, selectedEffects, sequence, }) => {
|
|
301
|
+
if (clientId === null || selectedEffects === undefined) {
|
|
302
|
+
return [];
|
|
303
|
+
}
|
|
304
|
+
const handles = [];
|
|
305
|
+
for (const [effectIndex, selectedFields] of selectedEffects) {
|
|
306
|
+
const effect = sequence.effects[effectIndex];
|
|
307
|
+
if (!effect) {
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const effectStatus = remotion_1.Internals.getEffectCodeValuesCtx({
|
|
311
|
+
codeValues,
|
|
312
|
+
nodePath,
|
|
313
|
+
effectIndex,
|
|
314
|
+
});
|
|
315
|
+
if (effectStatus.type !== 'can-update-effect') {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
const dragOverrides = getEffectDragOverrides(nodePath, effectIndex);
|
|
319
|
+
const activeSchema = remotion_1.Internals.flattenActiveSchema(effect.schema, (key) => {
|
|
320
|
+
const dragOverride = dragOverrides[key];
|
|
321
|
+
if (dragOverride !== undefined) {
|
|
322
|
+
return dragOverride;
|
|
323
|
+
}
|
|
324
|
+
const propStatus = effectStatus.props[key];
|
|
325
|
+
if (!(propStatus === null || propStatus === void 0 ? void 0 : propStatus.canUpdate)) {
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
return propStatus.codeValue;
|
|
329
|
+
});
|
|
330
|
+
for (const [fieldKey, fieldSchema] of Object.entries(activeSchema)) {
|
|
331
|
+
if (fieldSchema.type !== 'uv-coordinate' ||
|
|
332
|
+
(!selectedFields.allFields && !selectedFields.fieldKeys.has(fieldKey))) {
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const propStatus = effectStatus.props[fieldKey];
|
|
336
|
+
if (!(propStatus === null || propStatus === void 0 ? void 0 : propStatus.canUpdate)) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const dragOverrideValue = dragOverrides[fieldKey];
|
|
340
|
+
const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
341
|
+
codeValue: propStatus,
|
|
342
|
+
dragOverrideValue,
|
|
343
|
+
defaultValue: fieldSchema.default,
|
|
344
|
+
shouldResortToDefaultValueIfUndefined: true,
|
|
345
|
+
});
|
|
346
|
+
const value = parseUvCoordinate(effectiveValue);
|
|
347
|
+
if (value === null) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
handles.push({
|
|
351
|
+
clientId,
|
|
352
|
+
codeValue: propStatus,
|
|
353
|
+
effectIndex,
|
|
354
|
+
fieldDefault: fieldSchema.default,
|
|
355
|
+
fieldKey,
|
|
356
|
+
fieldSchema,
|
|
357
|
+
nodePath,
|
|
358
|
+
schema: effect.schema,
|
|
359
|
+
value,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return handles;
|
|
364
|
+
};
|
|
365
|
+
const measureOutlines = (container, targets) => {
|
|
366
|
+
const containerRect = container.getBoundingClientRect();
|
|
367
|
+
const outlines = [];
|
|
368
|
+
for (const target of targets) {
|
|
369
|
+
const element = target.ref.current;
|
|
370
|
+
if (element === null) {
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const points = getElementOutlinePoints(element, containerRect);
|
|
374
|
+
if (points === null) {
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
outlines.push({ key: target.key, points });
|
|
378
|
+
}
|
|
379
|
+
return outlines;
|
|
380
|
+
};
|
|
381
|
+
const outlinesAreEqual = (a, b) => {
|
|
382
|
+
if (a.length !== b.length) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
for (let i = 0; i < a.length; i++) {
|
|
386
|
+
if (a[i].key !== b[i].key) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
for (let j = 0; j < a[i].points.length; j++) {
|
|
390
|
+
if (Math.abs(a[i].points[j].x - b[i].points[j].x) > 0.01 ||
|
|
391
|
+
Math.abs(a[i].points[j].y - b[i].points[j].y) > 0.01) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return true;
|
|
397
|
+
};
|
|
398
|
+
const getSelectedOutlineDragStates = ({ dragTargets, getDragOverrides, }) => {
|
|
399
|
+
return dragTargets.map((target) => {
|
|
400
|
+
var _a;
|
|
401
|
+
const dragOverrideValue = ((_a = getDragOverrides(target.nodePath)) !== null && _a !== void 0 ? _a : {})[translateFieldKey];
|
|
402
|
+
const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
403
|
+
codeValue: target.codeValue,
|
|
404
|
+
dragOverrideValue,
|
|
405
|
+
defaultValue: target.fieldDefault,
|
|
406
|
+
shouldResortToDefaultValueIfUndefined: true,
|
|
407
|
+
});
|
|
408
|
+
const [startX, startY] = (0, timeline_translate_utils_1.parseTranslate)(String(effectiveValue !== null && effectiveValue !== void 0 ? effectiveValue : '0px 0px'));
|
|
409
|
+
return {
|
|
410
|
+
defaultValue: target.fieldDefault !== undefined
|
|
411
|
+
? JSON.stringify(target.fieldDefault)
|
|
412
|
+
: null,
|
|
413
|
+
key: remotion_1.Internals.makeSequencePropsSubscriptionKey(target.nodePath),
|
|
414
|
+
startX,
|
|
415
|
+
startY,
|
|
416
|
+
target,
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
const getSelectedOutlineDragValues = ({ dragStates, deltaX, deltaY, }) => {
|
|
421
|
+
return new Map(dragStates.map((dragState) => [
|
|
422
|
+
dragState.key,
|
|
423
|
+
(0, timeline_translate_utils_1.serializeTranslate)(dragState.startX + deltaX, dragState.startY + deltaY),
|
|
424
|
+
]));
|
|
425
|
+
};
|
|
426
|
+
exports.getSelectedOutlineDragValues = getSelectedOutlineDragValues;
|
|
427
|
+
const getSelectedOutlineDragChanges = ({ dragStates, lastValues, }) => {
|
|
428
|
+
return dragStates.flatMap((dragState) => {
|
|
429
|
+
const value = lastValues.get(dragState.key);
|
|
430
|
+
if (value === undefined) {
|
|
431
|
+
return [];
|
|
432
|
+
}
|
|
433
|
+
const stringifiedValue = JSON.stringify(value);
|
|
434
|
+
const shouldSave = value !== dragState.target.codeValue.codeValue &&
|
|
435
|
+
!(dragState.defaultValue === stringifiedValue &&
|
|
436
|
+
dragState.target.codeValue.codeValue === undefined);
|
|
437
|
+
if (!shouldSave) {
|
|
438
|
+
return [];
|
|
439
|
+
}
|
|
440
|
+
return [
|
|
441
|
+
{
|
|
442
|
+
fileName: dragState.target.nodePath.absolutePath,
|
|
443
|
+
nodePath: dragState.target.nodePath,
|
|
444
|
+
fieldKey: translateFieldKey,
|
|
445
|
+
value,
|
|
446
|
+
defaultValue: dragState.defaultValue,
|
|
447
|
+
schema: dragState.target.schema,
|
|
448
|
+
},
|
|
449
|
+
];
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
exports.getSelectedOutlineDragChanges = getSelectedOutlineDragChanges;
|
|
453
|
+
const clearSelectedOutlineDragOverrides = ({ clearDragOverrides, dragStates, }) => {
|
|
454
|
+
for (const dragState of dragStates) {
|
|
455
|
+
clearDragOverrides(dragState.target.nodePath);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
const SelectedOutlinePolygon = ({ allDragTargets, outline, scale, target }) => {
|
|
459
|
+
var _a;
|
|
460
|
+
const { getDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
|
|
461
|
+
const { setCodeValues, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
462
|
+
const points = (0, react_1.useMemo)(() => outline.points.map(pointToString).join(' '), [outline.points]);
|
|
463
|
+
const drag = (_a = target === null || target === void 0 ? void 0 : target.drag) !== null && _a !== void 0 ? _a : null;
|
|
464
|
+
const onPointerDown = react_1.default.useCallback((event) => {
|
|
465
|
+
if (event.button !== 0 || drag === null) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
event.preventDefault();
|
|
469
|
+
event.stopPropagation();
|
|
470
|
+
const startPointerX = event.clientX;
|
|
471
|
+
const startPointerY = event.clientY;
|
|
472
|
+
const dragStates = getSelectedOutlineDragStates({
|
|
473
|
+
dragTargets: allDragTargets,
|
|
474
|
+
getDragOverrides,
|
|
475
|
+
});
|
|
476
|
+
let lastValues = new Map();
|
|
477
|
+
const onPointerMove = (moveEvent) => {
|
|
478
|
+
moveEvent.preventDefault();
|
|
479
|
+
lastValues = (0, exports.getSelectedOutlineDragValues)({
|
|
480
|
+
dragStates,
|
|
481
|
+
deltaX: (moveEvent.clientX - startPointerX) / scale,
|
|
482
|
+
deltaY: (moveEvent.clientY - startPointerY) / scale,
|
|
483
|
+
});
|
|
484
|
+
for (const dragState of dragStates) {
|
|
485
|
+
const value = lastValues.get(dragState.key);
|
|
486
|
+
if (value === undefined) {
|
|
487
|
+
throw new Error('Expected drag value to be available');
|
|
488
|
+
}
|
|
489
|
+
setDragOverrides(dragState.target.nodePath, translateFieldKey, value);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
const onPointerUp = () => {
|
|
493
|
+
window.removeEventListener('pointermove', onPointerMove);
|
|
494
|
+
window.removeEventListener('pointerup', onPointerUp);
|
|
495
|
+
window.removeEventListener('pointercancel', onPointerUp);
|
|
496
|
+
const changes = (0, exports.getSelectedOutlineDragChanges)({
|
|
497
|
+
dragStates,
|
|
498
|
+
lastValues,
|
|
499
|
+
});
|
|
500
|
+
if (changes.length === 0) {
|
|
501
|
+
clearSelectedOutlineDragOverrides({ clearDragOverrides, dragStates });
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
(0, save_sequence_prop_1.saveSequenceProps)({
|
|
505
|
+
changes,
|
|
506
|
+
setCodeValues,
|
|
507
|
+
clientId: drag.clientId,
|
|
508
|
+
undoLabel: changes.length > 1 ? 'Move selected sequences' : null,
|
|
509
|
+
redoLabel: changes.length > 1 ? 'Move selected sequences back' : null,
|
|
510
|
+
})
|
|
511
|
+
.catch((err) => {
|
|
512
|
+
(0, NotificationCenter_1.showNotification)(`Could not save sequence props: ${err instanceof Error ? err.message : String(err)}`, 4000);
|
|
513
|
+
})
|
|
514
|
+
.finally(() => {
|
|
515
|
+
clearSelectedOutlineDragOverrides({ clearDragOverrides, dragStates });
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
window.addEventListener('pointermove', onPointerMove);
|
|
519
|
+
window.addEventListener('pointerup', onPointerUp);
|
|
520
|
+
window.addEventListener('pointercancel', onPointerUp);
|
|
521
|
+
}, [
|
|
522
|
+
allDragTargets,
|
|
523
|
+
clearDragOverrides,
|
|
524
|
+
drag,
|
|
525
|
+
getDragOverrides,
|
|
526
|
+
scale,
|
|
527
|
+
setCodeValues,
|
|
528
|
+
setDragOverrides,
|
|
529
|
+
]);
|
|
530
|
+
return (jsx_runtime_1.jsx("polygon", { points: points, fill: drag === null ? 'none' : 'transparent', stroke: colors_1.BLUE, strokeWidth: 2, vectorEffect: "non-scaling-stroke", pointerEvents: drag === null ? undefined : 'all', onPointerDown: drag === null ? undefined : onPointerDown }));
|
|
531
|
+
};
|
|
532
|
+
const getSvgPointFromPointerEvent = ({ event, rect, }) => {
|
|
533
|
+
return {
|
|
534
|
+
x: event.clientX - rect.left,
|
|
535
|
+
y: event.clientY - rect.top,
|
|
536
|
+
};
|
|
537
|
+
};
|
|
538
|
+
const SelectedUvHandleCircle = ({ handle, outline }) => {
|
|
539
|
+
const { setEffectDragOverrides, clearEffectDragOverrides, setCodeValues } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
540
|
+
const position = (0, react_1.useMemo)(() => (0, exports.getUvHandlePosition)(outline.points, handle.value), [handle.value, outline.points]);
|
|
541
|
+
const onPointerDown = react_1.default.useCallback((event) => {
|
|
542
|
+
if (event.button !== 0) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
event.preventDefault();
|
|
546
|
+
event.stopPropagation();
|
|
547
|
+
const svg = event.currentTarget.ownerSVGElement;
|
|
548
|
+
if (svg === null) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const svgRect = svg.getBoundingClientRect();
|
|
552
|
+
let lastValue = null;
|
|
553
|
+
const defaultValue = handle.fieldDefault !== undefined
|
|
554
|
+
? JSON.stringify(handle.fieldDefault)
|
|
555
|
+
: null;
|
|
556
|
+
const updateFromPointerEvent = (pointerEvent) => {
|
|
557
|
+
const point = getSvgPointFromPointerEvent({
|
|
558
|
+
event: pointerEvent,
|
|
559
|
+
rect: svgRect,
|
|
560
|
+
});
|
|
561
|
+
const nextValue = constrainUv((0, exports.getUvCoordinateForPoint)(outline.points, point), handle.fieldSchema);
|
|
562
|
+
lastValue = nextValue;
|
|
563
|
+
setEffectDragOverrides(handle.nodePath, handle.effectIndex, handle.fieldKey, nextValue);
|
|
564
|
+
};
|
|
565
|
+
updateFromPointerEvent(event);
|
|
566
|
+
const onPointerMove = (moveEvent) => {
|
|
567
|
+
moveEvent.preventDefault();
|
|
568
|
+
updateFromPointerEvent(moveEvent);
|
|
569
|
+
};
|
|
570
|
+
const onPointerUp = () => {
|
|
571
|
+
window.removeEventListener('pointermove', onPointerMove);
|
|
572
|
+
window.removeEventListener('pointerup', onPointerUp);
|
|
573
|
+
window.removeEventListener('pointercancel', onPointerUp);
|
|
574
|
+
const stringifiedValue = lastValue === null ? null : JSON.stringify(lastValue);
|
|
575
|
+
const shouldSave = lastValue !== null &&
|
|
576
|
+
!tuplesEqual(handle.codeValue.codeValue, lastValue) &&
|
|
577
|
+
!(defaultValue === stringifiedValue &&
|
|
578
|
+
handle.codeValue.codeValue === undefined);
|
|
579
|
+
if (!shouldSave) {
|
|
580
|
+
clearEffectDragOverrides(handle.nodePath, handle.effectIndex);
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
(0, save_effect_prop_1.saveEffectProp)({
|
|
584
|
+
fileName: handle.nodePath.absolutePath,
|
|
585
|
+
nodePath: handle.nodePath,
|
|
586
|
+
effectIndex: handle.effectIndex,
|
|
587
|
+
fieldKey: handle.fieldKey,
|
|
588
|
+
value: lastValue,
|
|
589
|
+
defaultValue,
|
|
590
|
+
schema: handle.schema,
|
|
591
|
+
setCodeValues,
|
|
592
|
+
clientId: handle.clientId,
|
|
593
|
+
}).finally(() => {
|
|
594
|
+
clearEffectDragOverrides(handle.nodePath, handle.effectIndex);
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
window.addEventListener('pointermove', onPointerMove);
|
|
598
|
+
window.addEventListener('pointerup', onPointerUp);
|
|
599
|
+
window.addEventListener('pointercancel', onPointerUp);
|
|
600
|
+
}, [
|
|
601
|
+
clearEffectDragOverrides,
|
|
602
|
+
handle,
|
|
603
|
+
outline.points,
|
|
604
|
+
setCodeValues,
|
|
605
|
+
setEffectDragOverrides,
|
|
606
|
+
]);
|
|
607
|
+
return (jsx_runtime_1.jsx("circle", { cx: position.x, cy: position.y, r: 6, fill: "white", stroke: colors_1.BLUE, strokeWidth: 2, vectorEffect: "non-scaling-stroke", pointerEvents: "all", cursor: "move", onPointerDown: onPointerDown }));
|
|
608
|
+
};
|
|
609
|
+
const SelectedOutlineOverlay = ({ scale }) => {
|
|
610
|
+
const { selectedItems } = (0, TimelineSelection_1.useTimelineSelection)();
|
|
611
|
+
const { sequences } = (0, react_1.useContext)(remotion_1.Internals.SequenceManager);
|
|
612
|
+
const { codeValues } = (0, react_1.useContext)(remotion_1.Internals.VisualModeCodeValuesContext);
|
|
613
|
+
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
614
|
+
const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
|
|
615
|
+
const { getEffectDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
|
|
616
|
+
const [outlines, setOutlines] = (0, react_1.useState)([]);
|
|
617
|
+
const overlayRef = (0, react_1.useRef)(null);
|
|
618
|
+
const selectedOutlineTargets = (0, react_1.useMemo)(() => {
|
|
619
|
+
if (!TimelineSelection_1.ENABLE_OUTLINES) {
|
|
620
|
+
return [];
|
|
621
|
+
}
|
|
622
|
+
const selectedEffectsBySequenceKey = (0, exports.getSelectedEffectFieldsBySequenceKey)(selectedItems);
|
|
623
|
+
const clientId = previewServerState.type === 'connected'
|
|
624
|
+
? previewServerState.clientId
|
|
625
|
+
: null;
|
|
626
|
+
return getSequencesWithSelectedOutlines({
|
|
627
|
+
selectedItems,
|
|
628
|
+
sequences,
|
|
629
|
+
overrideIdsToNodePaths: overrideIdToNodePathMappings,
|
|
630
|
+
}).map(({ key, nodePathInfo, sequence }) => {
|
|
631
|
+
var _a;
|
|
632
|
+
if (sequence.refForOutline === null) {
|
|
633
|
+
throw new Error('Expected sequence to have a ref for outline');
|
|
634
|
+
}
|
|
635
|
+
const nodePath = nodePathInfo.sequenceSubscriptionKey;
|
|
636
|
+
const { controls } = sequence;
|
|
637
|
+
const fieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[translateFieldKey];
|
|
638
|
+
const codeValue = (_a = remotion_1.Internals.getCodeValuesCtx(codeValues, nodePath)) === null || _a === void 0 ? void 0 : _a[translateFieldKey];
|
|
639
|
+
const canDrag = previewServerState.type === 'connected' &&
|
|
640
|
+
controls !== null &&
|
|
641
|
+
(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.type) === 'translate' &&
|
|
642
|
+
(codeValue === null || codeValue === void 0 ? void 0 : codeValue.canUpdate) === true;
|
|
643
|
+
return {
|
|
644
|
+
key,
|
|
645
|
+
ref: sequence.refForOutline,
|
|
646
|
+
drag: canDrag
|
|
647
|
+
? {
|
|
648
|
+
codeValue,
|
|
649
|
+
clientId: previewServerState.clientId,
|
|
650
|
+
fieldDefault: fieldSchema.default,
|
|
651
|
+
nodePath,
|
|
652
|
+
schema: controls.schema,
|
|
653
|
+
}
|
|
654
|
+
: null,
|
|
655
|
+
uvHandles: getSelectedUvHandles({
|
|
656
|
+
codeValues,
|
|
657
|
+
clientId,
|
|
658
|
+
getEffectDragOverrides,
|
|
659
|
+
nodePath,
|
|
660
|
+
selectedEffects: selectedEffectsBySequenceKey.get(key),
|
|
661
|
+
sequence,
|
|
662
|
+
}),
|
|
663
|
+
};
|
|
664
|
+
});
|
|
665
|
+
}, [
|
|
666
|
+
codeValues,
|
|
667
|
+
getEffectDragOverrides,
|
|
668
|
+
overrideIdToNodePathMappings,
|
|
669
|
+
previewServerState,
|
|
670
|
+
selectedItems,
|
|
671
|
+
sequences,
|
|
672
|
+
]);
|
|
673
|
+
const targetsByKey = (0, react_1.useMemo)(() => {
|
|
674
|
+
return new Map(selectedOutlineTargets.map((target) => [target.key, target]));
|
|
675
|
+
}, [selectedOutlineTargets]);
|
|
676
|
+
const allDragTargets = (0, react_1.useMemo)(() => {
|
|
677
|
+
return selectedOutlineTargets.flatMap((target) => target.drag === null ? [] : [target.drag]);
|
|
678
|
+
}, [selectedOutlineTargets]);
|
|
679
|
+
(0, react_1.useEffect)(() => {
|
|
680
|
+
if (selectedOutlineTargets.length === 0) {
|
|
681
|
+
setOutlines((prevOutlines) => prevOutlines.length === 0 ? prevOutlines : []);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
let animationFrame = null;
|
|
685
|
+
const updateOutlines = () => {
|
|
686
|
+
if (overlayRef.current) {
|
|
687
|
+
const nextOutlines = measureOutlines(overlayRef.current, selectedOutlineTargets);
|
|
688
|
+
setOutlines((prevOutlines) => outlinesAreEqual(prevOutlines, nextOutlines)
|
|
689
|
+
? prevOutlines
|
|
690
|
+
: nextOutlines);
|
|
691
|
+
}
|
|
692
|
+
animationFrame = requestAnimationFrame(updateOutlines);
|
|
693
|
+
};
|
|
694
|
+
updateOutlines();
|
|
695
|
+
return () => {
|
|
696
|
+
if (animationFrame !== null) {
|
|
697
|
+
cancelAnimationFrame(animationFrame);
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
}, [selectedOutlineTargets]);
|
|
701
|
+
if (selectedOutlineTargets.length === 0) {
|
|
702
|
+
return null;
|
|
703
|
+
}
|
|
704
|
+
return (jsx_runtime_1.jsx("svg", { ref: overlayRef, style: outlineContainer, width: "100%", height: "100%", "aria-hidden": "true", children: outlines.map((outline) => {
|
|
705
|
+
var _a;
|
|
706
|
+
return (jsx_runtime_1.jsxs(react_1.default.Fragment, { children: [
|
|
707
|
+
jsx_runtime_1.jsx(SelectedOutlinePolygon, { allDragTargets: allDragTargets, outline: outline, scale: scale, target: targetsByKey.get(outline.key) }), (_a = targetsByKey.get(outline.key)) === null || _a === void 0 ? void 0 : _a.uvHandles.map((handle) => (jsx_runtime_1.jsx(SelectedUvHandleCircle, { handle: handle, outline: outline }, `${handle.effectIndex}-${handle.fieldKey}`)))] }, outline.key));
|
|
708
|
+
}) }));
|
|
709
|
+
};
|
|
710
|
+
exports.SelectedOutlineOverlay = SelectedOutlineOverlay;
|