🎥 Make videos programmatically with React
fix getInputProps() / environment variables being undefined
Jonny Burger0cc19cbe8658
diff --git a/packages/renderer/src/set-props-and-env.ts b/packages/renderer/src/set-props-and-env.tsindex afb4c04ba6..112940708d 100644--- a/packages/renderer/src/set-props-and-env.ts+++ b/packages/renderer/src/set-props-and-env.ts@@ -26,6 +26,39 @@ export const setPropsAndEnv = async ({page.setDefaultNavigationTimeout(actualTimeout);const urlToVisit = normalizeServeUrl(serveUrl);++ await page.evaluateOnNewDocument(+ (timeout: number) => {+ window.remotion_puppeteerTimeout = timeout;+ },+ [actualTimeout]+ );++ if (inputProps) {+ await page.evaluateOnNewDocument(+ (input: string) => {+ window.remotion_inputProps = input;+ },+ [JSON.stringify(inputProps)]+ );+ }++ if (envVariables) {+ await page.evaluateOnNewDocument(+ (input: string) => {+ window.remotion_envVariables = input;+ },+ [JSON.stringify(envVariables)]+ );+ }++ await page.evaluateOnNewDocument(+ (key: string, value: string) => {+ window.localStorage.setItem(key, value);+ },+ [Internals.INITIAL_FRAME_LOCAL_STORAGE_KEY, initialFrame]+ );+const pageRes = await page.goto(urlToVisit);const status = pageRes.status();@@ -41,21 +74,6 @@ export const setPropsAndEnv = async ({);}- const siteVersion = await puppeteerEvaluateWithCatch<'2'>({- pageFunction: () => {- return window.siteVersion;- },- args: [],- frame: null,- page,- });-- if (siteVersion !== '2') {- throw new Error(- `Incompatible site: When visiting ${urlToVisit}, a bundle was found, but one that is not compatible with this version of Remotion. The bundle format changed in versions from March 2022 onwards. To resolve this error, please bundle and deploy again.`- );- }-const isRemotionFn = await puppeteerEvaluateWithCatch<typeof window['getStaticCompositions']>({@@ -72,43 +90,18 @@ export const setPropsAndEnv = async ({);}- await puppeteerEvaluateWithCatch({- args: [actualTimeout],+ const siteVersion = await puppeteerEvaluateWithCatch<'2'>({+ pageFunction: () => {+ return window.siteVersion;+ },+ args: [],frame: null,page,- pageFunction: (timeout: number) => {- window.remotion_puppeteerTimeout = timeout;- },});- if (inputProps) {- await puppeteerEvaluateWithCatch({- pageFunction: (input: string) => {- window.remotion_inputProps = input;- },- args: [JSON.stringify(inputProps)],- frame: null,- page,- });- }-- if (envVariables) {- await puppeteerEvaluateWithCatch({- pageFunction: (input: string) => {- window.remotion_envVariables = input;- },- args: [JSON.stringify(envVariables)],- frame: null,- page,- });+ if (siteVersion !== '2') {+ throw new Error(+ `Incompatible site: When visiting ${urlToVisit}, a bundle was found, but one that is not compatible with this version of Remotion. The bundle format changed in versions from March 2022 onwards. To resolve this error, please bundle and deploy again.`+ );}-- await puppeteerEvaluateWithCatch({- pageFunction: (key: string, value: string) => {- window.localStorage.setItem(key, value);- },- args: [Internals.INITIAL_FRAME_LOCAL_STORAGE_KEY, initialFrame],- frame: null,- page,- });};