import {Audio, Video} from '@remotion/media'; import type {Size} from '@remotion/player'; import {PlayerInternals} from '@remotion/player'; import React, { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react'; import {createPortal} from 'react-dom'; import type {CanvasContent} from 'remotion'; import {Internals, staticFile} from 'remotion'; import {ErrorLoader} from '../error-overlay/remotion-overlay/ErrorLoader'; import {addAssetCacheBust} from '../helpers/add-asset-cache-bust'; import { checkerboardBackgroundColor, checkerboardBackgroundImage, getCheckerboardBackgroundPos, getCheckerboardBackgroundSize, } from '../helpers/checkerboard-background'; import {LIGHT_TEXT, RULER_COLOR} from '../helpers/colors'; import type {AssetMetadata} from '../helpers/get-asset-metadata'; import {getPreviewFileType} from '../helpers/get-preview-file-type'; import type {Dimensions} from '../helpers/is-current-selected-still'; import {calculateStudioCanvasTransformation} from '../helpers/studio-fit-padding'; import {AudioFileIcon} from '../icons/audio'; import {CheckerboardContext} from '../state/checkerboard'; import {EditorShowPixelGridContext} from '../state/editor-pixel-grid'; import {VERTICAL_SCROLLBAR_CLASSNAME} from './Menu/is-menu-item'; import {RenderPreview} from './RenderPreview'; import {SelectedOutlineOverlay} from './SelectedOutlineOverlay'; import {Spinner} from './Spinner'; import {StaticFilePreview} from './StaticFilePreview'; import {shouldClearSelectionOnPointerDown} from './Timeline/should-clear-selection-on-pointer-down'; import {useCurrentTimelineSelectionStateAsRef} from './Timeline/TimelineSelection'; const centeredContainer: React.CSSProperties = { display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', }; const label: React.CSSProperties = { fontFamily: 'sans-serif', fontSize: 14, color: LIGHT_TEXT, }; const assetMetadataErrorContainer: React.CSSProperties = { marginLeft: 'auto', marginRight: 'auto', width: '100%', position: 'absolute', height: '100%', overflowY: 'auto', }; const checkerboardSize = 49; const PIXEL_GRID_MIN_SCALE = 4; const containerStyle = (options: { scale: number; scaleX: number; width: number; height: number; checkerboard: boolean; }): React.CSSProperties => { return { transform: `scale(${options.scaleX}, ${options.scale})`, // Keep the scaled composition on its own layer so the checkerboard does // not bleed through its edges at fractional preview scales. willChange: 'transform', transformOrigin: '0 0', width: options.width, height: options.height, display: 'flex', overflow: 'hidden', position: 'absolute', backgroundColor: checkerboardBackgroundColor(options.checkerboard), backgroundImage: checkerboardBackgroundImage(options.checkerboard), backgroundSize: getCheckerboardBackgroundSize(checkerboardSize) /* Must be a square */, backgroundPosition: getCheckerboardBackgroundPos( checkerboardSize, ) /* Must be half of one side of the square */, }; }; const PixelGrid: React.FC<{ readonly scale: number; }> = ({scale}) => { const {editorShowPixelGrid} = useContext(EditorShowPixelGridContext); if (!editorShowPixelGrid || scale < PIXEL_GRID_MIN_SCALE) { return null; } return (