@remotion/studio 4.0.494 → 4.0.495

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 (96) hide show
  1. package/dist/api/get-static-files.d.ts +1 -1
  2. package/dist/components/AssetFileIcon.d.ts +7 -0
  3. package/dist/components/AssetFileIcon.js +24 -0
  4. package/dist/components/AssetSelectorItem.js +13 -7
  5. package/dist/components/Canvas.js +191 -36
  6. package/dist/components/CompositionSelectorItem.js +15 -8
  7. package/dist/components/CurrentAsset.d.ts +1 -0
  8. package/dist/components/CurrentAsset.js +17 -1
  9. package/dist/components/Editor.js +2 -4
  10. package/dist/components/InspectorPanel/AssetInspector.d.ts +4 -0
  11. package/dist/components/InspectorPanel/AssetInspector.js +11 -0
  12. package/dist/components/InspectorPanel/{DefaultInspector.d.ts → CompositionInspector.d.ts} +2 -2
  13. package/dist/components/InspectorPanel/CompositionInspector.js +114 -0
  14. package/dist/components/InspectorPanel/CompositionInspectorHeader.d.ts +1 -0
  15. package/dist/components/{CurrentComposition.js → InspectorPanel/CompositionInspectorHeader.js} +16 -16
  16. package/dist/components/InspectorPanel/{CompositionDimensions.d.ts → CompositionMetadata.d.ts} +1 -1
  17. package/dist/components/InspectorPanel/{CompositionDimensions.js → CompositionMetadata.js} +17 -8
  18. package/dist/components/InspectorPanel/ConnectedCompositionsSection.js +2 -2
  19. package/dist/components/InspectorPanel/EasingInspector.js +3 -5
  20. package/dist/components/InspectorPanel/KeyframeInspector.js +2 -2
  21. package/dist/components/InspectorPanel/SequenceSelectionInspector.js +34 -1
  22. package/dist/components/InspectorPanel/common.d.ts +8 -0
  23. package/dist/components/InspectorPanel/common.js +31 -8
  24. package/dist/components/InspectorPanel/styles.d.ts +5 -3
  25. package/dist/components/InspectorPanel/styles.js +13 -4
  26. package/dist/components/InspectorPanel/use-composition-actions.d.ts +8 -0
  27. package/dist/components/InspectorPanel/use-composition-actions.js +114 -0
  28. package/dist/components/InspectorPanel.js +11 -2
  29. package/dist/components/InspectorSequenceSection.d.ts +0 -1
  30. package/dist/components/InspectorSequenceSection.js +9 -48
  31. package/dist/components/Modals.js +2 -1
  32. package/dist/components/NewComposition/InputDragger.d.ts +6 -0
  33. package/dist/components/NewComposition/InputDragger.js +26 -13
  34. package/dist/components/NewComposition/NewComposition.js +8 -1
  35. package/dist/components/NewComposition/ValidationMessage.d.ts +1 -1
  36. package/dist/components/Preview.js +15 -7
  37. package/dist/components/RenderModal/RenderModalOutputName.js +34 -1
  38. package/dist/components/SelectedOutlineOverlay.js +1 -0
  39. package/dist/components/SvgImportDialog.d.ts +7 -0
  40. package/dist/components/SvgImportDialog.js +103 -0
  41. package/dist/components/Timeline/Timeline.js +1 -0
  42. package/dist/components/Timeline/TimelineClipboardKeybindings.js +8 -1
  43. package/dist/components/Timeline/TimelineList.js +9 -4
  44. package/dist/components/Timeline/TimelineSequenceItem.d.ts +2 -1
  45. package/dist/components/Timeline/TimelineSequenceItem.js +19 -11
  46. package/dist/components/Timeline/nest-timeline-tracks.d.ts +8 -0
  47. package/dist/components/Timeline/nest-timeline-tracks.js +25 -0
  48. package/dist/components/Timeline/timeline-scroll-logic.d.ts +8 -4
  49. package/dist/components/Timeline/timeline-scroll-logic.js +29 -15
  50. package/dist/components/import-assets.d.ts +17 -1
  51. package/dist/components/import-assets.js +96 -11
  52. package/dist/components/layout.d.ts +1 -0
  53. package/dist/components/layout.js +2 -1
  54. package/dist/components/selected-outline-measurement.d.ts +2 -1
  55. package/dist/components/selected-outline-measurement.js +3 -1
  56. package/dist/esm/{chunk-tdncqycp.js → chunk-784jbkzs.js} +8428 -7246
  57. package/dist/esm/internals.mjs +8428 -7246
  58. package/dist/esm/previewEntry.mjs +8577 -7395
  59. package/dist/esm/renderEntry.mjs +1 -1
  60. package/dist/helpers/client-id.js +2 -1
  61. package/dist/helpers/clipboard-figma.d.ts +4 -0
  62. package/dist/helpers/clipboard-figma.js +41 -0
  63. package/dist/helpers/clipboard-images.d.ts +10 -0
  64. package/dist/helpers/clipboard-images.js +77 -0
  65. package/dist/helpers/clipboard-svg.d.ts +3 -0
  66. package/dist/helpers/clipboard-svg.js +47 -0
  67. package/dist/helpers/get-effective-translation.d.ts +2 -1
  68. package/dist/helpers/get-effective-translation.js +15 -7
  69. package/dist/helpers/get-preview-file-type.d.ts +1 -1
  70. package/dist/helpers/get-preview-file-type.js +5 -1
  71. package/dist/helpers/inject-css.js +9 -0
  72. package/dist/helpers/studio-fit-padding.d.ts +41 -0
  73. package/dist/helpers/studio-fit-padding.js +64 -0
  74. package/dist/helpers/use-image-metadata.d.ts +8 -0
  75. package/dist/helpers/use-image-metadata.js +82 -0
  76. package/dist/helpers/use-studio-canvas-dimensions.js +2 -2
  77. package/dist/icons/audio.d.ts +3 -0
  78. package/dist/icons/audio.js +3 -1
  79. package/dist/icons/font.d.ts +4 -0
  80. package/dist/icons/font.js +8 -0
  81. package/dist/icons/frame.d.ts +3 -1
  82. package/dist/icons/frame.js +1 -1
  83. package/dist/icons/json.d.ts +4 -0
  84. package/dist/icons/json.js +8 -0
  85. package/dist/icons/magnet.js +1 -1
  86. package/dist/icons/scissors.d.ts +5 -0
  87. package/dist/icons/scissors.js +8 -0
  88. package/dist/icons/solid.d.ts +5 -0
  89. package/dist/icons/solid.js +8 -0
  90. package/dist/icons/video.d.ts +3 -0
  91. package/dist/icons/video.js +5 -1
  92. package/dist/state/modals.d.ts +8 -1
  93. package/dist/state/timeline-zoom.js +12 -11
  94. package/package.json +11 -11
  95. package/dist/components/CurrentComposition.d.ts +0 -2
  96. package/dist/components/InspectorPanel/DefaultInspector.js +0 -97
