🎥 Make videos programmatically with React
deserialize input props
Jonny Burgerc9c4582f82e5
diff --git a/packages/lambda/src/api/get-compositions-on-lambda.ts b/packages/lambda/src/api/get-compositions-on-lambda.tsindex f5e8fb5577..b32452c4b5 100644--- a/packages/lambda/src/api/get-compositions-on-lambda.ts+++ b/packages/lambda/src/api/get-compositions-on-lambda.ts@@ -54,6 +54,7 @@ export const getCompositionsOnLambda = async ({region,type: 'still',userSpecifiedBucketName: bucketName ?? null,+ propsType: 'input-props',});try {diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda/src/api/make-lambda-payload.tsindex 4f0e9a7733..74b4a6a411 100644--- a/packages/lambda/src/api/make-lambda-payload.ts+++ b/packages/lambda/src/api/make-lambda-payload.ts@@ -66,6 +66,7 @@ export const makeLambdaRenderMediaPayload = async ({region,type: 'video-or-audio',userSpecifiedBucketName: bucketName ?? null,+ propsType: 'input-props',});return {rendererFunctionName: rendererFunctionName ?? null,diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.tsindex 8e0f9dcd92..2bcf76942c 100644--- a/packages/lambda/src/api/render-still-on-lambda.ts+++ b/packages/lambda/src/api/render-still-on-lambda.ts@@ -104,6 +104,7 @@ export const renderStillOnLambda = async ({region,type: 'still',userSpecifiedBucketName: forceBucketName ?? null,+ propsType: 'input-props',});try {diff --git a/packages/lambda/src/functions/compositions.ts b/packages/lambda/src/functions/compositions.tsindex 5208b67b2e..4d255a7b8e 100644--- a/packages/lambda/src/functions/compositions.ts+++ b/packages/lambda/src/functions/compositions.ts@@ -51,6 +51,7 @@ export const compositionsHandler = async (expectedBucketOwner: options.expectedBucketOwner,region: getCurrentRegionInFunction(),serialized: lambdaParams.inputProps,+ propsType: 'input-props',});const realServeUrl = convertToServeUrl({diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex 04a972d32a..b9b9d39627 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -166,6 +166,7 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {expectedBucketOwner: options.expectedBucketOwner,region: getCurrentRegionInFunction(),serialized: params.inputProps,+ propsType: 'input-props',});const comp = await validateComposition({diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.tsindex 4a0859535f..b664c9eb67 100644--- a/packages/lambda/src/functions/renderer.ts+++ b/packages/lambda/src/functions/renderer.ts@@ -52,6 +52,7 @@ const renderHandler = async (expectedBucketOwner: options.expectedBucketOwner,region: getCurrentRegionInFunction(),serialized: params.inputProps,+ propsType: 'input-props',});const browserInstance = await getBrowserInstance(diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.tsindex 9ce49c889a..6f6fbfd90e 100644--- a/packages/lambda/src/functions/still.ts+++ b/packages/lambda/src/functions/still.ts@@ -94,6 +94,7 @@ const innerStillHandler = async (expectedBucketOwner: options.expectedBucketOwner,region,serialized: lambdaParams.inputProps,+ propsType: 'input-props',});const serveUrl = convertToServeUrl({diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex b83b2514aa..337b1e9771 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -183,6 +183,10 @@ export const inputPropsKey = (hash: string) => {return `input-props/${hash}.json`;};+export const resolvedPropsKey = (hash: string) => {+ return `resolved-props/${hash}.json`;+};+export const RENDERER_PATH_TOKEN = 'remotion-bucket';export const CONCAT_FOLDER_TOKEN = 'remotion-concat';export const REMOTION_CONCATED_TOKEN = 'remotion-concated-token';diff --git a/packages/lambda/src/shared/serialize-props.ts b/packages/lambda/src/shared/serialize-props.tsindex fe062ad8bf..4ce75bbc30 100644--- a/packages/lambda/src/shared/serialize-props.ts+++ b/packages/lambda/src/shared/serialize-props.ts@@ -1,21 +1,24 @@import {getOrCreateBucket} from '../api/get-or-create-bucket';import type {AwsRegion} from '../client';import {lambdaReadFile, lambdaWriteFile} from '../functions/helpers/io';-import type {SerializedInputProps} from './constants';-import {inputPropsKey} from './constants';+import {inputPropsKey, resolvedPropsKey, type SerializedInputProps} from './constants';import {randomHash} from './random-hash';import {streamToString} from './stream-to-string';+type PropsType = 'input-props' | 'resolved-props';+export const serializeInputProps = async ({inputProps,region,type,userSpecifiedBucketName,+ propsType}: {inputProps: Record<string, unknown>;region: AwsRegion;type: 'still' | 'video-or-audio';userSpecifiedBucketName: string | null;+ propsType: PropsType;}): Promise<SerializedInputProps> => {try {const payload = JSON.stringify(inputProps);@@ -46,7 +49,7 @@ export const serializeInputProps = async ({customCredentials: null,downloadBehavior: null,expectedBucketOwner: null,- key: inputPropsKey(hash),+ key: makeKey(propsType, hash),privacy: 'public',});@@ -72,11 +75,13 @@ export const deserializeInputProps = async ({region,bucketName,expectedBucketOwner,+ propsType}: {serialized: SerializedInputProps;region: AwsRegion;bucketName: string;expectedBucketOwner: string;+ propsType: PropsType;}): Promise<Record<string, unknown>> => {if (serialized.type === 'payload') {return JSON.parse(serialized.payload as string);@@ -86,7 +91,7 @@ export const deserializeInputProps = async ({const response = await lambdaReadFile({bucketName,expectedBucketOwner,- key: inputPropsKey(serialized.hash),+ key: makeKey(propsType, serialized.hash),region,});@@ -102,3 +107,12 @@ export const deserializeInputProps = async ({);}};++const makeKey = (type: PropsType, hash: string): string => {+ if (type === 'input-props') {+ return inputPropsKey(hash);+ }++ return resolvedPropsKey(hash);++}