🎥 Make videos programmatically with React
package manager
Jonny Burgerdf24276bfb07
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.tsindex bbde27cd8d..14996083bf 100644--- a/packages/bundler/src/bundle.ts+++ b/packages/bundler/src/bundle.ts@@ -303,6 +303,7 @@ export const internalBundle = async (basename: path.basename,}),installedDependencies: null,+ packageManager: 'unknown',});fs.writeFileSync(path.join(outDir, 'index.html'), html);diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.tsindex d6e2d9c504..8f48380e6c 100644--- a/packages/bundler/src/index-html.ts+++ b/packages/bundler/src/index-html.ts@@ -1,6 +1,7 @@import type {GitSource,InstallablePackage,+ PackageManager,RenderDefaults,} from '@remotion/studio-shared';import type {StaticFile} from 'remotion';@@ -24,6 +25,7 @@ export const indexHtml = ({gitSource,projectName,installedDependencies,+ packageManager,}: {staticHash: string;publicPath: string;@@ -42,6 +44,7 @@ export const indexHtml = ({gitSource: GitSource | null;projectName: string;installedDependencies: InstallablePackage[] | null;+ packageManager: PackageManager | 'unknown';}) =>// Must setup remotion_editorName and remotion.remotion_projectName before bundle.js is loaded`@@ -105,6 +108,7 @@ export const indexHtml = ({}<script>window.remotion_staticFiles = ${JSON.stringify(publicFiles)}</script><script>window.remotion_installedPackages = ${JSON.stringify(installedDependencies)}</script>+ <script>window.remotion_packageManager = ${JSON.stringify(packageManager)}</script><script>window.remotion_publicFolderExists = ${publicFolderExists ? `"${publicFolderExists}"` : 'null'};</script>diff --git a/packages/studio-server/src/routes.ts b/packages/studio-server/src/routes.tsindex d9a7f1dafd..614fc5bc2b 100644--- a/packages/studio-server/src/routes.ts+++ b/packages/studio-server/src/routes.ts@@ -102,6 +102,8 @@ const handleFallback = async ({resolvedRemotionRoot: remotionRoot,}),installedDependencies,+ packageManager:+ packageManager === 'unknown' ? 'unknown' : packageManager.manager,}),);};diff --git a/packages/studio-shared/src/render-defaults.ts b/packages/studio-shared/src/render-defaults.tsindex 16e26cf40a..9036c61232 100644--- a/packages/studio-shared/src/render-defaults.ts+++ b/packages/studio-shared/src/render-defaults.ts@@ -12,6 +12,7 @@ import type {} from '@remotion/renderer';import type {GitSource} from './git-source';import type {InstallablePackage} from './installable-packages';+import type {PackageManager} from './package-manager';export type RenderDefaults = {jpegQuality: number;@@ -54,5 +55,6 @@ declare global {remotion_renderDefaults: RenderDefaults | undefined;remotion_gitSource: GitSource | null;remotion_installedPackages: InstallablePackage[] | null;+ remotion_packageManager: PackageManager | 'unknown';}}diff --git a/packages/studio/src/components/InstallPackage.tsx b/packages/studio/src/components/InstallPackage.tsxindex 287ed21308..e421b93ee3 100644--- a/packages/studio/src/components/InstallPackage.tsx+++ b/packages/studio/src/components/InstallPackage.tsx@@ -1,3 +1,4 @@+import type {PackageManager} from '@remotion/studio-shared';import {listOfInstallableRemotionPackages,type InstallablePackage,@@ -46,7 +47,9 @@ type State =type: 'restarting';};-export const InstallPackageModal: React.FC<{}> = () => {+export const InstallPackageModal: React.FC<{+ readonly packageManager: PackageManager;+}> = ({packageManager}) => {const [state, setState] = React.useState<State>({type: 'idle'});const [map, setMap] = React.useState<{[key in InstallablePackage]: boolean}>({'@remotion/animated-emoji': false,@@ -180,7 +183,8 @@ export const InstallPackageModal: React.FC<{}> = () => {{state.type === 'idle' ? (<span style={{color: LIGHT_TEXT, fontSize: 13, lineHeight: 1.2}}>This will install {selectedPackages.length} package- {selectedPackages.length === 1 ? '' : 's'} (v{VERSION})+ {selectedPackages.length === 1 ? '' : 's'} (v{VERSION}) using{' '}+ {packageManager}</span>) : null}<Flex />diff --git a/packages/studio/src/components/Modals.tsx b/packages/studio/src/components/Modals.tsxindex 83591779f5..eb6268b743 100644--- a/packages/studio/src/components/Modals.tsx+++ b/packages/studio/src/components/Modals.tsx@@ -103,7 +103,7 @@ export const Modals: React.FC<{/>)}{modalContextType && modalContextType.type === 'install-packages' && (- <InstallPackageModal />+ <InstallPackageModal packageManager={modalContextType.packageManager} />)}{modalContextType && modalContextType.type === 'quick-switcher' && (diff --git a/packages/studio/src/helpers/use-menu-structure.tsx b/packages/studio/src/helpers/use-menu-structure.tsxindex 332e69136e..d7420339a9 100644--- a/packages/studio/src/helpers/use-menu-structure.tsx+++ b/packages/studio/src/helpers/use-menu-structure.tsx@@ -165,6 +165,8 @@ export const useMenuStructure = (const isFullscreenSupported = checkFullscreenSupport();+ const {remotion_packageManager} = window;+const mobileLayout = useMobileLayout();const structure = useMemo((): Structure => {let struct: Structure = [@@ -653,7 +655,7 @@ export const useMenuStructure = (].filter(Internals.truthy),quickSwitcherLabel: null,},- readOnlyStudio+ readOnlyStudio || remotion_packageManager === 'unknown'? null: {id: 'install' as const,@@ -668,6 +670,7 @@ export const useMenuStructure = (closeMenu();setSelectedModal({type: 'install-packages',+ packageManager: remotion_packageManager,});},type: 'item' as const,@@ -856,6 +859,7 @@ export const useMenuStructure = (return struct;}, [+ remotion_packageManager,readOnlyStudio,mobileLayout,sizes,diff --git a/packages/studio/src/state/modals.ts b/packages/studio/src/state/modals.tsindex add91e149d..c31fc1f623 100644--- a/packages/studio/src/state/modals.ts+++ b/packages/studio/src/state/modals.ts@@ -10,6 +10,7 @@ import type {VideoImageFormat,X264Preset,} from '@remotion/renderer';+import type {PackageManager} from '@remotion/studio-shared';import type React from 'react';import {createContext} from 'react';import type {CompType} from '../components/NewComposition/DuplicateComposition';@@ -87,6 +88,7 @@ export type ModalState =}| {type: 'install-packages';+ packageManager: PackageManager;}| {type: 'quick-switcher';