@remotion/studio 4.0.496 → 4.0.497
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/components/AudioWaveform.js +1 -11
- package/dist/components/Canvas.js +22 -203
- package/dist/components/CompositionSelectorItem.js +2 -10
- package/dist/components/InspectorPanel/AlignmentControls.js +2 -0
- package/dist/components/InspectorPanel/ConnectedCompositionsSection.js +27 -2
- package/dist/components/InspectorPanel/SequenceSelectionInspector.js +65 -8
- package/dist/components/InspectorPanel/use-composition-actions.js +6 -2
- package/dist/components/NewComposition/CodemodFooter.d.ts +1 -1
- package/dist/components/NewComposition/CodemodFooter.js +23 -4
- package/dist/components/NewComposition/InputDragger.d.ts +6 -0
- package/dist/components/NewComposition/InputDragger.js +12 -3
- package/dist/components/NewComposition/NewComposition.js +1 -1
- package/dist/components/NewComposition/use-rename-static-file.js +1 -1
- package/dist/components/SelectedOutlineElement.js +56 -88
- package/dist/components/SelectedOutlineOverlay.d.ts +1 -1
- package/dist/components/SelectedOutlineOverlay.js +9 -10
- package/dist/components/Timeline/Timeline.js +10 -3
- package/dist/components/Timeline/TimelineAssetDropIndicator.d.ts +2 -0
- package/dist/components/Timeline/TimelineAssetDropIndicator.js +37 -0
- package/dist/components/Timeline/TimelineClipboardKeybindings.js +1 -7
- package/dist/components/Timeline/TimelineScrollable.js +3 -2
- package/dist/components/Timeline/TimelineSelection.d.ts +4 -0
- package/dist/components/Timeline/TimelineSelection.js +40 -5
- package/dist/components/Timeline/TimelineSequence.js +20 -8
- package/dist/components/Timeline/TimelineSequenceFrame.js +2 -4
- package/dist/components/Timeline/TimelineSequenceItem.js +2 -0
- package/dist/components/Timeline/TimelineSequencePropItem.js +4 -0
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +15 -3
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +96 -18
- package/dist/components/Timeline/TimelineTimeIndicators.d.ts +16 -0
- package/dist/components/Timeline/TimelineTimeIndicators.js +154 -35
- package/dist/components/Timeline/TimelineTranslateField.js +2 -1
- package/dist/components/Timeline/TimelineVideoInfo.d.ts +1 -0
- package/dist/components/Timeline/TimelineVideoInfo.js +4 -1
- package/dist/components/Timeline/delete-selected-timeline-item.d.ts +2 -0
- package/dist/components/Timeline/delete-selected-timeline-item.js +5 -4
- package/dist/components/Timeline/disable-sequence-interactivity.js +2 -0
- package/dist/components/Timeline/get-timeline-media-visualization-layout.d.ts +8 -0
- package/dist/components/Timeline/get-timeline-media-visualization-layout.js +10 -0
- package/dist/components/Timeline/get-timeline-video-info-widths.js +11 -3
- package/dist/components/Timeline/keyframe-clipboard.js +21 -5
- package/dist/components/Timeline/reset-selected-timeline-props.js +2 -0
- package/dist/components/Timeline/save-sequence-prop.d.ts +5 -3
- package/dist/components/Timeline/save-sequence-prop.js +43 -18
- package/dist/components/Timeline/should-clear-selection-on-pointer-down.d.ts +2 -0
- package/dist/components/Timeline/should-clear-selection-on-pointer-down.js +1 -1
- package/dist/components/Timeline/timeline-asset-drop-context.d.ts +1 -0
- package/dist/components/Timeline/timeline-asset-drop-context.js +5 -0
- package/dist/components/Timeline/timeline-scroll-logic.d.ts +7 -0
- package/dist/components/Timeline/timeline-scroll-logic.js +10 -1
- package/dist/components/Timeline/use-rename-sequence.js +2 -0
- package/dist/components/Timeline/use-sequence-freeze-frame-menu-item.js +2 -0
- package/dist/components/Timeline/use-timeline-asset-drop.d.ts +1 -0
- package/dist/components/Timeline/use-timeline-asset-drop.js +168 -0
- package/dist/components/composition-menu-items.d.ts +15 -1
- package/dist/components/composition-menu-items.js +137 -107
- package/dist/components/drop-handler-data.d.ts +13 -0
- package/dist/components/drop-handler-data.js +117 -0
- package/dist/components/handle-drop.d.ts +13 -0
- package/dist/components/handle-drop.js +115 -0
- package/dist/components/import-assets.d.ts +26 -8
- package/dist/components/import-assets.js +161 -49
- package/dist/components/selected-outline-drag.d.ts +11 -1
- package/dist/components/selected-outline-drag.js +74 -1
- package/dist/esm/{chunk-0v4n7nkh.js → chunk-5wj95bdd.js} +4262 -3392
- package/dist/esm/internals.mjs +4262 -3392
- package/dist/esm/previewEntry.mjs +4464 -3594
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/is-video-with-last-frame-hold.d.ts +2 -0
- package/dist/helpers/is-video-with-last-frame-hold.js +9 -0
- package/dist/helpers/url-state.d.ts +1 -0
- package/dist/helpers/url-state.js +5 -1
- package/dist/helpers/use-max-media-duration.js +5 -3
- package/dist/helpers/use-menu-structure.js +2 -0
- package/dist/icons/duplicate.d.ts +5 -0
- package/dist/icons/duplicate.js +10 -0
- package/dist/icons/snowflake.d.ts +5 -0
- package/dist/icons/snowflake.js +10 -0
- package/dist/icons/trash.d.ts +5 -0
- package/dist/icons/trash.js +8 -0
- package/package.json +11 -11
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.insertElement = exports.insertComposition = exports.insertComponent = exports.insertExistingAssets = exports.insertRemoteAudio = exports.importRemoteAsset = exports.insertSvgMarkup = exports.importFigmaClipboard = exports.importAssets = exports.pickFilesToImport = exports.getComponentDimensions = exports.getAssetPositionForDrop = exports.getCompositionPositionForDrop = exports.getElementPositionForDrop = exports.hasSvgFile = exports.getAssetElementForDroppedFile = exports.getAssetElementFromPath = exports.getAssetElement = void 0;
|
|
4
|
-
const media_utils_1 = require("@remotion/media-utils");
|
|
3
|
+
exports.insertElement = exports.insertComposition = exports.insertComponent = exports.insertExistingAssets = exports.insertRemoteAudio = exports.importRemoteAsset = exports.insertSvgMarkup = exports.importFigmaClipboard = exports.importAssets = exports.pickFilesToImport = exports.getDurationInFrames = exports.getComponentDimensions = exports.getAssetPositionForDrop = exports.getCompositionPositionForDrop = exports.getElementPositionForDrop = exports.hasSvgFile = exports.getAssetElementForDroppedFile = exports.getAssetElementFromPath = exports.getAssetElement = void 0;
|
|
5
4
|
const studio_shared_1 = require("@remotion/studio-shared");
|
|
6
5
|
const remotion_1 = require("remotion");
|
|
7
6
|
const no_react_1 = require("remotion/no-react");
|
|
@@ -9,6 +8,7 @@ const get_static_files_1 = require("../api/get-static-files");
|
|
|
9
8
|
const write_static_file_1 = require("../api/write-static-file");
|
|
10
9
|
const clipboard_figma_1 = require("../helpers/clipboard-figma");
|
|
11
10
|
const install_required_package_1 = require("../helpers/install-required-package");
|
|
11
|
+
const use_media_metadata_1 = require("../helpers/use-media-metadata");
|
|
12
12
|
const call_api_1 = require("./call-api");
|
|
13
13
|
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
14
14
|
const getAssetElement = ({ fileType, src, }) => {
|
|
@@ -19,6 +19,7 @@ const getAssetElement = ({ fileType, src, }) => {
|
|
|
19
19
|
src,
|
|
20
20
|
srcType: 'static',
|
|
21
21
|
dimensions: fileType.dimensions,
|
|
22
|
+
durationInFrames: null,
|
|
22
23
|
position: null,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
@@ -32,6 +33,7 @@ const getAssetElement = ({ fileType, src, }) => {
|
|
|
32
33
|
src,
|
|
33
34
|
srcType: 'static',
|
|
34
35
|
dimensions: fileType.dimensions,
|
|
36
|
+
durationInFrames: null,
|
|
35
37
|
position: null,
|
|
36
38
|
};
|
|
37
39
|
}
|
|
@@ -42,6 +44,7 @@ const getAssetElement = ({ fileType, src, }) => {
|
|
|
42
44
|
src,
|
|
43
45
|
srcType: 'static',
|
|
44
46
|
dimensions: fileType.dimensions,
|
|
47
|
+
durationInFrames: null,
|
|
45
48
|
position: null,
|
|
46
49
|
};
|
|
47
50
|
}
|
|
@@ -52,6 +55,7 @@ const getAssetElement = ({ fileType, src, }) => {
|
|
|
52
55
|
src,
|
|
53
56
|
srcType: 'static',
|
|
54
57
|
dimensions: fileType.dimensions,
|
|
58
|
+
durationInFrames: null,
|
|
55
59
|
position: null,
|
|
56
60
|
};
|
|
57
61
|
}
|
|
@@ -65,6 +69,7 @@ const getAssetElement = ({ fileType, src, }) => {
|
|
|
65
69
|
src,
|
|
66
70
|
srcType: 'static',
|
|
67
71
|
dimensions: null,
|
|
72
|
+
durationInFrames: null,
|
|
68
73
|
position: null,
|
|
69
74
|
};
|
|
70
75
|
}
|
|
@@ -78,6 +83,7 @@ const getAssetElement = ({ fileType, src, }) => {
|
|
|
78
83
|
src,
|
|
79
84
|
srcType: 'static',
|
|
80
85
|
dimensions: null,
|
|
86
|
+
durationInFrames: null,
|
|
81
87
|
position: null,
|
|
82
88
|
};
|
|
83
89
|
}
|
|
@@ -100,6 +106,7 @@ const getAssetElementFromPath = (assetPath) => {
|
|
|
100
106
|
src: assetPath,
|
|
101
107
|
srcType: 'static',
|
|
102
108
|
dimensions: null,
|
|
109
|
+
durationInFrames: null,
|
|
103
110
|
position: null,
|
|
104
111
|
};
|
|
105
112
|
}
|
|
@@ -110,6 +117,7 @@ const getAssetElementFromPath = (assetPath) => {
|
|
|
110
117
|
src: assetPath,
|
|
111
118
|
srcType: 'static',
|
|
112
119
|
dimensions: null,
|
|
120
|
+
durationInFrames: null,
|
|
113
121
|
position: null,
|
|
114
122
|
};
|
|
115
123
|
}
|
|
@@ -120,6 +128,7 @@ const getAssetElementFromPath = (assetPath) => {
|
|
|
120
128
|
src: assetPath,
|
|
121
129
|
srcType: 'static',
|
|
122
130
|
dimensions: null,
|
|
131
|
+
durationInFrames: null,
|
|
123
132
|
position: null,
|
|
124
133
|
};
|
|
125
134
|
}
|
|
@@ -130,6 +139,7 @@ const getAssetElementFromPath = (assetPath) => {
|
|
|
130
139
|
src: assetPath,
|
|
131
140
|
srcType: 'static',
|
|
132
141
|
dimensions: null,
|
|
142
|
+
durationInFrames: null,
|
|
133
143
|
position: null,
|
|
134
144
|
};
|
|
135
145
|
}
|
|
@@ -140,6 +150,7 @@ const getAssetElementFromPath = (assetPath) => {
|
|
|
140
150
|
src: assetPath,
|
|
141
151
|
srcType: 'static',
|
|
142
152
|
dimensions: null,
|
|
153
|
+
durationInFrames: null,
|
|
143
154
|
position: null,
|
|
144
155
|
};
|
|
145
156
|
}
|
|
@@ -267,20 +278,47 @@ const getImageDimensions = ({ revokeObjectUrl, src, }) => {
|
|
|
267
278
|
image.src = src;
|
|
268
279
|
});
|
|
269
280
|
};
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
281
|
+
const getMediaAssetMetadata = async (src) => {
|
|
282
|
+
var _a;
|
|
283
|
+
const metadata = await (0, use_media_metadata_1.getMediaMetadata)(src);
|
|
284
|
+
return {
|
|
285
|
+
dimensions: (metadata === null || metadata === void 0 ? void 0 : metadata.width) === null || (metadata === null || metadata === void 0 ? void 0 : metadata.height) === null || !metadata
|
|
286
|
+
? null
|
|
287
|
+
: { width: metadata.width, height: metadata.height },
|
|
288
|
+
durationInSeconds: (_a = metadata === null || metadata === void 0 ? void 0 : metadata.duration) !== null && _a !== void 0 ? _a : null,
|
|
289
|
+
};
|
|
273
290
|
};
|
|
274
|
-
const
|
|
291
|
+
const getAnimatedImageAssetDuration = (src, contentType) => {
|
|
292
|
+
return remotion_1.Internals.getAnimatedImageDurationInSeconds({
|
|
293
|
+
resolvedSrc: src,
|
|
294
|
+
signal: new AbortController().signal,
|
|
295
|
+
contentType,
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
const assetTypeHasDuration = (assetType) => assetType !== 'image';
|
|
299
|
+
const getFileMetadata = async ({ file, fileType, }) => {
|
|
300
|
+
var _a;
|
|
275
301
|
if (fileType.type === 'unknown' && file.name.toLowerCase().endsWith('.svg')) {
|
|
276
302
|
const objectUrl = URL.createObjectURL(file);
|
|
277
|
-
return
|
|
303
|
+
return {
|
|
304
|
+
dimensions: await getImageDimensions({
|
|
305
|
+
revokeObjectUrl: true,
|
|
306
|
+
src: objectUrl,
|
|
307
|
+
}),
|
|
308
|
+
durationInSeconds: null,
|
|
309
|
+
};
|
|
278
310
|
}
|
|
279
311
|
if (fileType.type === 'wav' ||
|
|
280
312
|
fileType.type === 'mp3' ||
|
|
281
313
|
fileType.type === 'aac' ||
|
|
282
314
|
fileType.type === 'flac') {
|
|
283
|
-
|
|
315
|
+
const objectUrl = URL.createObjectURL(file);
|
|
316
|
+
try {
|
|
317
|
+
return await getMediaAssetMetadata(objectUrl);
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
URL.revokeObjectURL(objectUrl);
|
|
321
|
+
}
|
|
284
322
|
}
|
|
285
323
|
if (fileType.type === 'png' ||
|
|
286
324
|
fileType.type === 'jpeg' ||
|
|
@@ -288,11 +326,26 @@ const getFileDimensions = async ({ file, fileType, }) => {
|
|
|
288
326
|
fileType.type === 'bmp' ||
|
|
289
327
|
fileType.type === 'apng' ||
|
|
290
328
|
fileType.type === 'gif') {
|
|
291
|
-
if (fileType.dimensions) {
|
|
292
|
-
return fileType.dimensions;
|
|
293
|
-
}
|
|
294
329
|
const objectUrl = URL.createObjectURL(file);
|
|
295
|
-
|
|
330
|
+
try {
|
|
331
|
+
const dimensions = (_a = fileType.dimensions) !== null && _a !== void 0 ? _a : (await getImageDimensions({ revokeObjectUrl: false, src: objectUrl }));
|
|
332
|
+
const isAnimated = fileType.type === 'gif' ||
|
|
333
|
+
fileType.type === 'apng' ||
|
|
334
|
+
(fileType.type === 'webp' && fileType.animated);
|
|
335
|
+
return {
|
|
336
|
+
dimensions,
|
|
337
|
+
durationInSeconds: isAnimated
|
|
338
|
+
? await getAnimatedImageAssetDuration(objectUrl, fileType.type === 'gif'
|
|
339
|
+
? 'image/gif'
|
|
340
|
+
: fileType.type === 'webp'
|
|
341
|
+
? 'image/webp'
|
|
342
|
+
: 'image/png')
|
|
343
|
+
: null,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
finally {
|
|
347
|
+
URL.revokeObjectURL(objectUrl);
|
|
348
|
+
}
|
|
296
349
|
}
|
|
297
350
|
if (fileType.type === 'riff' ||
|
|
298
351
|
fileType.type === 'webm' ||
|
|
@@ -300,44 +353,65 @@ const getFileDimensions = async ({ file, fileType, }) => {
|
|
|
300
353
|
fileType.type === 'transport-stream') {
|
|
301
354
|
const objectUrl = URL.createObjectURL(file);
|
|
302
355
|
try {
|
|
303
|
-
return await
|
|
356
|
+
return await getMediaAssetMetadata(objectUrl);
|
|
304
357
|
}
|
|
305
358
|
finally {
|
|
306
359
|
URL.revokeObjectURL(objectUrl);
|
|
307
360
|
}
|
|
308
361
|
}
|
|
309
|
-
return null;
|
|
362
|
+
return { dimensions: null, durationInSeconds: null };
|
|
310
363
|
};
|
|
311
|
-
const
|
|
364
|
+
const getStaticAssetMetadata = (assetPath, assetType) => {
|
|
312
365
|
var _a;
|
|
313
366
|
const extension = (_a = assetPath.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
314
367
|
const src = (0, remotion_1.staticFile)(assetPath);
|
|
315
368
|
if (extension &&
|
|
316
369
|
['png', 'jpg', 'jpeg', 'webp', 'bmp', 'gif', 'apng', 'svg'].includes(extension)) {
|
|
317
|
-
return
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
370
|
+
return Promise.all([
|
|
371
|
+
getImageDimensions({ revokeObjectUrl: false, src }),
|
|
372
|
+
assetType === 'gif' || assetType === 'animated-image'
|
|
373
|
+
? getAnimatedImageAssetDuration(src, extension === 'gif'
|
|
374
|
+
? 'image/gif'
|
|
375
|
+
: extension === 'webp'
|
|
376
|
+
? 'image/webp'
|
|
377
|
+
: 'image/png')
|
|
378
|
+
: null,
|
|
379
|
+
]).then(([dimensions, durationInSeconds]) => ({
|
|
380
|
+
dimensions,
|
|
381
|
+
durationInSeconds,
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
if (assetType === 'video' || assetType === 'audio') {
|
|
385
|
+
return getMediaAssetMetadata(src);
|
|
386
|
+
}
|
|
387
|
+
return { dimensions: null, durationInSeconds: null };
|
|
388
|
+
};
|
|
389
|
+
const getFileMetadataOrNull = async ({ file, fileType, }) => {
|
|
326
390
|
try {
|
|
327
|
-
return await
|
|
391
|
+
return await getFileMetadata({ file, fileType });
|
|
328
392
|
}
|
|
329
393
|
catch (_a) {
|
|
330
|
-
return null;
|
|
394
|
+
return { dimensions: null, durationInSeconds: null };
|
|
331
395
|
}
|
|
332
396
|
};
|
|
333
|
-
const
|
|
397
|
+
const getStaticAssetMetadataOrNull = async (assetPath, assetType) => {
|
|
334
398
|
try {
|
|
335
|
-
return await
|
|
399
|
+
return await getStaticAssetMetadata(assetPath, assetType);
|
|
336
400
|
}
|
|
337
401
|
catch (_a) {
|
|
402
|
+
return { dimensions: null, durationInSeconds: null };
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const getDurationInFrames = ({ durationInSeconds, fps, }) => {
|
|
406
|
+
if (durationInSeconds === null ||
|
|
407
|
+
!Number.isFinite(durationInSeconds) ||
|
|
408
|
+
durationInSeconds <= 0) {
|
|
338
409
|
return null;
|
|
339
410
|
}
|
|
411
|
+
const durationInFrames = Math.round(durationInSeconds * fps * 100) / 100;
|
|
412
|
+
return durationInFrames > 0 ? durationInFrames : null;
|
|
340
413
|
};
|
|
414
|
+
exports.getDurationInFrames = getDurationInFrames;
|
|
341
415
|
const getStaticAssetFileType = async (assetPath) => {
|
|
342
416
|
var _a;
|
|
343
417
|
const extension = (_a = assetPath.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
@@ -410,13 +484,14 @@ const notifyUnsupportedFiles = (unsupportedFiles) => {
|
|
|
410
484
|
(0, NotificationCenter_1.showNotification)(`Skipped ${unsupportedFiles.length} unsupported files`, 3000);
|
|
411
485
|
}
|
|
412
486
|
};
|
|
413
|
-
const insertCompositionElement = async ({ compositionFile, compositionId, element, }) => {
|
|
487
|
+
const insertCompositionElement = async ({ compositionFile, compositionId, element, from, }) => {
|
|
414
488
|
const requiredPackage = (0, studio_shared_1.getRequiredPackageForInsertableElement)(element);
|
|
415
489
|
await (0, install_required_package_1.installRequiredPackages)(requiredPackage ? [requiredPackage] : []);
|
|
416
490
|
const result = await (0, call_api_1.callApi)('/api/insert-jsx-element', {
|
|
417
491
|
compositionFile,
|
|
418
492
|
compositionId,
|
|
419
493
|
element,
|
|
494
|
+
from,
|
|
420
495
|
});
|
|
421
496
|
if (!result.success) {
|
|
422
497
|
(0, NotificationCenter_1.showNotification)(result.reason, 4000);
|
|
@@ -427,7 +502,7 @@ const insertCompositionElement = async ({ compositionFile, compositionId, elemen
|
|
|
427
502
|
const downloadRemoteAsset = (url) => {
|
|
428
503
|
return (0, call_api_1.callApi)('/api/download-remote-asset', { url });
|
|
429
504
|
};
|
|
430
|
-
const importAssets = async ({ compositionFile, compositionId, destinationDimensions, dropPosition, files, svgImportMode, }) => {
|
|
505
|
+
const importAssets = async ({ compositionFile, compositionId, destinationDimensions, dropPosition, files, fps, from, svgImportMode, }) => {
|
|
431
506
|
var _a;
|
|
432
507
|
if (files.length === 0) {
|
|
433
508
|
return;
|
|
@@ -460,16 +535,17 @@ const importAssets = async ({ compositionFile, compositionId, destinationDimensi
|
|
|
460
535
|
for (const file of files) {
|
|
461
536
|
const contents = await file.arrayBuffer();
|
|
462
537
|
const fileType = (0, studio_shared_1.detectFileType)(new Uint8Array(contents));
|
|
463
|
-
const
|
|
538
|
+
const metadata = await getFileMetadataOrNull({ file, fileType });
|
|
464
539
|
if (isSvgFile(file) && svgImportMode === 'inline') {
|
|
465
540
|
const svgInserted = await insertCompositionElement({
|
|
466
541
|
compositionFile,
|
|
467
542
|
compositionId,
|
|
543
|
+
from,
|
|
468
544
|
element: {
|
|
469
545
|
type: 'svg',
|
|
470
546
|
markup: new TextDecoder().decode(contents),
|
|
471
547
|
position: (0, exports.getAssetPositionForDrop)({
|
|
472
|
-
assetDimensions: dimensions,
|
|
548
|
+
assetDimensions: metadata.dimensions,
|
|
473
549
|
destinationDimensions,
|
|
474
550
|
dropPosition,
|
|
475
551
|
}),
|
|
@@ -499,13 +575,20 @@ const importAssets = async ({ compositionFile, compositionId, destinationDimensi
|
|
|
499
575
|
});
|
|
500
576
|
addedStaticFiles.push(file.name);
|
|
501
577
|
}
|
|
502
|
-
const resolvedDimensions = (_a = element.dimensions) !== null && _a !== void 0 ? _a : dimensions;
|
|
578
|
+
const resolvedDimensions = (_a = element.dimensions) !== null && _a !== void 0 ? _a : metadata.dimensions;
|
|
503
579
|
const inserted = await insertCompositionElement({
|
|
504
580
|
compositionFile,
|
|
505
581
|
compositionId,
|
|
582
|
+
from,
|
|
506
583
|
element: {
|
|
507
584
|
...element,
|
|
508
585
|
dimensions: resolvedDimensions,
|
|
586
|
+
durationInFrames: assetTypeHasDuration(element.assetType)
|
|
587
|
+
? (0, exports.getDurationInFrames)({
|
|
588
|
+
durationInSeconds: metadata.durationInSeconds,
|
|
589
|
+
fps,
|
|
590
|
+
})
|
|
591
|
+
: null,
|
|
509
592
|
position: (0, exports.getAssetPositionForDrop)({
|
|
510
593
|
assetDimensions: resolvedDimensions,
|
|
511
594
|
destinationDimensions,
|
|
@@ -566,6 +649,7 @@ const insertSvgMarkup = async ({ compositionFile, compositionId, destinationDime
|
|
|
566
649
|
const inserted = await insertCompositionElement({
|
|
567
650
|
compositionFile,
|
|
568
651
|
compositionId,
|
|
652
|
+
from: null,
|
|
569
653
|
element: {
|
|
570
654
|
type: 'svg',
|
|
571
655
|
markup,
|
|
@@ -585,7 +669,8 @@ const insertSvgMarkup = async ({ compositionFile, compositionId, destinationDime
|
|
|
585
669
|
}
|
|
586
670
|
};
|
|
587
671
|
exports.insertSvgMarkup = insertSvgMarkup;
|
|
588
|
-
const importRemoteAsset = async ({ compositionFile, compositionId, destinationDimensions, dropPosition, url, }) => {
|
|
672
|
+
const importRemoteAsset = async ({ compositionFile, compositionId, destinationDimensions, dropPosition, fps, from, url, }) => {
|
|
673
|
+
var _a;
|
|
589
674
|
try {
|
|
590
675
|
const { assetPath, created, element } = await downloadRemoteAsset(url);
|
|
591
676
|
if (created) {
|
|
@@ -595,13 +680,23 @@ const importRemoteAsset = async ({ compositionFile, compositionId, destinationDi
|
|
|
595
680
|
(0, NotificationCenter_1.showNotification)('Cannot add remote asset: Unsupported asset type', 3000);
|
|
596
681
|
return;
|
|
597
682
|
}
|
|
683
|
+
const metadata = await getStaticAssetMetadataOrNull(assetPath, element.assetType);
|
|
684
|
+
const dimensions = (_a = element.dimensions) !== null && _a !== void 0 ? _a : metadata.dimensions;
|
|
598
685
|
const inserted = await insertCompositionElement({
|
|
599
686
|
compositionFile,
|
|
600
687
|
compositionId,
|
|
688
|
+
from,
|
|
601
689
|
element: {
|
|
602
690
|
...element,
|
|
691
|
+
dimensions,
|
|
692
|
+
durationInFrames: assetTypeHasDuration(element.assetType)
|
|
693
|
+
? (0, exports.getDurationInFrames)({
|
|
694
|
+
durationInSeconds: metadata.durationInSeconds,
|
|
695
|
+
fps,
|
|
696
|
+
})
|
|
697
|
+
: null,
|
|
603
698
|
position: (0, exports.getAssetPositionForDrop)({
|
|
604
|
-
assetDimensions:
|
|
699
|
+
assetDimensions: dimensions,
|
|
605
700
|
destinationDimensions,
|
|
606
701
|
dropPosition,
|
|
607
702
|
}),
|
|
@@ -617,24 +712,30 @@ const importRemoteAsset = async ({ compositionFile, compositionId, destinationDi
|
|
|
617
712
|
}
|
|
618
713
|
};
|
|
619
714
|
exports.importRemoteAsset = importRemoteAsset;
|
|
620
|
-
const insertRemoteAudio = async ({ compositionFile, compositionId, url, }) => {
|
|
715
|
+
const insertRemoteAudio = async ({ compositionFile, compositionId, fps, from, url, }) => {
|
|
621
716
|
if (!(0, studio_shared_1.isUrl)(url)) {
|
|
622
717
|
(0, NotificationCenter_1.showNotification)('Cannot add sound effect: Unsupported URL', 3000);
|
|
623
718
|
return;
|
|
624
719
|
}
|
|
625
|
-
const element = {
|
|
626
|
-
type: 'asset',
|
|
627
|
-
assetType: 'audio',
|
|
628
|
-
src: url,
|
|
629
|
-
srcType: 'remote',
|
|
630
|
-
dimensions: null,
|
|
631
|
-
position: null,
|
|
632
|
-
};
|
|
633
720
|
try {
|
|
721
|
+
const metadata = await getMediaAssetMetadata(url);
|
|
722
|
+
const element = {
|
|
723
|
+
type: 'asset',
|
|
724
|
+
assetType: 'audio',
|
|
725
|
+
src: url,
|
|
726
|
+
srcType: 'remote',
|
|
727
|
+
dimensions: null,
|
|
728
|
+
durationInFrames: (0, exports.getDurationInFrames)({
|
|
729
|
+
durationInSeconds: metadata.durationInSeconds,
|
|
730
|
+
fps,
|
|
731
|
+
}),
|
|
732
|
+
position: null,
|
|
733
|
+
};
|
|
634
734
|
const inserted = await insertCompositionElement({
|
|
635
735
|
compositionFile,
|
|
636
736
|
compositionId,
|
|
637
737
|
element,
|
|
738
|
+
from,
|
|
638
739
|
});
|
|
639
740
|
if (!inserted) {
|
|
640
741
|
return;
|
|
@@ -646,7 +747,7 @@ const insertRemoteAudio = async ({ compositionFile, compositionId, url, }) => {
|
|
|
646
747
|
}
|
|
647
748
|
};
|
|
648
749
|
exports.insertRemoteAudio = insertRemoteAudio;
|
|
649
|
-
const insertExistingAssets = async ({ assetPaths, compositionFile, compositionId, destinationDimensions, dropPosition, }) => {
|
|
750
|
+
const insertExistingAssets = async ({ assetPaths, compositionFile, compositionId, destinationDimensions, dropPosition, fps, from, }) => {
|
|
650
751
|
var _a;
|
|
651
752
|
if (assetPaths.length === 0) {
|
|
652
753
|
return;
|
|
@@ -660,13 +761,21 @@ const insertExistingAssets = async ({ assetPaths, compositionFile, compositionId
|
|
|
660
761
|
unsupportedFiles.push(assetPath);
|
|
661
762
|
continue;
|
|
662
763
|
}
|
|
663
|
-
const
|
|
764
|
+
const metadata = await getStaticAssetMetadataOrNull(assetPath, element.assetType);
|
|
765
|
+
const dimensions = (_a = element.dimensions) !== null && _a !== void 0 ? _a : metadata.dimensions;
|
|
664
766
|
const inserted = await insertCompositionElement({
|
|
665
767
|
compositionFile,
|
|
666
768
|
compositionId,
|
|
769
|
+
from,
|
|
667
770
|
element: {
|
|
668
771
|
...element,
|
|
669
772
|
dimensions,
|
|
773
|
+
durationInFrames: assetTypeHasDuration(element.assetType)
|
|
774
|
+
? (0, exports.getDurationInFrames)({
|
|
775
|
+
durationInSeconds: metadata.durationInSeconds,
|
|
776
|
+
fps,
|
|
777
|
+
})
|
|
778
|
+
: null,
|
|
670
779
|
position: (0, exports.getAssetPositionForDrop)({
|
|
671
780
|
assetDimensions: dimensions,
|
|
672
781
|
destinationDimensions,
|
|
@@ -687,11 +796,12 @@ const insertExistingAssets = async ({ assetPaths, compositionFile, compositionId
|
|
|
687
796
|
}
|
|
688
797
|
};
|
|
689
798
|
exports.insertExistingAssets = insertExistingAssets;
|
|
690
|
-
const insertComponent = async ({ component, compositionFile, compositionId, dropPosition, }) => {
|
|
799
|
+
const insertComponent = async ({ component, compositionFile, compositionId, dropPosition, from, }) => {
|
|
691
800
|
try {
|
|
692
801
|
const inserted = await insertCompositionElement({
|
|
693
802
|
compositionFile,
|
|
694
803
|
compositionId,
|
|
804
|
+
from,
|
|
695
805
|
element: {
|
|
696
806
|
type: 'component',
|
|
697
807
|
componentName: component.componentName,
|
|
@@ -721,7 +831,7 @@ const serializeResolvedPropsForSourceCode = (props) => {
|
|
|
721
831
|
staticBase: window.remotion_staticBase,
|
|
722
832
|
}).serializedString;
|
|
723
833
|
};
|
|
724
|
-
const insertComposition = async ({ composition, compositionFile, compositionId, destinationDimensions, dropPosition, }) => {
|
|
834
|
+
const insertComposition = async ({ composition, compositionFile, compositionId, destinationDimensions, dropPosition, from, }) => {
|
|
725
835
|
if (composition.compositionId === compositionId) {
|
|
726
836
|
(0, NotificationCenter_1.showNotification)('Cannot add a composition to itself', 3000);
|
|
727
837
|
return;
|
|
@@ -743,6 +853,7 @@ const insertComposition = async ({ composition, compositionFile, compositionId,
|
|
|
743
853
|
const inserted = await insertCompositionElement({
|
|
744
854
|
compositionFile,
|
|
745
855
|
compositionId,
|
|
856
|
+
from,
|
|
746
857
|
element: {
|
|
747
858
|
type: 'composition',
|
|
748
859
|
compositionId: composition.compositionId,
|
|
@@ -768,13 +879,14 @@ const insertComposition = async ({ composition, compositionFile, compositionId,
|
|
|
768
879
|
}
|
|
769
880
|
};
|
|
770
881
|
exports.insertComposition = insertComposition;
|
|
771
|
-
const insertElement = async ({ compositionFile, compositionId, dropPosition, element, }) => {
|
|
882
|
+
const insertElement = async ({ compositionFile, compositionId, dropPosition, element, from, }) => {
|
|
772
883
|
try {
|
|
773
884
|
await (0, install_required_package_1.installRequiredPackages)(element.dependencies);
|
|
774
885
|
const response = await (0, call_api_1.callApi)('/api/insert-element', {
|
|
775
886
|
compositionFile,
|
|
776
887
|
compositionId,
|
|
777
888
|
element,
|
|
889
|
+
from,
|
|
778
890
|
position: (0, exports.getElementPositionForDrop)({
|
|
779
891
|
dimensions: element.dimensions,
|
|
780
892
|
dropPosition,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CanUpdateSequencePropStatus, DragOverrideValue, GetDragOverrides, SequencePropsSubscriptionKey, InteractivitySchema } from 'remotion';
|
|
2
2
|
import { type OutlinePoint } from './selected-outline-geometry';
|
|
3
|
-
import type { SelectedOutlineDragState, SelectedOutlineRotationDragState, SelectedOutlineRotationDragTarget, SelectedOutlineScaleDragState, SelectedOutlineScaleDragTarget, SelectedOutlineDragTarget } from './selected-outline-types';
|
|
3
|
+
import type { SelectedOutlineDragState, SelectedOutlineRotationDragState, SelectedOutlineRotationDragTarget, SelectedOutlineScaleDragState, SelectedOutlineScaleDragTarget, SelectedOutlineDragTarget, SelectedOutlineTransformOriginDragTarget } from './selected-outline-types';
|
|
4
4
|
import { type UvCoordinate } from './selected-outline-uv';
|
|
5
|
+
import type { AddSequenceKeyframeChange } from './Timeline/call-add-keyframe';
|
|
5
6
|
import type { SaveSequencePropChange } from './Timeline/save-sequence-prop';
|
|
6
7
|
export declare const getSelectedOutlineActiveSchema: ({ schema, currentRuntimeValueDotNotation, dragOverrides, propStatus, frame, }: {
|
|
7
8
|
readonly schema: InteractivitySchema;
|
|
@@ -126,6 +127,15 @@ export declare const compensateTranslateForTransformOrigin: ({ startTranslate, d
|
|
|
126
127
|
readonly rotate: number;
|
|
127
128
|
readonly scale: readonly [number, number];
|
|
128
129
|
}) => readonly [number, number];
|
|
130
|
+
export declare const getSelectedOutlineTransformOriginDragChanges: ({ target, startTranslate, origin, translate, }: {
|
|
131
|
+
readonly target: SelectedOutlineTransformOriginDragTarget;
|
|
132
|
+
readonly startTranslate: readonly [number, number];
|
|
133
|
+
readonly origin: string;
|
|
134
|
+
readonly translate: string;
|
|
135
|
+
}) => {
|
|
136
|
+
readonly staticChanges: SaveSequencePropChange[];
|
|
137
|
+
readonly keyframedChanges: AddSequenceKeyframeChange[];
|
|
138
|
+
};
|
|
129
139
|
export declare const uvsEqual: (left: readonly [number, number], right: readonly [number, number]) => boolean;
|
|
130
140
|
export type SelectedOutlineTransformOriginLockedAxis = 'x' | 'y' | null;
|
|
131
141
|
export declare const getSelectedOutlineTransformOriginLockedAxis: ({ axisLocked, dimensions, startUv, uv, }: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.snapSelectedOutlineTransformOriginUv = exports.selectedOutlineTransformOriginSnapThresholdPx = exports.snapSelectedOutlineUv = exports.selectedOutlineUvSnapThresholdPx = exports.applySelectedOutlineTransformOriginAxisLock = exports.getSelectedOutlineTransformOriginLockedAxis = exports.uvsEqual = exports.compensateTranslateForTransformOrigin = exports.parseCssRotationToRadians = exports.clearSelectedOutlineRotationDragOverrides = exports.clearSelectedOutlineScaleDragOverrides = exports.getSelectedOutlineKeyboardNudgeDirection = exports.clearSelectedOutlineDragOverrides = exports.getSelectedOutlineRotationDragChanges = exports.snapSelectedOutlineRotationDeltaDegrees = exports.selectedOutlineRotationSnapStepDegrees = exports.getSelectedOutlineRotationDragValues = exports.getSelectedOutlineRotationDragStates = exports.getSelectedOutlineScaleDragChanges = exports.getSelectedOutlineScaleDragValues = exports.getSelectedOutlineScaleDragStates = exports.getSelectedOutlineScaleEdgeInfo = exports.getSelectedOutlineKeyboardNudgeDeltas = exports.getSelectedOutlineKeyboardNudgeDelta = exports.getSelectedOutlineDragChanges = exports.isSelectedOutlineDragPastThreshold = exports.applySelectedOutlineDragAxisLock = exports.getSelectedOutlineDragValues = exports.getSelectedOutlineDragStates = exports.getSelectedOutlineActiveSchema = void 0;
|
|
3
|
+
exports.snapSelectedOutlineTransformOriginUv = exports.selectedOutlineTransformOriginSnapThresholdPx = exports.snapSelectedOutlineUv = exports.selectedOutlineUvSnapThresholdPx = exports.applySelectedOutlineTransformOriginAxisLock = exports.getSelectedOutlineTransformOriginLockedAxis = exports.uvsEqual = exports.getSelectedOutlineTransformOriginDragChanges = exports.compensateTranslateForTransformOrigin = exports.parseCssRotationToRadians = exports.clearSelectedOutlineRotationDragOverrides = exports.clearSelectedOutlineScaleDragOverrides = exports.getSelectedOutlineKeyboardNudgeDirection = exports.clearSelectedOutlineDragOverrides = exports.getSelectedOutlineRotationDragChanges = exports.snapSelectedOutlineRotationDeltaDegrees = exports.selectedOutlineRotationSnapStepDegrees = exports.getSelectedOutlineRotationDragValues = exports.getSelectedOutlineRotationDragStates = exports.getSelectedOutlineScaleDragChanges = exports.getSelectedOutlineScaleDragValues = exports.getSelectedOutlineScaleDragStates = exports.getSelectedOutlineScaleEdgeInfo = exports.getSelectedOutlineKeyboardNudgeDeltas = exports.getSelectedOutlineKeyboardNudgeDelta = exports.getSelectedOutlineDragChanges = exports.isSelectedOutlineDragPastThreshold = exports.applySelectedOutlineDragAxisLock = exports.getSelectedOutlineDragValues = exports.getSelectedOutlineDragStates = exports.getSelectedOutlineActiveSchema = void 0;
|
|
4
4
|
const remotion_1 = require("remotion");
|
|
5
5
|
const no_react_1 = require("remotion/no-react");
|
|
6
6
|
const selected_outline_geometry_1 = require("./selected-outline-geometry");
|
|
@@ -446,6 +446,79 @@ const compensateTranslateForTransformOrigin = ({ startTranslate, deltaOrigin, ro
|
|
|
446
446
|
return [startTranslate[0] - compensationX, startTranslate[1] - compensationY];
|
|
447
447
|
};
|
|
448
448
|
exports.compensateTranslateForTransformOrigin = compensateTranslateForTransformOrigin;
|
|
449
|
+
const getSelectedOutlineTransformOriginDragChanges = ({ target, startTranslate, origin, translate, }) => {
|
|
450
|
+
const staticChanges = [];
|
|
451
|
+
const keyframedChanges = [];
|
|
452
|
+
const originChanged = origin !== target.originValue;
|
|
453
|
+
const translateChanged = translate !== target.translateValue;
|
|
454
|
+
if (originChanged) {
|
|
455
|
+
if (target.originPropStatus.status === 'keyframed') {
|
|
456
|
+
keyframedChanges.push({
|
|
457
|
+
fileName: target.nodePath.absolutePath,
|
|
458
|
+
nodePath: target.nodePath,
|
|
459
|
+
fieldKey: selected_outline_types_1.transformOriginFieldKey,
|
|
460
|
+
sourceFrame: target.sourceFrame,
|
|
461
|
+
value: origin,
|
|
462
|
+
schema: target.schema,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
staticChanges.push({
|
|
467
|
+
fileName: target.nodePath.absolutePath,
|
|
468
|
+
nodePath: target.nodePath,
|
|
469
|
+
fieldKey: selected_outline_types_1.transformOriginFieldKey,
|
|
470
|
+
value: origin,
|
|
471
|
+
defaultValue: target.originDefault === undefined
|
|
472
|
+
? null
|
|
473
|
+
: JSON.stringify(target.originDefault),
|
|
474
|
+
schema: target.schema,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (!translateChanged) {
|
|
479
|
+
return { staticChanges, keyframedChanges };
|
|
480
|
+
}
|
|
481
|
+
if (target.translatePropStatus.status === 'static') {
|
|
482
|
+
staticChanges.push({
|
|
483
|
+
fileName: target.nodePath.absolutePath,
|
|
484
|
+
nodePath: target.nodePath,
|
|
485
|
+
fieldKey: selected_outline_types_1.translateFieldKey,
|
|
486
|
+
value: translate,
|
|
487
|
+
defaultValue: target.translateDefault === undefined
|
|
488
|
+
? null
|
|
489
|
+
: JSON.stringify(target.translateDefault),
|
|
490
|
+
schema: target.schema,
|
|
491
|
+
});
|
|
492
|
+
return { staticChanges, keyframedChanges };
|
|
493
|
+
}
|
|
494
|
+
if (target.originPropStatus.status === 'keyframed') {
|
|
495
|
+
keyframedChanges.push({
|
|
496
|
+
fileName: target.nodePath.absolutePath,
|
|
497
|
+
nodePath: target.nodePath,
|
|
498
|
+
fieldKey: selected_outline_types_1.translateFieldKey,
|
|
499
|
+
sourceFrame: target.sourceFrame,
|
|
500
|
+
value: translate,
|
|
501
|
+
schema: target.schema,
|
|
502
|
+
});
|
|
503
|
+
return { staticChanges, keyframedChanges };
|
|
504
|
+
}
|
|
505
|
+
const nextTranslate = (0, timeline_translate_utils_1.parseTranslate)(translate);
|
|
506
|
+
const deltaTranslateX = nextTranslate[0] - startTranslate[0];
|
|
507
|
+
const deltaTranslateY = nextTranslate[1] - startTranslate[1];
|
|
508
|
+
for (const keyframe of target.translatePropStatus.keyframes) {
|
|
509
|
+
const keyframeTranslate = (0, timeline_translate_utils_1.parseTranslate)(String(keyframe.value));
|
|
510
|
+
keyframedChanges.push({
|
|
511
|
+
fileName: target.nodePath.absolutePath,
|
|
512
|
+
nodePath: target.nodePath,
|
|
513
|
+
fieldKey: selected_outline_types_1.translateFieldKey,
|
|
514
|
+
sourceFrame: keyframe.frame,
|
|
515
|
+
value: (0, timeline_translate_utils_1.serializeTranslate)(keyframeTranslate[0] + deltaTranslateX, keyframeTranslate[1] + deltaTranslateY),
|
|
516
|
+
schema: target.schema,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
return { staticChanges, keyframedChanges };
|
|
520
|
+
};
|
|
521
|
+
exports.getSelectedOutlineTransformOriginDragChanges = getSelectedOutlineTransformOriginDragChanges;
|
|
449
522
|
const uvsEqual = (left, right) => Math.abs(left[0] - right[0]) < 0.000001 &&
|
|
450
523
|
Math.abs(left[1] - right[1]) < 0.000001;
|
|
451
524
|
exports.uvsEqual = uvsEqual;
|