@@ -212,7 +212,7 @@ var renderContent = (Root) => {
212
212
  renderToDOM(/* @__PURE__ */ jsx("div", {
213
213
  children: /* @__PURE__ */ jsx(DelayedSpinner, {})
214
214
  }));
215
- import("./chunk-tdncqycp.js").then(({ StudioInternals }) => {
215
+ import("./chunk-784jbkzs.js").then(({ StudioInternals }) => {
216
216
  window.remotion_isStudio = true;
217
217
  window.remotion_isReadOnlyStudio = true;
218
218
  window.remotion_inputProps = "{}";
@@ -71,7 +71,8 @@ const PreviewServerConnection = ({ children, readOnlyStudio }) => {
71
71
  const handleEvent = (newEvent) => {
72
72
  var _a, _b;
73
73
  if (newEvent.type === 'new-input-props' ||
74
- newEvent.type === 'new-env-variables') {
74
+ newEvent.type === 'new-env-variables' ||
75
+ newEvent.type === 'config-file-changed') {
75
76
  (0, url_state_1.reloadUrl)();
76
77
  }
77
78
  if (newEvent.type === 'init') {
@@ -0,0 +1,4 @@
1
+ export declare const getClipboardFigmaHtml: (clipboardData: DataTransfer) => string | null;
2
+ export declare const hasClipboardFigmaPayload: (clipboardData: DataTransfer) => boolean;
3
+ export declare const formatFigmaClipboardError: (reason: string) => string;
4
+ export declare const formatFigmaClipboardErrorNotification: (reason: string) => string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatFigmaClipboardErrorNotification = exports.formatFigmaClipboardError = exports.hasClipboardFigmaPayload = exports.getClipboardFigmaHtml = void 0;
4
+ const figmaMetaStart = '<!--(figmeta)';
5
+ const figmaMetaEnd = '(/figmeta)-->';
6
+ const figmaDataStart = '<!--(figma)';
7
+ const figmaDataEnd = '(/figma)-->';
8
+ const hasSection = ({ end, html, start, }) => {
9
+ const startIndex = html.indexOf(start);
10
+ return (startIndex !== -1 && html.indexOf(end, startIndex + start.length) !== -1);
11
+ };
12
+ const getClipboardFigmaHtml = (clipboardData) => {
13
+ const html = clipboardData.getData('text/html');
14
+ if (!hasSection({ end: figmaMetaEnd, html, start: figmaMetaStart }) ||
15
+ !hasSection({ end: figmaDataEnd, html, start: figmaDataStart })) {
16
+ return null;
17
+ }
18
+ return html;
19
+ };
20
+ exports.getClipboardFigmaHtml = getClipboardFigmaHtml;
21
+ const hasClipboardFigmaPayload = (clipboardData) => {
22
+ return (0, exports.getClipboardFigmaHtml)(clipboardData) !== null;
23
+ };
24
+ exports.hasClipboardFigmaPayload = hasClipboardFigmaPayload;
25
+ const formatFigmaClipboardError = (reason) => {
26
+ const withoutPrefix = reason
27
+ .replace(/^(?:Cannot|Could not) import Figma selection:\s*/i, '')
28
+ .trim();
29
+ const message = withoutPrefix.toLowerCase() === 'clipboard scene is incomplete'
30
+ ? 'Pasting images from Figma is not supported'
31
+ : withoutPrefix;
32
+ if (/[.!?]$/.test(message)) {
33
+ return message;
34
+ }
35
+ return `${message}.`;
36
+ };
37
+ exports.formatFigmaClipboardError = formatFigmaClipboardError;
38
+ const formatFigmaClipboardErrorNotification = (reason) => {
39
+ return `${(0, exports.formatFigmaClipboardError)(reason)} Try “Copy as SVG” in Figma and paste again.`;
40
+ };
41
+ exports.formatFigmaClipboardErrorNotification = formatFigmaClipboardErrorNotification;
@@ -0,0 +1,10 @@
1
+ export declare const hasClipboardImage: (clipboardData: DataTransfer) => boolean;
2
+ export declare const getUniqueClipboardImageName: ({ existingFileNames, fileName, mimeType, }: {
3
+ existingFileNames: Set<string>;
4
+ fileName: string;
5
+ mimeType: string;
6
+ }) => string;
7
+ export declare const getClipboardImageFiles: ({ clipboardData, existingFileNames, }: {
8
+ clipboardData: DataTransfer;
9
+ existingFileNames: string[];
10
+ }) => File[];
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getClipboardImageFiles = exports.getUniqueClipboardImageName = exports.hasClipboardImage = void 0;
4
+ const getClipboardFiles = (clipboardData) => {
5
+ const imageItems = Array.from(clipboardData.items).filter((item) => item.kind === 'file' && item.type.startsWith('image/'));
6
+ if (imageItems.length > 0) {
7
+ const files = imageItems
8
+ .map((item) => item.getAsFile())
9
+ .filter((file) => file !== null);
10
+ if (files.length > 0) {
11
+ return files;
12
+ }
13
+ }
14
+ return Array.from(clipboardData.files).filter((file) => file.type.startsWith('image/'));
15
+ };
16
+ const hasClipboardImage = (clipboardData) => {
17
+ return (Array.from(clipboardData.items).some((item) => item.kind === 'file' && item.type.startsWith('image/')) ||
18
+ Array.from(clipboardData.files).some((file) => file.type.startsWith('image/')));
19
+ };
20
+ exports.hasClipboardImage = hasClipboardImage;
21
+ const getExtensionForMimeType = (mimeType) => {
22
+ switch (mimeType) {
23
+ case 'image/jpeg':
24
+ return 'jpg';
25
+ case 'image/svg+xml':
26
+ return 'svg';
27
+ default:
28
+ return mimeType.startsWith('image/')
29
+ ? mimeType.slice('image/'.length)
30
+ : 'png';
31
+ }
32
+ };
33
+ const getNameParts = ({ fileName, mimeType, }) => {
34
+ const trimmedName = fileName.trim();
35
+ const lastDot = trimmedName.lastIndexOf('.');
36
+ if (lastDot > 0 && lastDot < trimmedName.length - 1) {
37
+ return {
38
+ base: trimmedName.slice(0, lastDot),
39
+ extension: trimmedName.slice(lastDot + 1),
40
+ };
41
+ }
42
+ return {
43
+ base: 'pasted-image',
44
+ extension: getExtensionForMimeType(mimeType),
45
+ };
46
+ };
47
+ const getUniqueClipboardImageName = ({ existingFileNames, fileName, mimeType, }) => {
48
+ const { base, extension } = getNameParts({ fileName, mimeType });
49
+ let candidate = `${base}.${extension}`;
50
+ let suffix = 1;
51
+ while (existingFileNames.has(candidate)) {
52
+ candidate = `${base}-${suffix}.${extension}`;
53
+ suffix++;
54
+ }
55
+ return candidate;
56
+ };
57
+ exports.getUniqueClipboardImageName = getUniqueClipboardImageName;
58
+ const getClipboardImageFiles = ({ clipboardData, existingFileNames, }) => {
59
+ const usedNames = new Set(existingFileNames);
60
+ return getClipboardFiles(clipboardData).map((file) => {
61
+ var _a;
62
+ const candidate = (0, exports.getUniqueClipboardImageName)({
63
+ existingFileNames: usedNames,
64
+ fileName: (_a = file.name) !== null && _a !== void 0 ? _a : '',
65
+ mimeType: file.type,
66
+ });
67
+ usedNames.add(candidate);
68
+ if (candidate === file.name) {
69
+ return file;
70
+ }
71
+ return new File([file.slice()], candidate, {
72
+ type: file.type,
73
+ lastModified: file.lastModified,
74
+ });
75
+ });
76
+ };
77
+ exports.getClipboardImageFiles = getClipboardImageFiles;
@@ -0,0 +1,3 @@
1
+ export declare const extractSvgMarkup: (value: string) => string | null;
2
+ export declare const getClipboardSvgMarkup: (clipboardData: DataTransfer) => string | null;
3
+ export declare const hasClipboardSvgMarkup: (clipboardData: DataTransfer) => boolean;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasClipboardSvgMarkup = exports.getClipboardSvgMarkup = exports.extractSvgMarkup = void 0;
4
+ const svgOpeningTag = /^<svg(?:\s|>)/i;
5
+ const removeSvgPreamble = (value) => {
6
+ let remaining = value.trim();
7
+ while (true) {
8
+ const withoutPreamble = remaining
9
+ .replace(/^<\?xml[\s\S]*?\?>\s*/i, '')
10
+ .replace(/^<!doctype[\s\S]*?>\s*/i, '')
11
+ .replace(/^<!--[\s\S]*?-->\s*/, '');
12
+ if (withoutPreamble === remaining) {
13
+ return remaining;
14
+ }
15
+ remaining = withoutPreamble;
16
+ }
17
+ };
18
+ const extractSvgMarkup = (value) => {
19
+ const withoutPreamble = removeSvgPreamble(value);
20
+ if (!svgOpeningTag.test(withoutPreamble)) {
21
+ return null;
22
+ }
23
+ const closingTagIndex = withoutPreamble.toLowerCase().lastIndexOf('</svg>');
24
+ if (closingTagIndex === -1) {
25
+ return null;
26
+ }
27
+ const afterClosingTag = withoutPreamble.slice(closingTagIndex + '</svg>'.length);
28
+ if (afterClosingTag.trim() !== '') {
29
+ return null;
30
+ }
31
+ return withoutPreamble.slice(0, closingTagIndex + '</svg>'.length);
32
+ };
33
+ exports.extractSvgMarkup = extractSvgMarkup;
34
+ const getClipboardSvgMarkup = (clipboardData) => {
35
+ for (const mimeType of ['text/plain', 'text/html']) {
36
+ const markup = (0, exports.extractSvgMarkup)(clipboardData.getData(mimeType));
37
+ if (markup !== null) {
38
+ return markup;
39
+ }
40
+ }
41
+ return null;
42
+ };
43
+ exports.getClipboardSvgMarkup = getClipboardSvgMarkup;
44
+ const hasClipboardSvgMarkup = (clipboardData) => {
45
+ return (0, exports.getClipboardSvgMarkup)(clipboardData) !== null;
46
+ };
47
+ exports.hasClipboardSvgMarkup = hasClipboardSvgMarkup;
@@ -25,7 +25,8 @@ export declare const getCenterPointWhileScrolling: ({ size, clientX, clientY, co
25
25
  centerX: number;
26
26
  centerY: number;
27
27
  };
28
- export declare const applyZoomAroundFocalPoint: ({ canvasSize, contentDimensions, previewSizeBefore, oldNumericSize, newNumericSize, clientX, clientY, }: {
28
+ export declare const applyZoomAroundFocalPoint: ({ addFitPadding, canvasSize, contentDimensions, previewSizeBefore, oldNumericSize, newNumericSize, clientX, clientY, }: {
29
+ readonly addFitPadding: boolean;
29
30
  readonly canvasSize: Size;
30
31
  readonly contentDimensions: {
31
32
  width: number;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyZoomAroundFocalPoint = exports.getCenterPointWhileScrolling = exports.getEffectiveTranslation = void 0;
4
4
  const remotion_1 = require("remotion");
5
5
  const smooth_zoom_1 = require("./smooth-zoom");
6
+ const studio_fit_padding_1 = require("./studio-fit-padding");
6
7
  const getEffectiveXTranslation = ({ canvasSize, scale, compositionWidth, translation, }) => {
7
8
  const maxTranslation = Math.abs(canvasSize.width / 2 +
8
9
  (scale * compositionWidth) / 2 -
@@ -45,13 +46,20 @@ const getCenterPointWhileScrolling = ({ size, clientX, clientY, compositionWidth
45
46
  };
46
47
  };
47
48
  exports.getCenterPointWhileScrolling = getCenterPointWhileScrolling;
48
- const applyZoomAroundFocalPoint = ({ canvasSize, contentDimensions, previewSizeBefore, oldNumericSize, newNumericSize, clientX, clientY, }) => {
49
- const scale = remotion_1.Internals.calculateScale({
50
- canvasSize,
51
- compositionHeight: contentDimensions.height,
52
- compositionWidth: contentDimensions.width,
53
- previewSize: previewSizeBefore.size,
54
- });
49
+ const applyZoomAroundFocalPoint = ({ addFitPadding, canvasSize, contentDimensions, previewSizeBefore, oldNumericSize, newNumericSize, clientX, clientY, }) => {
50
+ const scale = addFitPadding
51
+ ? (0, studio_fit_padding_1.calculateStudioScale)({
52
+ canvasSize,
53
+ compositionHeight: contentDimensions.height,
54
+ compositionWidth: contentDimensions.width,
55
+ previewSize: previewSizeBefore.size,
56
+ })
57
+ : remotion_1.Internals.calculateScale({
58
+ canvasSize,
59
+ compositionHeight: contentDimensions.height,
60
+ compositionWidth: contentDimensions.width,
61
+ previewSize: previewSizeBefore.size,
62
+ });
55
63
  const clampedNew = Math.min(smooth_zoom_1.MAX_ZOOM, Math.max(smooth_zoom_1.MIN_ZOOM, newNumericSize));
56
64
  if (clampedNew === oldNumericSize) {
57
65
  return previewSizeBefore;
@@ -1,2 +1,2 @@
1
- export type AssetFileType = 'audio' | 'video' | 'image' | 'json' | 'txt' | 'other';
1
+ export type AssetFileType = 'audio' | 'font' | 'video' | 'image' | 'json' | 'txt' | 'other';
2
2
  export declare const getPreviewFileType: (fileName: string | null) => AssetFileType;
@@ -8,7 +8,8 @@ const getPreviewFileType = (fileName) => {
8
8
  }
9
9
  const audioExtensions = ['mp3', 'wav', 'ogg', 'aac'];
10
10
  const videoExtensions = ['mp4', 'avi', 'mkv', 'mov', 'webm'];
11
- const imageExtensions = ['jpg', 'jpeg', 'png', 'apng', 'gif', 'bmp'];
11
+ const imageExtensions = ['jpg', 'jpeg', 'png', 'apng', 'gif', 'bmp', 'webp'];
12
+ const fontExtensions = ['woff', 'woff2', 'ttf', 'otf', 'eot'];
12
13
  const fileExtension = (_a = fileName.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
13
14
  if (fileExtension === undefined) {
14
15
  throw new Error('File extension is undefined');
@@ -22,6 +23,9 @@ const getPreviewFileType = (fileName) => {
22
23
  if (imageExtensions.includes(fileExtension)) {
23
24
  return 'image';
24
25
  }
26
+ if (fontExtensions.includes(fileExtension)) {
27
+ return 'font';
28
+ }
25
29
  if (fileExtension === 'json') {
26
30
  return 'json';
27
31
  }
@@ -89,6 +89,15 @@ const makeDefaultGlobalCSS = () => {
89
89
  box-shadow: ${colors_1.FOCUS_BOX_SHADOW};
90
90
  }
91
91
 
92
+ .__remotion-composition-selector-item:focus {
93
+ outline: none;
94
+ box-shadow: none;
95
+ }
96
+
97
+ .__remotion-composition-selector-item:focus-visible {
98
+ box-shadow: ${colors_1.FOCUS_BOX_SHADOW};
99
+ }
100
+
92
101
  .__remotion_color_swatch:focus {
93
102
  outline: none;
94
103
  }
@@ -0,0 +1,41 @@
1
+ import type { Size } from '@remotion/player';
2
+ export declare const STUDIO_FIT_PADDING = 16;
3
+ type CanvasSize = {
4
+ readonly width: number;
5
+ readonly height: number;
6
+ };
7
+ export declare const getStudioPaddedCanvasSize: <T extends CanvasSize>(canvasSize: T) => {
8
+ canvasSize: T & {
9
+ width: number;
10
+ height: number;
11
+ };
12
+ horizontalPadding: number;
13
+ verticalPadding: number;
14
+ };
15
+ export declare const getStudioCurrentScaleContext: (canvasSize: Size) => {
16
+ type: "canvas-size";
17
+ canvasSize: Size;
18
+ canvasSizeForAuto: Size & {
19
+ width: number;
20
+ height: number;
21
+ };
22
+ };
23
+ export declare const calculateStudioScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
24
+ readonly canvasSize: CanvasSize;
25
+ readonly compositionHeight: number;
26
+ readonly compositionWidth: number;
27
+ readonly previewSize: number | "auto";
28
+ }) => number;
29
+ export declare const calculateStudioCanvasTransformation: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
30
+ readonly canvasSize: Size;
31
+ readonly compositionHeight: number;
32
+ readonly compositionWidth: number;
33
+ readonly previewSize: number | "auto";
34
+ }) => {
35
+ centerX: number;
36
+ centerY: number;
37
+ xCorrection: number;
38
+ yCorrection: number;
39
+ scale: number;
40
+ };
41
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateStudioCanvasTransformation = exports.calculateStudioScale = exports.getStudioCurrentScaleContext = exports.getStudioPaddedCanvasSize = exports.STUDIO_FIT_PADDING = void 0;
4
+ const player_1 = require("@remotion/player");
5
+ const remotion_1 = require("remotion");
6
+ exports.STUDIO_FIT_PADDING = 16;
7
+ const getPadding = (length) => {
8
+ return Math.min(exports.STUDIO_FIT_PADDING, Math.max(0, (length - 1) / 2));
9
+ };
10
+ const getStudioPaddedCanvasSize = (canvasSize) => {
11
+ const horizontalPadding = getPadding(canvasSize.width);
12
+ const verticalPadding = getPadding(canvasSize.height);
13
+ return {
14
+ canvasSize: {
15
+ ...canvasSize,
16
+ width: canvasSize.width - horizontalPadding * 2,
17
+ height: canvasSize.height - verticalPadding * 2,
18
+ },
19
+ horizontalPadding,
20
+ verticalPadding,
21
+ };
22
+ };
23
+ exports.getStudioPaddedCanvasSize = getStudioPaddedCanvasSize;
24
+ const getStudioCurrentScaleContext = (canvasSize) => {
25
+ return {
26
+ type: 'canvas-size',
27
+ canvasSize,
28
+ canvasSizeForAuto: (0, exports.getStudioPaddedCanvasSize)(canvasSize).canvasSize,
29
+ };
30
+ };
31
+ exports.getStudioCurrentScaleContext = getStudioCurrentScaleContext;
32
+ const calculateStudioScale = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
33
+ const paddedCanvasSize = (0, exports.getStudioPaddedCanvasSize)(canvasSize).canvasSize;
34
+ return remotion_1.Internals.calculateScale({
35
+ canvasSize: paddedCanvasSize,
36
+ compositionHeight,
37
+ compositionWidth,
38
+ previewSize,
39
+ });
40
+ };
41
+ exports.calculateStudioScale = calculateStudioScale;
42
+ const calculateStudioCanvasTransformation = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
43
+ if (previewSize !== 'auto') {
44
+ return player_1.PlayerInternals.calculateCanvasTransformation({
45
+ canvasSize,
46
+ compositionHeight,
47
+ compositionWidth,
48
+ previewSize,
49
+ });
50
+ }
51
+ const { canvasSize: paddedCanvasSize, horizontalPadding, verticalPadding, } = (0, exports.getStudioPaddedCanvasSize)(canvasSize);
52
+ const transformation = player_1.PlayerInternals.calculateCanvasTransformation({
53
+ canvasSize: paddedCanvasSize,
54
+ compositionHeight,
55
+ compositionWidth,
56
+ previewSize,
57
+ });
58
+ return {
59
+ ...transformation,
60
+ centerX: transformation.centerX + horizontalPadding,
61
+ centerY: transformation.centerY + verticalPadding,
62
+ };
63
+ };
64
+ exports.calculateStudioCanvasTransformation = calculateStudioCanvasTransformation;
@@ -0,0 +1,8 @@
1
+ export type ImageMetadata = {
2
+ readonly format: string;
3
+ readonly width: number;
4
+ readonly height: number;
5
+ };
6
+ export declare const getImageMetadataFromData: (data: Uint8Array<ArrayBufferLike>) => ImageMetadata | null;
7
+ export declare const getImageMetadata: (src: string) => Promise<ImageMetadata | null>;
8
+ export declare const useImageMetadata: (src: string | null) => ImageMetadata | null;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useImageMetadata = exports.getImageMetadata = exports.getImageMetadataFromData = void 0;
4
+ const studio_shared_1 = require("@remotion/studio-shared");
5
+ const react_1 = require("react");
6
+ const cache = new Map();
7
+ const pendingRequests = new Map();
8
+ const formatImageType = (fileType) => {
9
+ if (fileType === 'webp') {
10
+ return 'WebP';
11
+ }
12
+ return fileType.toUpperCase();
13
+ };
14
+ const getImageMetadataFromData = (data) => {
15
+ const fileType = (0, studio_shared_1.detectFileType)(data);
16
+ if (!(0, studio_shared_1.isImageFileType)(fileType) || fileType.dimensions === null) {
17
+ return null;
18
+ }
19
+ return {
20
+ format: formatImageType(fileType.type),
21
+ width: fileType.dimensions.width,
22
+ height: fileType.dimensions.height,
23
+ };
24
+ };
25
+ exports.getImageMetadataFromData = getImageMetadataFromData;
26
+ const getImageMetadata = (src) => {
27
+ const cached = cache.get(src);
28
+ if (cached) {
29
+ return Promise.resolve(cached);
30
+ }
31
+ const pendingRequest = pendingRequests.get(src);
32
+ if (pendingRequest) {
33
+ return pendingRequest;
34
+ }
35
+ const request = fetch(src)
36
+ .then((response) => {
37
+ if (!response.ok) {
38
+ return null;
39
+ }
40
+ return response.arrayBuffer();
41
+ })
42
+ .then((data) => {
43
+ if (data === null) {
44
+ return null;
45
+ }
46
+ const metadata = (0, exports.getImageMetadataFromData)(new Uint8Array(data));
47
+ if (metadata) {
48
+ cache.set(src, metadata);
49
+ }
50
+ return metadata;
51
+ })
52
+ .catch(() => null)
53
+ .finally(() => {
54
+ pendingRequests.delete(src);
55
+ });
56
+ pendingRequests.set(src, request);
57
+ return request;
58
+ };
59
+ exports.getImageMetadata = getImageMetadata;
60
+ const useImageMetadata = (src) => {
61
+ var _a;
62
+ const [imageMetadata, setImageMetadata] = (0, react_1.useState)(src ? ((_a = cache.get(src)) !== null && _a !== void 0 ? _a : null) : null);
63
+ (0, react_1.useEffect)(() => {
64
+ var _a;
65
+ const cached = src ? ((_a = cache.get(src)) !== null && _a !== void 0 ? _a : null) : null;
66
+ setImageMetadata(cached);
67
+ if (!src || cached) {
68
+ return;
69
+ }
70
+ let cancelled = false;
71
+ (0, exports.getImageMetadata)(src).then((metadata) => {
72
+ if (!cancelled) {
73
+ setImageMetadata(metadata);
74
+ }
75
+ });
76
+ return () => {
77
+ cancelled = true;
78
+ };
79
+ }, [src]);
80
+ return imageMetadata;
81
+ };
82
+ exports.useImageMetadata = useImageMetadata;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useStudioCanvasDimensions = void 0;
4
- const player_1 = require("@remotion/player");
5
4
  const react_1 = require("react");
6
5
  const remotion_1 = require("remotion");
6
+ const studio_fit_padding_1 = require("./studio-fit-padding");
7
7
  const useStudioCanvasDimensions = ({ canvasSize, contentDimensions, assetMetadata, }) => {
8
8
  const { size: previewSize } = (0, react_1.useContext)(remotion_1.Internals.PreviewSizeContext);
9
9
  const { centerX, centerY, scale } = (0, react_1.useMemo)(() => {
@@ -19,7 +19,7 @@ const useStudioCanvasDimensions = ({ canvasSize, contentDimensions, assetMetadat
19
19
  scale: 1,
20
20
  };
21
21
  }
22
- return player_1.PlayerInternals.calculateCanvasTransformation({
22
+ return (0, studio_fit_padding_1.calculateStudioCanvasTransformation)({
23
23
  canvasSize,
24
24
  compositionHeight: contentDimensions.height,
25
25
  compositionWidth: contentDimensions.width,
@@ -1,2 +1,5 @@
1
1
  import type { SVGProps } from 'react';
2
2
  export declare const AudioIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const AudioFileIcon: ({ color, ...props }: SVGProps<SVGSVGElement> & {
4
+ readonly color?: string | undefined;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AudioIcon = void 0;
3
+ exports.AudioFileIcon = exports.AudioIcon = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const colors_1 = require("../helpers/colors");
6
6
  const AudioIcon = (props) => (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { fill: colors_1.CURRENT_COLOR_LOWERCASE, d: "M243 32.32C105.5 39.15 0 157.8 0 295.5v120.4C0 451.3 28.63 480 64 480h32c17.62 0 32-14.38 32-32V288c0-17.62-14.38-32-32-32H64c-10.79 0-20.8 2.9-29.72 7.7 14.2-106.8 100.5-193.9 210.4-199.4 120.5-5.965 221.7 83.92 234 199.9-9.08-5.1-19.48-8.2-30.68-8.2h-32c-17.62 0-32 14.38-32 32v160c0 17.62 14.38 32 32 32h32c35.38 0 64-28.75 64-64.13V287.9c0-145.4-122-262.88-269-255.58zM64 288h32v160H64c-17.62 0-32-14.5-32-32.13v-95.75C32 302.5 46.38 288 64 288zm416 127.9c0 17.6-14.4 32.1-32 32.1h-32V288h32c17.62 0 32 14.5 32 32.13v95.77z" }) }));
7
7
  exports.AudioIcon = AudioIcon;
8
+ const AudioFileIcon = ({ color, ...props }) => (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { fill: color !== null && color !== void 0 ? color : colors_1.CURRENT_COLOR_LOWERCASE, d: "M480 16l0-19.9-19.5 4.3-288 64-12.5 2.8 0 273.2c-17-12.7-39.4-20.4-64-20.4-53 0-96 35.8-96 80s43 80 96 80 96-35.8 96-80l0-187.2 256-56.9 0 120.4c-17-12.7-39.4-20.4-64-20.4-53 0-96 35.8-96 80s43 80 96 80 96-35.8 96-80l0-320zM448 336c0 26.5-28.7 48-64 48s-64-21.5-64-48 28.7-48 64-48 64 21.5 64 48zM160 400c0 26.5-28.7 48-64 48s-64-21.5-64-48 28.7-48 64-48 64 21.5 64 48zM448 123.2l-256 56.9 0-87.2 256-56.9 0 87.2z" }) }));
9
+ exports.AudioFileIcon = AudioFileIcon;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare const FontFileIcon: ({ color, ...props }: SVGProps<SVGSVGElement> & {
3
+ readonly color: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FontFileIcon = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const FontFileIcon = ({ color, ...props }) => {
6
+ return (jsx_runtime_1.jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", children: jsx_runtime_1.jsx("path", { fill: color, d: "M256 32c6.4 0 12.2 3.8 14.7 9.8L442.6 448 480 448c8.8 0 16 7.2 16 16s-7.2 16-16 16l-112 0c-8.8 0-16-7.2-16-16s7.2-16 16-16l39.9 0-40.6-96-222.5 0-40.6 96 39.9 0c8.8 0 16 7.2 16 16s-7.2 16-16 16L32 480c-8.8 0-16-7.2-16-16s7.2-16 16-16l37.4 0 171.9-406.2c2.5-5.9 8.3-9.8 14.7-9.8zM158.3 320L353.7 320 256 89.1 158.3 320z" }) }));
7
+ };
8
+ exports.FontFileIcon = FontFileIcon;
@@ -1,2 +1,4 @@
1
1
  import type { SVGProps } from 'react';
2
- export declare const PicIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const PicIcon: ({ color, ...props }: SVGProps<SVGSVGElement> & {
3
+ readonly color?: string | undefined;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PicIcon = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const colors_1 = require("../helpers/colors");
6
- const PicIcon = (props) => (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { fill: colors_1.CURRENT_COLOR_LOWERCASE, d: "M324.9 157.8c-11.38-17.38-39.89-17.31-51.23-.063L200.5 268.5l-16.4-22.6c-11.4-16.8-38.2-16-49.7 0l-64.52 89.16c-6.797 9.406-7.75 21.72-2.547 32C72.53 377.5 83.05 384 94.75 384h322.5c11.41 0 21.8-6.281 27.14-16.38a30.922 30.922 0 0 0-1.516-31.56L324.9 157.8zM95.8 352l62.39-87.38 29.91 41.34c3.1 4.24 8.3 7.24 13.3 6.64 5.25-.125 10.12-2.781 13.02-7.188l83.83-129.9L415 352H95.8zM447.1 32h-384C28.65 32-.01 60.65-.01 96v320c0 35.35 28.65 64 63.1 64h384c35.35 0 64-28.65 64-64V96c.01-35.35-27.79-64-63.99-64zM480 416c0 17.64-14.36 32-32 32H64c-17.64 0-32-14.36-32-32V96c0-17.64 14.36-32 32-32h384c17.64 0 32 14.36 32 32v320zM144 192c26.5 0 48-21.5 48-48s-21.5-48-48-48-48 21.5-48 48 21.5 48 48 48zm0-64c8.822 0 15.1 7.178 15.1 16s-6.3 16-15.1 16-16-7.2-16-16 7.2-16 16-16z" }) }));
6
+ const PicIcon = ({ color, ...props }) => (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { fill: color !== null && color !== void 0 ? color : colors_1.CURRENT_COLOR_LOWERCASE, d: "M324.9 157.8c-11.38-17.38-39.89-17.31-51.23-.063L200.5 268.5l-16.4-22.6c-11.4-16.8-38.2-16-49.7 0l-64.52 89.16c-6.797 9.406-7.75 21.72-2.547 32C72.53 377.5 83.05 384 94.75 384h322.5c11.41 0 21.8-6.281 27.14-16.38a30.922 30.922 0 0 0-1.516-31.56L324.9 157.8zM95.8 352l62.39-87.38 29.91 41.34c3.1 4.24 8.3 7.24 13.3 6.64 5.25-.125 10.12-2.781 13.02-7.188l83.83-129.9L415 352H95.8zM447.1 32h-384C28.65 32-.01 60.65-.01 96v320c0 35.35 28.65 64 63.1 64h384c35.35 0 64-28.65 64-64V96c.01-35.35-27.79-64-63.99-64zM480 416c0 17.64-14.36 32-32 32H64c-17.64 0-32-14.36-32-32V96c0-17.64 14.36-32 32-32h384c17.64 0 32 14.36 32 32v320zM144 192c26.5 0 48-21.5 48-48s-21.5-48-48-48-48 21.5-48 48 21.5 48 48 48zm0-64c8.822 0 15.1 7.178 15.1 16s-6.3 16-15.1 16-16-7.2-16-16 7.2-16 16-16z" }) }));
7
7
  exports.PicIcon = PicIcon;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare const JsonFileIcon: ({ color, ...props }: SVGProps<SVGSVGElement> & {
3
+ readonly color: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonFileIcon = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const JsonFileIcon = ({ color, ...props }) => {
6
+ return (jsx_runtime_1.jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512", children: jsx_runtime_1.jsx("path", { fill: color, d: "M144 32c-44.2 0-80 35.8-80 80l0 53.5c0 12.7-5.1 24.9-14.1 33.9L4.7 244.7c-3 3-4.7 7.1-4.7 11.3s1.7 8.3 4.7 11.3l45.3 45.3c9 9 14.1 21.2 14.1 33.9L64 400c0 44.2 35.8 80 80 80l64 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-64 0c-26.5 0-48-21.5-48-48l0-53.5c0-21.2-8.4-41.6-23.4-56.6L38.6 256 72.6 222.1c15-15 23.4-35.4 23.4-56.6L96 112c0-26.5 21.5-48 48-48l64 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-64 0zm288 0l-64 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l64 0c26.5 0 48 21.5 48 48l0 53.5c0 21.2 8.4 41.6 23.4 56.6l33.9 33.9-33.9 33.9c-15 15-23.4 35.4-23.4 56.6l0 53.5c0 26.5-21.5 48-48 48l-64 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l64 0c44.2 0 80-35.8 80-80l0-53.5c0-12.7 5.1-24.9 14.1-33.9l45.3-45.3c3-3 4.7-7.1 4.7-11.3s-1.7-8.3-4.7-11.3l-45.3-45.3c-9-9-14.1-21.2-14.1-33.9l0-53.5c0-44.2-35.8-80-80-80z" }) }));
7
+ };
8
+ exports.JsonFileIcon = JsonFileIcon;
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MagnetIcon = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const MagnetIcon = (props) => {
6
- return (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { transform: "rotate(180 256 256)", d: "M32 176v112c0 123.7 100.3 224 224 224s224-100.3 224-224V176H352v112c0 53-43 96-96 96s-96-43-96-96V176H32zm0-48h128V64c0-17.7-14.3-32-32-32H64C46.3 32 32 46.3 32 64v64zm320 0h128V64c0-17.7-14.3-32-32-32h-64c-17.7 0-32 14.3-32 32v64z" }) }));
6
+ return (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { transform: "rotate(180 256 256)", d: "M32 176v112c0 123.7 100.3 224 224 224s224-100.3 224-224V176H352v112c0 53-43 96-96 96s-96-43-96-96V176H32zm0-48h128V32c0-17.7-14.3-32-32-32H64C46.3 0 32 14.3 32 32v96zm320 0h128V32c0-17.7-14.3-32-32-32h-64c-17.7 0-32 14.3-32 32v96z" }) }));
7
7
  };
8
8
  exports.MagnetIcon = MagnetIcon;
@@ -0,0 +1,5 @@
1
+ import type { SVGProps } from 'react';
2
+ import React from 'react';
3
+ export declare const ScissorsIcon: React.FC<SVGProps<SVGSVGElement> & {
4
+ readonly color: string;
5
+ }>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScissorsIcon = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ScissorsIcon = ({ color, ...props }) => {
6
+ return (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { fill: color, d: "M112 32a80 80 0 1 0 0 160 80 80 0 1 0 0-160zm0-32c61.9 0 112 50.1 112 112 0 12.4-2 24.4-5.8 35.6L256 185.4 383.9 57.5c31-31 81.2-31 112.2 0 12.4 12.4 12.4 32.6 0 45L221.6 377c1.6 7.4 2.4 15.1 2.4 23 0 61.9-50.1 112-112 112S0 461.9 0 400s50.1-112 112-112c12.4 0 24.4 2 35.6 5.8L177.4 264 135 221.6c-7.4 1.6-15.1 2.4-23 2.4-61.9 0-112-50.1-112-112S50.1 0 112 0zm55.8 209.1l32.2 32.2 33.4-33.4-30.5-30.5c-9.3 12.9-21.3 23.7-35.1 31.7zm238.7-129-229 229c12.9 9.3 23.7 21.3 31.7 35.1L473.4 80c-18.5-18.4-48.4-18.3-66.9.1zM192 400a80 80 0 1 0-160 0 80 80 0 1 0 160 0zm206.5 39.9c18.5 18.5 48.4 18.5 66.9.1L346 320.6l22.6-22.6 119.5 119.5c12.4 12.4 12.4 32.6 0 45-31 31-81.2 31-112.2 0L290 376.6l22.6-22.6 85.9 85.9z" }) }));
7
+ };
8
+ exports.ScissorsIcon = ScissorsIcon;
@@ -0,0 +1,5 @@
1
+ import type { SVGProps } from 'react';
2
+ import React from 'react';
3
+ export declare const SolidIcon: React.FC<SVGProps<SVGSVGElement> & {
4
+ readonly color: string;
5
+ }>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolidIcon = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const SolidIcon = ({ color, ...props }) => {
6
+ return (jsx_runtime_1.jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", children: jsx_runtime_1.jsx("rect", { x: 16, y: 48, width: 480, height: 416, rx: 48, fill: "none", stroke: color, strokeWidth: 32 }) }));
7
+ };
8
+ exports.SolidIcon = SolidIcon;