import type {LogLevel, StaticFile} from 'remotion'; import {Internals, VERSION} from 'remotion'; import type {GitSource} from './git-source'; import type {PackageManager} from './package-manager'; import type {RenderDefaults} from './render-defaults'; import type {StudioRuntimeConfig} from './studio-runtime-config'; declare global { interface Window { remotion_browserStudioReload: (() => void) | null; remotion_studioStartup: { takeErrors: () => Error[]; dismiss: () => void; } | null; } } export type StudioHtmlOptions = { staticHash: string; outputHash: string | null; publicPath: string; editorName: string | null; inputProps: object | null; envVariables?: Record; remotionRoot: string; studioServerCommand: string | null; renderQueue: unknown | null; completedClientRenders?: unknown | null; numberOfAudioTags: number; audioLatencyHint: AudioContextLatencyCategory; experimentalKeepAudioContextAlive: boolean; sampleRate: number | null; publicFiles: StaticFile[]; publicFolderExists: string | null; fileSystemPlatform: string | null; supportsNativeFilePicker: boolean; includeFavicon: boolean; title: string; renderDefaults: RenderDefaults | undefined; gitSource: GitSource | null; projectName: string; installedDependencies: string[] | null; packageManager: PackageManager | 'unknown'; logLevel: LogLevel; mode: 'dev' | 'bundle'; bundleScriptUrl?: string; bundleScriptType?: 'classic' | 'module'; importMap: Record | null; readOnlyStudio?: boolean; studioRuntimeConfig?: StudioRuntimeConfig; }; export const studioHtml = ({ publicPath, editorName, inputProps, envVariables, staticHash, outputHash, remotionRoot, studioServerCommand, renderQueue, completedClientRenders, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, fileSystemPlatform, supportsNativeFilePicker, gitSource, projectName, installedDependencies, packageManager, audioLatencyHint, experimentalKeepAudioContextAlive, sampleRate, logLevel, mode, bundleScriptUrl, bundleScriptType, importMap, readOnlyStudio, studioRuntimeConfig, }: StudioHtmlOptions) => { const scriptUrl = bundleScriptUrl ?? `${publicPath}bundle.js`; const isRelativeBundle = mode === 'bundle' && publicPath === './'; const staticBaseValue = isRelativeBundle ? `new URL(${JSON.stringify(staticHash)}, window.location.href).pathname` : JSON.stringify(staticHash); const staticFilesValue = isRelativeBundle ? `${JSON.stringify(publicFiles)}.map((file) => ({...file, src: new URL(file.src, window.location.href).pathname}))` : JSON.stringify(publicFiles); const publicFolderExistsValue = isRelativeBundle && publicFolderExists ? `new URL(${JSON.stringify(publicFolderExists)}, window.location.href).pathname` : JSON.stringify(publicFolderExists); const startupErrorHtml = mode === 'dev' ? ` ` : ''; return ` ${ importMap ? `` : '' } ${ includeFavicon ? `` : '' } ${title} ${startupErrorHtml} ${mode === 'dev' ? `` : ''} ${ editorName ? `` : '' } ${ inputProps ? `` : '' } ${ renderQueue ? `` : '' } ${ completedClientRenders ? `` : '' } ${ envVariables ? `` : '' } ${ gitSource ? `` : '' } ${ mode === 'dev' ? ` `.trimStart() : '' }
`.trim(); };