@remotion/lambda 4.1.0-alpha2 → 4.1.0-alpha5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/api/get-buckets.d.ts +1 -1
  2. package/dist/api/get-buckets.js +9 -3
  3. package/dist/api/get-compositions-on-lambda.d.ts +3 -1
  4. package/dist/api/get-compositions-on-lambda.js +7 -7
  5. package/dist/api/get-sites.d.ts +2 -1
  6. package/dist/api/get-sites.js +4 -2
  7. package/dist/api/make-lambda-payload.js +8 -7
  8. package/dist/api/render-media-on-lambda.d.ts +3 -1
  9. package/dist/api/render-media-on-lambda.js +0 -1
  10. package/dist/api/render-still-on-lambda.d.ts +3 -1
  11. package/dist/api/render-still-on-lambda.js +7 -7
  12. package/dist/cli/commands/render/render.js +2 -2
  13. package/dist/cli/commands/sites/create.js +1 -0
  14. package/dist/cli/commands/sites/rm.js +2 -1
  15. package/dist/cli/commands/still.js +2 -2
  16. package/dist/cli/log.d.ts +3 -4
  17. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +4 -1
  18. package/dist/functions/compositions.d.ts +1 -1
  19. package/dist/functions/compositions.js +7 -7
  20. package/dist/functions/helpers/get-browser-instance.d.ts +2 -2
  21. package/dist/functions/helpers/get-browser-instance.js +3 -3
  22. package/dist/functions/helpers/get-current-region.d.ts +1 -1
  23. package/dist/functions/helpers/print-cloudwatch-helper.js +2 -1
  24. package/dist/functions/helpers/validate-composition.d.ts +2 -2
  25. package/dist/functions/helpers/validate-composition.js +4 -2
  26. package/dist/functions/index.js +1 -1
  27. package/dist/functions/launch.js +25 -4
  28. package/dist/functions/renderer.js +27 -10
  29. package/dist/functions/start.js +0 -1
  30. package/dist/functions/still.js +9 -10
  31. package/dist/index.d.ts +1 -1
  32. package/dist/shared/constants.d.ts +5 -6
  33. package/dist/shared/constants.js +10 -1
  34. package/dist/shared/serialize-props.d.ts +20 -0
  35. package/dist/shared/serialize-props.js +83 -0
  36. package/package.json +8 -8
  37. package/remotionlambda-arm64.zip +0 -0
  38. package/remotionlambda-x64.zip +0 -0
  39. package/dist/shared/deserialize-input-props.d.ts +0 -8
  40. package/dist/shared/deserialize-input-props.js +0 -26
  41. package/dist/shared/serialize-input-props.d.ts +0 -8
  42. package/dist/shared/serialize-input-props.js +0 -42
@@ -4,6 +4,6 @@ export type BucketWithLocation = {
4
4
  creationDate: number;
5
5
  region: AwsRegion;
6
6
  };
7
- export declare const getRemotionS3Buckets: (region: AwsRegion) => Promise<{
7
+ export declare const getRemotionS3Buckets: (region: AwsRegion, forceBucketName?: string) => Promise<{
8
8
  remotionBuckets: BucketWithLocation[];
9
9
  }>;
@@ -2,15 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRemotionS3Buckets = void 0;
4
4
  const client_s3_1 = require("@aws-sdk/client-s3");
5
+ const defaults_1 = require("../defaults");
5
6
  const aws_clients_1 = require("../shared/aws-clients");
6
- const constants_1 = require("../shared/constants");
7
7
  const validate_bucketname_1 = require("../shared/validate-bucketname");
8
- const getRemotionS3Buckets = async (region) => {
8
+ const getRemotionS3Buckets = async (region, forceBucketName) => {
9
9
  const { Buckets } = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.ListBucketsCommand({}));
10
10
  if (!Buckets) {
11
11
  return { remotionBuckets: [] };
12
12
  }
13
- const remotionBuckets = Buckets.filter((b) => { var _a; return (_a = b.Name) === null || _a === void 0 ? void 0 : _a.startsWith(constants_1.REMOTION_BUCKET_PREFIX); });
13
+ const remotionBuckets = Buckets.filter((b) => {
14
+ var _a;
15
+ if (forceBucketName) {
16
+ return b.Name === forceBucketName;
17
+ }
18
+ return (_a = b.Name) === null || _a === void 0 ? void 0 : _a.startsWith(defaults_1.REMOTION_BUCKET_PREFIX);
19
+ });
14
20
  const locations = await Promise.all(remotionBuckets.map(async (bucket) => {
15
21
  var _a, _b;
16
22
  const { region: parsedRegion } = (0, validate_bucketname_1.parseBucketName)(bucket.Name);
@@ -11,6 +11,9 @@ export type GetCompositionsOnLambdaInput = {
11
11
  logLevel?: LogLevel;
12
12
  timeoutInMilliseconds?: number;
13
13
  forceBucketName?: string;
14
+ /**
15
+ * @deprecated in favor of `logLevel`: true
16
+ */
14
17
  dumpBrowserLogs?: boolean;
15
18
  };
16
19
  export type GetCompositionsOnLambdaOutput = AnyCompMetadata[];
@@ -25,7 +28,6 @@ export type GetCompositionsOnLambdaOutput = AnyCompMetadata[];
25
28
  * @param params.logLevel The log level of the Lambda function
26
29
  * @param params.timeoutInMilliseconds The timeout of the Lambda function
27
30
  * @param params.chromiumOptions The options to pass to Chromium
28
- * @param params.dumpBrowserLogs Whether to print browser logs to CloudWatch
29
31
  * @returns The compositions
30
32
  */
31
33
  export declare const getCompositionsOnLambda: ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, }: GetCompositionsOnLambdaInput) => Promise<GetCompositionsOnLambdaOutput>;
@@ -4,7 +4,7 @@ exports.getCompositionsOnLambda = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const defaults_1 = require("../defaults");
6
6
  const call_lambda_1 = require("../shared/call-lambda");
7
- const serialize_input_props_1 = require("../shared/serialize-input-props");
7
+ const serialize_props_1 = require("../shared/serialize-props");
8
8
  /**
9
9
  * @description Returns the compositions from a serveUrl
10
10
  * @see [Documentation](https://remotion.dev/docs/lambda/getcompositionsonlambda)
@@ -16,16 +16,17 @@ const serialize_input_props_1 = require("../shared/serialize-input-props");
16
16
  * @param params.logLevel The log level of the Lambda function
17
17
  * @param params.timeoutInMilliseconds The timeout of the Lambda function
18
18
  * @param params.chromiumOptions The options to pass to Chromium
19
- * @param params.dumpBrowserLogs Whether to print browser logs to CloudWatch
20
19
  * @returns The compositions
21
20
  */
22
21
  const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, }) => {
23
22
  var _a;
24
- const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
25
- inputProps,
23
+ const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps, 'input-props');
24
+ const serializedInputProps = await (0, serialize_props_1.serializeInputProps)({
25
+ stringifiedInputProps,
26
26
  region,
27
- type: 'still',
28
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
+ propsType: 'input-props',
29
+ needsToUpload: (0, serialize_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
29
30
  });
30
31
  try {
31
32
  const res = await (0, call_lambda_1.callLambda)({
@@ -36,11 +37,10 @@ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inpu
36
37
  serveUrl,
37
38
  envVariables,
38
39
  inputProps: serializedInputProps,
39
- logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
40
+ logLevel: dumpBrowserLogs ? 'verbose' : logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
40
41
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
41
42
  version: version_1.VERSION,
42
43
  bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
43
- dumpBrowserLogs: dumpBrowserLogs !== null && dumpBrowserLogs !== void 0 ? dumpBrowserLogs : false,
44
44
  },
45
45
  region,
46
46
  });
@@ -9,6 +9,7 @@ type Site = {
9
9
  };
10
10
  export type GetSitesInput = {
11
11
  region: AwsRegion;
12
+ forceBucketName?: string;
12
13
  };
13
14
  export type GetSitesOutput = {
14
15
  sites: Site[];
@@ -20,5 +21,5 @@ export type GetSitesOutput = {
20
21
  * @param {AwsRegion} params.region The AWS region that you want to query for.
21
22
  * @returns {Promise<GetSitesOutput>} A Promise containing an object with `sites` and `bucket` keys. Consult documentation for details.
22
23
  */
23
- export declare const getSites: ({ region, }: GetSitesInput) => Promise<GetSitesOutput>;
24
+ export declare const getSites: ({ region, forceBucketName, }: GetSitesInput) => Promise<GetSitesOutput>;
24
25
  export {};
@@ -12,9 +12,11 @@ const get_buckets_1 = require("./get-buckets");
12
12
  * @param {AwsRegion} params.region The AWS region that you want to query for.
13
13
  * @returns {Promise<GetSitesOutput>} A Promise containing an object with `sites` and `bucket` keys. Consult documentation for details.
14
14
  */
15
- const getSites = async ({ region, }) => {
15
+ const getSites = async ({ region, forceBucketName, }) => {
16
16
  var _a;
17
- const { remotionBuckets } = await (0, get_buckets_1.getRemotionS3Buckets)(region);
17
+ const { remotionBuckets } = forceBucketName
18
+ ? await (0, get_buckets_1.getRemotionS3Buckets)(region, forceBucketName)
19
+ : await (0, get_buckets_1.getRemotionS3Buckets)(region);
18
20
  const accountId = await (0, get_account_id_1.getAccountId)({ region });
19
21
  const sites = {};
20
22
  for (const bucket of remotionBuckets) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRenderProgressPayload = exports.makeLambdaRenderMediaPayload = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const defaults_1 = require("../defaults");
6
- const serialize_input_props_1 = require("../shared/serialize-input-props");
6
+ const serialize_props_1 = require("../shared/serialize-props");
7
7
  const validate_download_behavior_1 = require("../shared/validate-download-behavior");
8
8
  const validate_frames_per_lambda_1 = require("../shared/validate-frames-per-lambda");
9
9
  const validate_lambda_codec_1 = require("../shared/validate-lambda-codec");
@@ -19,18 +19,20 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
19
19
  durationInFrames: 1,
20
20
  });
21
21
  (0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
22
- const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
23
- inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
22
+ const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
23
+ const serialized = await (0, serialize_props_1.serializeInputProps)({
24
+ stringifiedInputProps,
24
25
  region,
25
- type: 'video-or-audio',
26
+ needsToUpload: (0, serialize_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
26
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
+ propsType: 'input-props',
27
29
  });
28
30
  return {
29
31
  rendererFunctionName: rendererFunctionName !== null && rendererFunctionName !== void 0 ? rendererFunctionName : null,
30
32
  framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
31
33
  composition,
32
34
  serveUrl,
33
- inputProps: serializedInputProps,
35
+ inputProps: serialized,
34
36
  codec: actualCodec,
35
37
  imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : 'jpeg',
36
38
  crf,
@@ -40,7 +42,7 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
40
42
  jpegQuality,
41
43
  maxRetries: maxRetries !== null && maxRetries !== void 0 ? maxRetries : 1,
42
44
  privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
43
- logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
45
+ logLevel: dumpBrowserLogs ? 'verbose' : logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
44
46
  frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
45
47
  outName: outName !== null && outName !== void 0 ? outName : null,
46
48
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
@@ -60,7 +62,6 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
60
62
  forceWidth: forceWidth !== null && forceWidth !== void 0 ? forceWidth : null,
61
63
  bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
62
64
  audioCodec: audioCodec !== null && audioCodec !== void 0 ? audioCodec : null,
63
- dumpBrowserLogs: dumpBrowserLogs !== null && dumpBrowserLogs !== void 0 ? dumpBrowserLogs : false,
64
65
  type: defaults_1.LambdaRoutines.start,
65
66
  };
66
67
  };
@@ -46,6 +46,9 @@ export type RenderMediaOnLambdaInput = {
46
46
  rendererFunctionName?: string | null;
47
47
  forceBucketName?: string;
48
48
  audioCodec?: AudioCodec | null;
49
+ /**
50
+ * @deprecated in favor of `logLevel`: true
51
+ */
49
52
  dumpBrowserLogs?: boolean;
50
53
  };
51
54
  export type RenderMediaOnLambdaOutput = {
@@ -71,7 +74,6 @@ export type RenderMediaOnLambdaOutput = {
71
74
  * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
72
75
  * @param params.logLevel Level of logging that Lambda function should perform. Default "info".
73
76
  * @param params.webhook Configuration for webhook called upon completion or timeout of the render.
74
- * @param params.dumpBrowserLogs Whether to print browser logs to CloudWatch
75
77
  * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
76
78
  */
77
79
  export declare const renderMediaOnLambda: (input: RenderMediaOnLambdaInput) => Promise<RenderMediaOnLambdaOutput>;
@@ -22,7 +22,6 @@ const make_lambda_payload_1 = require("./make-lambda-payload");
22
22
  * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
23
23
  * @param params.logLevel Level of logging that Lambda function should perform. Default "info".
24
24
  * @param params.webhook Configuration for webhook called upon completion or timeout of the render.
25
- * @param params.dumpBrowserLogs Whether to print browser logs to CloudWatch
26
25
  * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
27
26
  */
28
27
  const renderMediaOnLambda = async (input) => {
@@ -27,6 +27,9 @@ export type RenderStillOnLambdaInput = {
27
27
  forceWidth?: number | null;
28
28
  forceHeight?: number | null;
29
29
  forceBucketName?: string;
30
+ /**
31
+ * @deprecated Renamed to `dumpBrowserLogs`
32
+ */
30
33
  dumpBrowserLogs?: boolean;
31
34
  };
32
35
  export type RenderStillOnLambdaOutput = {
@@ -51,7 +54,6 @@ export type RenderStillOnLambdaOutput = {
51
54
  * @param params.maxRetries How often rendering a chunk may fail before the video render gets aborted.
52
55
  * @param params.frame Which frame should be used for the still image. Default 0.
53
56
  * @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
54
- * @param params.dumpBrowserLogs Whether to print browser logs to CloudWatch.
55
57
  * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
56
58
  */
57
59
  export declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
@@ -5,7 +5,7 @@ const version_1 = require("remotion/version");
5
5
  const call_lambda_1 = require("../shared/call-lambda");
6
6
  const constants_1 = require("../shared/constants");
7
7
  const get_aws_urls_1 = require("../shared/get-aws-urls");
8
- const serialize_input_props_1 = require("../shared/serialize-input-props");
8
+ const serialize_props_1 = require("../shared/serialize-props");
9
9
  /**
10
10
  * @description Renders a still frame on Lambda
11
11
  * @link https://remotion.dev/docs/lambda/renderstillonlambda
@@ -20,7 +20,6 @@ const serialize_input_props_1 = require("../shared/serialize-input-props");
20
20
  * @param params.maxRetries How often rendering a chunk may fail before the video render gets aborted.
21
21
  * @param params.frame Which frame should be used for the still image. Default 0.
22
22
  * @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
23
- * @param params.dumpBrowserLogs Whether to print browser logs to CloudWatch.
24
23
  * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
25
24
  */
26
25
  const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, }) => {
@@ -28,11 +27,13 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
28
27
  if (quality) {
29
28
  throw new Error('The `quality` option is deprecated. Use `jpegQuality` instead.');
30
29
  }
31
- const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
32
- inputProps,
30
+ const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps, 'input-props');
31
+ const serializedInputProps = await (0, serialize_props_1.serializeInputProps)({
32
+ stringifiedInputProps,
33
33
  region,
34
- type: 'still',
34
+ needsToUpload: (0, serialize_props_1.getNeedsToUpload)('still', stringifiedInputProps),
35
35
  userSpecifiedBucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
36
+ propsType: 'input-props',
36
37
  });
37
38
  try {
38
39
  const res = await (0, call_lambda_1.callLambda)({
@@ -49,7 +50,7 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
49
50
  frame: frame !== null && frame !== void 0 ? frame : 0,
50
51
  privacy,
51
52
  attempt: 1,
52
- logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
53
+ logLevel: dumpBrowserLogs ? 'verbose' : logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
53
54
  outName: outName !== null && outName !== void 0 ? outName : null,
54
55
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
55
56
  chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
@@ -59,7 +60,6 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
59
60
  forceHeight: forceHeight !== null && forceHeight !== void 0 ? forceHeight : null,
60
61
  forceWidth: forceWidth !== null && forceWidth !== void 0 ? forceWidth : null,
61
62
  bucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
62
- dumpBrowserLogs: dumpBrowserLogs !== null && dumpBrowserLogs !== void 0 ? dumpBrowserLogs : false,
63
63
  },
64
64
  region,
65
65
  });
@@ -45,7 +45,7 @@ const renderCommand = async (args, remotionRoot) => {
45
45
  indent: false,
46
46
  port,
47
47
  remotionRoot,
48
- verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
48
+ logLevel,
49
49
  webpackConfigOrServeUrl: serveUrl,
50
50
  });
51
51
  const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
@@ -61,7 +61,7 @@ const renderCommand = async (args, remotionRoot) => {
61
61
  puppeteerInstance: undefined,
62
62
  serveUrlOrWebpackUrl: serveUrl,
63
63
  timeoutInMilliseconds: puppeteerTimeout,
64
- verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
64
+ logLevel,
65
65
  width,
66
66
  server: await server,
67
67
  });
@@ -90,6 +90,7 @@ const sitesCreateSubcommand = async (args, remotionRoot) => {
90
90
  },
91
91
  enableCaching: config_1.ConfigInternals.getWebpackCaching(),
92
92
  webpackOverride: (_c = config_1.ConfigInternals.getWebpackOverrideFn()) !== null && _c !== void 0 ? _c : ((f) => f),
93
+ bypassBucketNameValidation: Boolean(args_1.parsedLambdaCli['force-bucket-name']),
93
94
  },
94
95
  region: (0, get_aws_region_1.getAwsRegion)(),
95
96
  privacy: args_1.parsedLambdaCli.privacy,
@@ -24,9 +24,10 @@ const sitesRmSubcommand = async (args) => {
24
24
  const region = (0, get_aws_region_1.getAwsRegion)();
25
25
  const deployedSites = await (0, get_sites_1.getSites)({
26
26
  region,
27
+ forceBucketName: args_1.parsedLambdaCli['force-bucket-name'],
27
28
  });
29
+ const bucketName = (_a = args_1.parsedLambdaCli['force-bucket-name']) !== null && _a !== void 0 ? _a : (await (0, get_or_create_bucket_1.getOrCreateBucket)({ region })).bucketName;
28
30
  for (const siteName of args) {
29
- const bucketName = (_a = args_1.parsedLambdaCli['force-bucket-name']) !== null && _a !== void 0 ? _a : (await (0, get_or_create_bucket_1.getOrCreateBucket)({ region })).bucketName;
30
31
  const site = deployedSites.sites.find((s) => s.id === siteName.trim());
31
32
  if (!site) {
32
33
  log_1.Log.error(`No site ${siteName.trim()} was found in your bucket ${bucketName}.`);
@@ -41,7 +41,7 @@ const stillCommand = async (args, remotionRoot) => {
41
41
  indent: false,
42
42
  port,
43
43
  remotionRoot,
44
- verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
44
+ logLevel,
45
45
  webpackConfigOrServeUrl: serveUrl,
46
46
  });
47
47
  const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
@@ -49,7 +49,7 @@ const stillCommand = async (args, remotionRoot) => {
49
49
  compositionIdFromUi: null,
50
50
  indent: false,
51
51
  serveUrlOrWebpackUrl: serveUrl,
52
- verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
52
+ logLevel,
53
53
  browserExecutable,
54
54
  chromiumOptions,
55
55
  envVariables,
package/dist/cli/log.d.ts CHANGED
@@ -2,20 +2,19 @@ export declare const Log: {
2
2
  verbose: (message?: any, ...optionalParams: any[]) => void;
3
3
  verboseAdvanced: (options: {
4
4
  indent: boolean;
5
- logLevel: "error" | "verbose" | "info" | "warn";
5
+ logLevel: "warn" | "error" | "verbose" | "info";
6
6
  } & {
7
7
  tag?: string | undefined;
8
- secondTag?: string | undefined;
9
8
  }, message?: any, ...optionalParams: any[]) => void;
10
9
  info: (message?: any, ...optionalParams: any[]) => void;
11
10
  infoAdvanced: (options: {
12
11
  indent: boolean;
13
- logLevel: "error" | "verbose" | "info" | "warn";
12
+ logLevel: "warn" | "error" | "verbose" | "info";
14
13
  }, message?: any, ...optionalParams: any[]) => void;
15
14
  warn: (message?: any, ...optionalParams: any[]) => void;
16
15
  warnAdvanced: (options: {
17
16
  indent: boolean;
18
- logLevel: "error" | "verbose" | "info" | "warn";
17
+ logLevel: "warn" | "error" | "verbose" | "info";
19
18
  }, message?: any, ...optionalParams: any[]) => void;
20
19
  error: (message?: any, ...optionalParams: any[]) => void;
21
20
  };
@@ -3,5 +3,8 @@ export declare const planFrameRanges: ({ framesPerLambda, frameRange, everyNthFr
3
3
  frameRange: [number, number];
4
4
  everyNthFrame: number;
5
5
  }) => {
6
- chunks: [number, number][];
6
+ chunks: [
7
+ number,
8
+ number
9
+ ][];
7
10
  };
@@ -3,6 +3,6 @@ type Options = {
3
3
  expectedBucketOwner: string;
4
4
  };
5
5
  export declare const compositionsHandler: (lambdaParams: LambdaPayload, options: Options) => Promise<{
6
- compositions: import("remotion").AnyCompMetadata[];
6
+ compositions: import("remotion").VideoConfig[];
7
7
  }>;
8
8
  export {};
@@ -6,11 +6,11 @@ const version_1 = require("remotion/version");
6
6
  const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
7
7
  const defaults_1 = require("../defaults");
8
8
  const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
9
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
10
9
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
11
10
  const get_current_region_1 = require("./helpers/get-current-region");
11
+ const serialize_props_1 = require("../shared/serialize-props");
12
12
  const compositionsHandler = async (lambdaParams, options) => {
13
- var _a, _b, _c, _d;
13
+ var _a, _b, _c;
14
14
  if (lambdaParams.type !== defaults_1.LambdaRoutines.compositions) {
15
15
  throw new TypeError('Expected info compositions');
16
16
  }
@@ -21,18 +21,18 @@ const compositionsHandler = async (lambdaParams, options) => {
21
21
  throw new Error(`Version mismatch: When calling getCompositionsOnLambda(), you passed ${process.env.AWS_LAMBDA_FUNCTION_NAME} as the function, which has the version ${version_1.VERSION}, but the @remotion/lambda package you used to invoke the function has version ${lambdaParams.version}. Deploy a new function and use it to call getCompositionsOnLambda(). See: https://www.remotion.dev/docs/lambda/upgrading`);
22
22
  }
23
23
  const region = (0, get_current_region_1.getCurrentRegionInFunction)();
24
- const verbose = renderer_1.RenderInternals.isEqualOrBelowLogLevel(lambdaParams.logLevel, 'verbose');
25
24
  const [bucketName, browserInstance] = await Promise.all([
26
25
  (_a = lambdaParams.bucketName) !== null && _a !== void 0 ? _a : (0, get_or_create_bucket_1.getOrCreateBucket)({
27
26
  region,
28
27
  }).then((b) => b.bucketName),
29
- (0, get_browser_instance_1.getBrowserInstance)((_b = lambdaParams.dumpBrowserLogs) !== null && _b !== void 0 ? _b : verbose, (_c = lambdaParams.chromiumOptions) !== null && _c !== void 0 ? _c : {}),
28
+ (0, get_browser_instance_1.getBrowserInstance)(lambdaParams.logLevel, false, (_b = lambdaParams.chromiumOptions) !== null && _b !== void 0 ? _b : {}),
30
29
  ]);
31
- const inputProps = await (0, deserialize_input_props_1.deserializeInputProps)({
30
+ const inputProps = await (0, serialize_props_1.deserializeInputProps)({
32
31
  bucketName,
33
32
  expectedBucketOwner: options.expectedBucketOwner,
34
33
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
35
34
  serialized: lambdaParams.inputProps,
35
+ propsType: 'input-props',
36
36
  });
37
37
  const realServeUrl = (0, convert_to_serve_url_1.convertToServeUrl)({
38
38
  urlOrId: lambdaParams.serveUrl,
@@ -43,12 +43,12 @@ const compositionsHandler = async (lambdaParams, options) => {
43
43
  serveUrlOrWebpackUrl: realServeUrl,
44
44
  puppeteerInstance: browserInstance,
45
45
  inputProps,
46
- envVariables: (_d = lambdaParams.envVariables) !== null && _d !== void 0 ? _d : {},
46
+ envVariables: (_c = lambdaParams.envVariables) !== null && _c !== void 0 ? _c : {},
47
47
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
48
48
  chromiumOptions: lambdaParams.chromiumOptions,
49
49
  port: null,
50
50
  server: undefined,
51
- verbose,
51
+ logLevel: lambdaParams.logLevel,
52
52
  indent: false,
53
53
  browserExecutable: null,
54
54
  onBrowserLog: null,
@@ -1,2 +1,2 @@
1
- import type { ChromiumOptions, openBrowser } from '@remotion/renderer';
2
- export declare const getBrowserInstance: (shouldDumpIo: boolean, chromiumOptions: ChromiumOptions) => ReturnType<typeof openBrowser>;
1
+ import type { ChromiumOptions, LogLevel, openBrowser } from '@remotion/renderer';
2
+ export declare const getBrowserInstance: (logLevel: LogLevel, indent: boolean, chromiumOptions: ChromiumOptions) => ReturnType<typeof openBrowser>;
@@ -19,7 +19,7 @@ const waitForLaunched = () => {
19
19
  check();
20
20
  });
21
21
  };
22
- const getBrowserInstance = async (shouldDumpIo, chromiumOptions) => {
22
+ const getBrowserInstance = async (logLevel, indent, chromiumOptions) => {
23
23
  var _a;
24
24
  if (launching) {
25
25
  await waitForLaunched();
@@ -41,15 +41,15 @@ const getBrowserInstance = async (shouldDumpIo, chromiumOptions) => {
41
41
  _browserInstance = await renderer_1.RenderInternals.internalOpenBrowser({
42
42
  browser: 'chrome',
43
43
  browserExecutable: execPath,
44
- shouldDumpIo,
45
44
  chromiumOptions: actualChromiumOptions,
46
45
  forceDeviceScaleFactor: undefined,
47
46
  indent: false,
48
47
  viewport: null,
48
+ logLevel,
49
49
  });
50
50
  _browserInstance.on('disconnected', () => {
51
51
  console.log('Browser disconnected / crashed');
52
- _browserInstance === null || _browserInstance === void 0 ? void 0 : _browserInstance.close(true).catch(() => undefined);
52
+ _browserInstance === null || _browserInstance === void 0 ? void 0 : _browserInstance.close(true, logLevel, indent).catch(() => undefined);
53
53
  _browserInstance = null;
54
54
  });
55
55
  launching = false;
@@ -1 +1 @@
1
- export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "sa-east-1" | "eu-south-1" | "af-south-1" | "ap-east-1" | "me-south-1";
1
+ export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printCloudwatchHelper = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
4
5
  const printCloudwatchHelper = (type, data) => {
5
6
  const d = Object.keys(data).reduce((a, b) => {
6
7
  return [...a, `${b}=${data[b]}`];
7
8
  }, []);
8
9
  const msg = [`method=${type}`, ...d].join(',');
9
- console.log(msg);
10
+ renderer_1.RenderInternals.Log.info(msg);
10
11
  };
11
12
  exports.printCloudwatchHelper = printCloudwatchHelper;
@@ -1,5 +1,5 @@
1
1
  import type { ChromiumOptions, LogLevel, openBrowser, RemotionServer } from '@remotion/renderer';
2
- import type { AnyCompMetadata } from 'remotion';
2
+ import type { VideoConfig } from 'remotion';
3
3
  import type { Await } from '../../shared/await';
4
4
  type ValidateCompositionOptions = {
5
5
  serveUrl: string;
@@ -15,5 +15,5 @@ type ValidateCompositionOptions = {
15
15
  logLevel: LogLevel;
16
16
  server: RemotionServer | undefined;
17
17
  };
18
- export declare const validateComposition: ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<AnyCompMetadata>;
18
+ export declare const validateComposition: ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<VideoConfig>;
19
19
  export {};
@@ -4,7 +4,7 @@ exports.validateComposition = void 0;
4
4
  const renderer_1 = require("@remotion/renderer");
5
5
  const get_chromium_executable_path_1 = require("./get-chromium-executable-path");
6
6
  const validateComposition = async ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
7
- const comp = await renderer_1.RenderInternals.internalSelectComposition({
7
+ const { metadata: comp } = await renderer_1.RenderInternals.internalSelectComposition({
8
8
  id: composition,
9
9
  puppeteerInstance: browserInstance,
10
10
  inputProps,
@@ -14,7 +14,7 @@ const validateComposition = async ({ serveUrl, composition, browserInstance, inp
14
14
  port,
15
15
  browserExecutable: (0, get_chromium_executable_path_1.executablePath)(),
16
16
  serveUrl,
17
- verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
17
+ logLevel,
18
18
  indent: false,
19
19
  onBrowserLog: null,
20
20
  server,
@@ -23,6 +23,8 @@ const validateComposition = async ({ serveUrl, composition, browserInstance, inp
23
23
  ...comp,
24
24
  height: forceHeight !== null && forceHeight !== void 0 ? forceHeight : comp.height,
25
25
  width: forceWidth !== null && forceWidth !== void 0 ? forceWidth : comp.width,
26
+ defaultProps: comp.defaultProps,
27
+ props: comp.props,
26
28
  };
27
29
  };
28
30
  exports.validateComposition = validateComposition;
@@ -79,7 +79,7 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
79
79
  renderId: params.renderId,
80
80
  chunk: String(params.chunk),
81
81
  dumpLogs: String(renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose')),
82
- inputProps: JSON.stringify(params.inputProps),
82
+ resolvedProps: JSON.stringify(params.resolvedProps),
83
83
  isWarm,
84
84
  });
85
85
  await (0, renderer_2.rendererHandler)(params, {
@@ -33,7 +33,6 @@ const version_1 = require("remotion/version");
33
33
  const aws_clients_1 = require("../shared/aws-clients");
34
34
  const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
35
35
  const constants_1 = require("../shared/constants");
36
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
37
36
  const docs_url_1 = require("../shared/docs-url");
38
37
  const invoke_webhook_1 = require("../shared/invoke-webhook");
39
38
  const make_s3_url_1 = require("../shared/make-s3-url");
@@ -57,6 +56,7 @@ const timer_1 = require("./helpers/timer");
57
56
  const validate_composition_1 = require("./helpers/validate-composition");
58
57
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
59
58
  const write_post_render_data_1 = require("./helpers/write-post-render-data");
59
+ const serialize_props_1 = require("../shared/serialize-props");
60
60
  const callFunctionWithRetry = async ({ payload, retries, functionName, }) => {
61
61
  try {
62
62
  await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
@@ -135,12 +135,13 @@ const innerLaunchHandler = async (params, options) => {
135
135
  }
136
136
  }
137
137
  }, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
138
- const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(verbose, params.chromiumOptions);
139
- const inputPropsPromise = (0, deserialize_input_props_1.deserializeInputProps)({
138
+ const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, params.chromiumOptions);
139
+ const inputPropsPromise = (0, serialize_props_1.deserializeInputProps)({
140
140
  bucketName: params.bucketName,
141
141
  expectedBucketOwner: options.expectedBucketOwner,
142
142
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
143
143
  serialized: params.inputProps,
144
+ propsType: 'input-props',
144
145
  });
145
146
  const comp = await (0, validate_composition_1.validateComposition)({
146
147
  serveUrl: params.serveUrl,
@@ -188,6 +189,25 @@ const innerLaunchHandler = async (params, options) => {
188
189
  });
189
190
  const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
190
191
  const reqSend = (0, timer_1.timer)('sending off requests');
192
+ const serializedResolved = (0, serialize_props_1.serializeOrThrow)(comp.props, 'resolved-props');
193
+ const serializedDefault = (0, serialize_props_1.serializeOrThrow)(comp.defaultProps, 'default-props');
194
+ const needsToUpload = (0, serialize_props_1.getNeedsToUpload)('video-or-audio', serializedResolved + serializedDefault);
195
+ const [serializedResolvedProps, serializedDefaultProps] = await Promise.all([
196
+ (0, serialize_props_1.serializeInputProps)({
197
+ propsType: 'resolved-props',
198
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
199
+ stringifiedInputProps: serializedResolved,
200
+ userSpecifiedBucketName: params.bucketName,
201
+ needsToUpload,
202
+ }),
203
+ (0, serialize_props_1.serializeInputProps)({
204
+ propsType: 'default-props',
205
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
206
+ stringifiedInputProps: serializedDefault,
207
+ userSpecifiedBucketName: params.bucketName,
208
+ needsToUpload,
209
+ }),
210
+ ]);
191
211
  const lambdaPayloads = chunks.map((chunkPayload) => {
192
212
  var _a;
193
213
  const payload = {
@@ -225,7 +245,8 @@ const innerLaunchHandler = async (params, options) => {
225
245
  launchFunctionConfig: {
226
246
  version: version_1.VERSION,
227
247
  },
228
- dumpBrowserLogs: params.dumpBrowserLogs,
248
+ resolvedProps: serializedResolvedProps,
249
+ defaultProps: serializedDefaultProps,
229
250
  };
230
251
  return payload;
231
252
  });
@@ -12,12 +12,12 @@ const version_1 = require("remotion/version");
12
12
  const aws_clients_1 = require("../shared/aws-clients");
13
13
  const chunk_progress_1 = require("../shared/chunk-progress");
14
14
  const constants_1 = require("../shared/constants");
15
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
16
15
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
17
16
  const get_chromium_executable_path_1 = require("./helpers/get-chromium-executable-path");
18
17
  const get_current_region_1 = require("./helpers/get-current-region");
19
18
  const io_1 = require("./helpers/io");
20
19
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
20
+ const serialize_props_1 = require("../shared/serialize-props");
21
21
  const renderHandler = async (params, options, logs) => {
22
22
  var _a;
23
23
  if (params.type !== constants_1.LambdaRoutines.renderer) {
@@ -26,13 +26,28 @@ const renderHandler = async (params, options, logs) => {
26
26
  if (params.launchFunctionConfig.version !== version_1.VERSION) {
27
27
  throw new Error(`The version of the function that was specified as "rendererFunctionName" is ${version_1.VERSION} but the version of the function that invoked the render is ${params.launchFunctionConfig.version}. Please make sure that the version of the function that is specified as "rendererFunctionName" is the same as the version of the function that is invoked.`);
28
28
  }
29
- const inputPropsPromise = (0, deserialize_input_props_1.deserializeInputProps)({
29
+ const inputPropsPromise = (0, serialize_props_1.deserializeInputProps)({
30
30
  bucketName: params.bucketName,
31
31
  expectedBucketOwner: options.expectedBucketOwner,
32
32
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
33
33
  serialized: params.inputProps,
34
+ propsType: 'input-props',
34
35
  });
35
- const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose'), (_a = params.chromiumOptions) !== null && _a !== void 0 ? _a : {});
36
+ const resolvedPropsPromise = (0, serialize_props_1.deserializeInputProps)({
37
+ bucketName: params.bucketName,
38
+ expectedBucketOwner: options.expectedBucketOwner,
39
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
40
+ serialized: params.resolvedProps,
41
+ propsType: 'resolved-props',
42
+ });
43
+ const defaultPropsPromise = (0, serialize_props_1.deserializeInputProps)({
44
+ bucketName: params.bucketName,
45
+ expectedBucketOwner: options.expectedBucketOwner,
46
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
47
+ serialized: params.defaultProps,
48
+ propsType: 'default-props',
49
+ });
50
+ const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, (_a = params.chromiumOptions) !== null && _a !== void 0 ? _a : {});
36
51
  const outputPath = renderer_1.RenderInternals.tmpDir('remotion-render-');
37
52
  if (typeof params.chunk !== 'number') {
38
53
  throw new Error('must pass chunk');
@@ -57,8 +72,10 @@ const renderHandler = async (params, options, logs) => {
57
72
  }))}`);
58
73
  const downloads = {};
59
74
  const inputProps = await inputPropsPromise;
75
+ const resolvedProps = await resolvedPropsPromise;
76
+ const defaultProps = await defaultPropsPromise;
60
77
  await new Promise((resolve, reject) => {
61
- var _a, _b, _c, _d, _e;
78
+ var _a, _b, _c, _d;
62
79
  renderer_1.RenderInternals.internalRenderMedia({
63
80
  composition: {
64
81
  id: params.composition,
@@ -66,6 +83,8 @@ const renderHandler = async (params, options, logs) => {
66
83
  fps: params.fps,
67
84
  height: params.height,
68
85
  width: params.width,
86
+ props: resolvedProps,
87
+ defaultProps,
69
88
  },
70
89
  imageFormat: params.imageFormat,
71
90
  inputProps,
@@ -104,15 +123,14 @@ const renderHandler = async (params, options, logs) => {
104
123
  serveUrl: params.serveUrl,
105
124
  jpegQuality: (_a = params.jpegQuality) !== null && _a !== void 0 ? _a : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
106
125
  envVariables: (_b = params.envVariables) !== null && _b !== void 0 ? _b : {},
107
- dumpBrowserLogs: (_c = params.dumpBrowserLogs) !== null && _c !== void 0 ? _c : renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose'),
108
- verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose'),
126
+ logLevel: params.logLevel,
109
127
  onBrowserLog: (log) => {
110
128
  logs.push(log);
111
129
  },
112
130
  outputLocation,
113
131
  codec: chunkCodec,
114
- crf: (_d = params.crf) !== null && _d !== void 0 ? _d : null,
115
- pixelFormat: (_e = params.pixelFormat) !== null && _e !== void 0 ? _e : renderer_1.RenderInternals.DEFAULT_PIXEL_FORMAT,
132
+ crf: (_c = params.crf) !== null && _c !== void 0 ? _c : null,
133
+ pixelFormat: (_d = params.pixelFormat) !== null && _d !== void 0 ? _d : renderer_1.RenderInternals.DEFAULT_PIXEL_FORMAT,
116
134
  proResProfile: params.proResProfile,
117
135
  onDownload: (src) => {
118
136
  console.log('Downloading', src);
@@ -160,10 +178,9 @@ const renderHandler = async (params, options, logs) => {
160
178
  server: undefined,
161
179
  })
162
180
  .then(({ slowestFrames }) => {
163
- console.log();
164
181
  console.log(`Slowest frames:`);
165
182
  slowestFrames.forEach(({ frame, time }) => {
166
- console.log(`Frame ${frame} (${time.toFixed(3)}ms)`);
183
+ console.log(` Frame ${frame} (${time.toFixed(3)}ms)`);
167
184
  });
168
185
  resolve();
169
186
  })
@@ -77,7 +77,6 @@ const startHandler = async (params, options) => {
77
77
  forceWidth: params.forceWidth,
78
78
  rendererFunctionName: params.rendererFunctionName,
79
79
  audioCodec: params.audioCodec,
80
- dumpBrowserLogs: params.dumpBrowserLogs,
81
80
  };
82
81
  await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
83
82
  FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
@@ -15,7 +15,6 @@ const aws_clients_1 = require("../shared/aws-clients");
15
15
  const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
16
16
  const constants_1 = require("../shared/constants");
17
17
  const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
18
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
19
18
  const make_s3_url_1 = require("../shared/make-s3-url");
20
19
  const random_hash_1 = require("../shared/random-hash");
21
20
  const validate_download_behavior_1 = require("../shared/validate-download-behavior");
@@ -30,8 +29,9 @@ const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-me
30
29
  const io_1 = require("./helpers/io");
31
30
  const validate_composition_1 = require("./helpers/validate-composition");
32
31
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
32
+ const serialize_props_1 = require("../shared/serialize-props");
33
33
  const innerStillHandler = async (lambdaParams, renderId, options) => {
34
- var _a, _b, _c, _d, _e, _f, _g;
34
+ var _a, _b, _c, _d, _e, _f;
35
35
  if (lambdaParams.type !== constants_1.LambdaRoutines.still) {
36
36
  throw new TypeError('Expected still type');
37
37
  }
@@ -49,29 +49,29 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
49
49
  (_a = lambdaParams.bucketName) !== null && _a !== void 0 ? _a : (0, get_or_create_bucket_1.getOrCreateBucket)({
50
50
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
51
51
  }).then((b) => b.bucketName),
52
- (0, get_browser_instance_1.getBrowserInstance)(renderer_1.RenderInternals.isEqualOrBelowLogLevel(lambdaParams.logLevel, 'verbose'), (_b = lambdaParams.chromiumOptions) !== null && _b !== void 0 ? _b : {}),
52
+ (0, get_browser_instance_1.getBrowserInstance)(lambdaParams.logLevel, false, (_b = lambdaParams.chromiumOptions) !== null && _b !== void 0 ? _b : {}),
53
53
  ]);
54
54
  const outputDir = renderer_1.RenderInternals.tmpDir('remotion-render-');
55
55
  const outputPath = node_path_1.default.join(outputDir, 'output');
56
56
  const region = (0, get_current_region_1.getCurrentRegionInFunction)();
57
- const inputProps = await (0, deserialize_input_props_1.deserializeInputProps)({
57
+ const inputProps = await (0, serialize_props_1.deserializeInputProps)({
58
58
  bucketName,
59
59
  expectedBucketOwner: options.expectedBucketOwner,
60
60
  region,
61
61
  serialized: lambdaParams.inputProps,
62
+ propsType: 'input-props',
62
63
  });
63
64
  const serveUrl = (0, convert_to_serve_url_1.convertToServeUrl)({
64
65
  urlOrId: lambdaParams.serveUrl,
65
66
  region,
66
67
  bucketName,
67
68
  });
68
- const verbose = renderer_1.RenderInternals.isEqualOrBelowLogLevel(lambdaParams.logLevel, 'verbose');
69
69
  const server = await renderer_1.RenderInternals.prepareServer({
70
70
  concurrency: 1,
71
71
  indent: false,
72
72
  port: null,
73
73
  remotionRoot: process.cwd(),
74
- verbose,
74
+ logLevel: lambdaParams.logLevel,
75
75
  webpackConfigOrServeUrl: serveUrl,
76
76
  });
77
77
  const composition = await (0, validate_composition_1.validateComposition)({
@@ -125,8 +125,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
125
125
  composition,
126
126
  output: outputPath,
127
127
  serveUrl,
128
- dumpBrowserLogs: (_e = lambdaParams.dumpBrowserLogs) !== null && _e !== void 0 ? _e : verbose,
129
- envVariables: (_f = lambdaParams.envVariables) !== null && _f !== void 0 ? _f : {},
128
+ envVariables: (_e = lambdaParams.envVariables) !== null && _e !== void 0 ? _e : {},
130
129
  frame: renderer_1.RenderInternals.convertToPositiveFrameIndex({
131
130
  frame: lambdaParams.frame,
132
131
  durationInFrames: composition.durationInFrames,
@@ -135,7 +134,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
135
134
  inputProps,
136
135
  overwrite: false,
137
136
  puppeteerInstance: browserInstance,
138
- jpegQuality: (_g = lambdaParams.jpegQuality) !== null && _g !== void 0 ? _g : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
137
+ jpegQuality: (_f = lambdaParams.jpegQuality) !== null && _f !== void 0 ? _f : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
139
138
  chromiumOptions: lambdaParams.chromiumOptions,
140
139
  scale: lambdaParams.scale,
141
140
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
@@ -146,7 +145,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
146
145
  onDownload: null,
147
146
  port: null,
148
147
  server,
149
- verbose,
148
+ logLevel: lambdaParams.logLevel,
150
149
  });
151
150
  const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, (0, expected_out_name_1.getCredentialsFromOutName)(lambdaParams.outName));
152
151
  const { size } = await node_fs_1.default.promises.stat(outputPath);
package/dist/index.d.ts CHANGED
@@ -55,6 +55,6 @@ declare const presignUrl: <CheckIfObjectExists extends boolean = false>({ region
55
55
  /**
56
56
  * @deprecated Import this from `@remotion/lambda/client` instead
57
57
  */
58
- declare const getSites: ({ region, }: GetSitesInput) => Promise<GetSitesOutput>;
58
+ declare const getSites: ({ region, forceBucketName, }: GetSitesInput) => Promise<GetSitesOutput>;
59
59
  export { deleteSite, deployFunction, deploySite, downloadMedia, getFunctions, getUserPolicy, getRolePolicy, getSites, getOrCreateBucket, getRenderProgress, renderVideoOnLambda, renderMediaOnLambda, simulatePermissions, deleteFunction, getFunctionInfo, estimatePrice, LambdaInternals, renderStillOnLambda, getRegions, getAwsClient, presignUrl, deleteRender, validateWebhookSignature, getCompositionsOnLambda, };
60
60
  export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput, GetRenderInput, RenderMediaOnLambdaInput, RenderMediaOnLambdaOutput, RenderStillOnLambdaInput, RenderStillOnLambdaOutput, SimulatePermissionsInput, SimulatePermissionsOutput, GetAwsClientInput, GetAwsClientOutput, CustomCredentials, WebhookPayload, LambdaErrorInfo, EnhancedErrorInfo, DeleteRenderInput, GetCompositionsOnLambdaOutput, GetCompositionsOnLambdaInput, };
@@ -79,7 +79,9 @@ export declare const outName: (renderId: string, extension: string) => string;
79
79
  export declare const outStillName: (renderId: string, imageFormat: StillImageFormat) => string;
80
80
  export declare const customOutName: (renderId: string, bucketName: string, name: OutNameInput) => OutNameOutput;
81
81
  export declare const postRenderDataKey: (renderId: string) => string;
82
+ export declare const defaultPropsKey: (hash: string) => string;
82
83
  export declare const inputPropsKey: (hash: string) => string;
84
+ export declare const resolvedPropsKey: (hash: string) => string;
83
85
  export declare const RENDERER_PATH_TOKEN = "remotion-bucket";
84
86
  export declare const CONCAT_FOLDER_TOKEN = "remotion-concat";
85
87
  export declare const REMOTION_CONCATED_TOKEN = "remotion-concated-token";
@@ -102,7 +104,7 @@ export type SerializedInputProps = {
102
104
  hash: string;
103
105
  } | {
104
106
  type: 'payload';
105
- payload: unknown;
107
+ payload: string;
106
108
  };
107
109
  export type LambdaStartPayload = {
108
110
  rendererFunctionName: string | null;
@@ -140,7 +142,6 @@ export type LambdaStartPayload = {
140
142
  forceHeight: number | null;
141
143
  forceWidth: number | null;
142
144
  bucketName: string | null;
143
- dumpBrowserLogs: boolean;
144
145
  };
145
146
  export type LambdaStatusPayload = {
146
147
  type: LambdaRoutines.status;
@@ -190,7 +191,6 @@ export type LambdaPayloads = {
190
191
  webhook: WebhookOption;
191
192
  forceHeight: number | null;
192
193
  forceWidth: number | null;
193
- dumpBrowserLogs: boolean;
194
194
  };
195
195
  status: LambdaStatusPayload;
196
196
  renderer: {
@@ -220,6 +220,8 @@ export type LambdaPayloads = {
220
220
  logLevel: LogLevel;
221
221
  timeoutInMilliseconds: number;
222
222
  chromiumOptions: ChromiumOptions;
223
+ resolvedProps: SerializedInputProps;
224
+ defaultProps: SerializedInputProps;
223
225
  scale: number;
224
226
  everyNthFrame: number;
225
227
  muted: boolean;
@@ -228,7 +230,6 @@ export type LambdaPayloads = {
228
230
  launchFunctionConfig: {
229
231
  version: string;
230
232
  };
231
- dumpBrowserLogs: boolean;
232
233
  };
233
234
  still: {
234
235
  type: LambdaRoutines.still;
@@ -252,7 +253,6 @@ export type LambdaPayloads = {
252
253
  forceHeight: number | null;
253
254
  forceWidth: number | null;
254
255
  bucketName: string | null;
255
- dumpBrowserLogs: boolean;
256
256
  };
257
257
  compositions: {
258
258
  type: LambdaRoutines.compositions;
@@ -264,7 +264,6 @@ export type LambdaPayloads = {
264
264
  timeoutInMilliseconds: number;
265
265
  serveUrl: string;
266
266
  bucketName: string | null;
267
- dumpBrowserLogs: boolean;
268
267
  };
269
268
  };
270
269
  export type LambdaPayload = LambdaPayloads[LambdaRoutines];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LAMBDA_BURST_LIMIT_QUOTA = exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.LambdaRoutines = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.inputPropsKey = exports.postRenderDataKey = exports.customOutName = exports.outStillName = exports.outName = exports.getSitesKey = exports.getErrorFileName = exports.getErrorKeyPrefix = exports.chunkKeyForIndex = exports.chunkKey = exports.lambdaTimingsKey = exports.lambdaLogsPrefix = exports.lambdaTimingsPrefixForChunk = exports.lambdaTimingsPrefix = exports.lambdaChunkInitializedKey = exports.lambdaChunkInitializedPrefix = exports.initalizedMetadataKey = exports.renderMetadataKey = exports.encodingProgressKey = exports.rendersPrefix = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.REMOTION_BUCKET_PREFIX = exports.ENCODING_PROGRESS_STEP_SIZE = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_FUNCTIONS_PER_RENDER = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.COMMAND_NOT_FOUND = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MINIMUM_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
3
+ exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.LambdaRoutines = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.resolvedPropsKey = exports.inputPropsKey = exports.defaultPropsKey = exports.postRenderDataKey = exports.customOutName = exports.outStillName = exports.outName = exports.getSitesKey = exports.getErrorFileName = exports.getErrorKeyPrefix = exports.chunkKeyForIndex = exports.chunkKey = exports.lambdaTimingsKey = exports.lambdaLogsPrefix = exports.lambdaTimingsPrefixForChunk = exports.lambdaTimingsPrefix = exports.lambdaChunkInitializedKey = exports.lambdaChunkInitializedPrefix = exports.initalizedMetadataKey = exports.renderMetadataKey = exports.encodingProgressKey = exports.rendersPrefix = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.REMOTION_BUCKET_PREFIX = exports.ENCODING_PROGRESS_STEP_SIZE = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_FUNCTIONS_PER_RENDER = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.COMMAND_NOT_FOUND = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MINIMUM_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
4
+ exports.LAMBDA_BURST_LIMIT_QUOTA = void 0;
4
5
  exports.MIN_MEMORY = 512;
5
6
  exports.MAX_MEMORY = 10240;
6
7
  exports.DEFAULT_MEMORY_SIZE = 2048;
@@ -77,10 +78,18 @@ const postRenderDataKey = (renderId) => {
77
78
  return `${(0, exports.rendersPrefix)(renderId)}/post-render-metadata.json`;
78
79
  };
79
80
  exports.postRenderDataKey = postRenderDataKey;
81
+ const defaultPropsKey = (hash) => {
82
+ return `default-props/${hash}.json`;
83
+ };
84
+ exports.defaultPropsKey = defaultPropsKey;
80
85
  const inputPropsKey = (hash) => {
81
86
  return `input-props/${hash}.json`;
82
87
  };
83
88
  exports.inputPropsKey = inputPropsKey;
89
+ const resolvedPropsKey = (hash) => {
90
+ return `resolved-props/${hash}.json`;
91
+ };
92
+ exports.resolvedPropsKey = resolvedPropsKey;
84
93
  exports.RENDERER_PATH_TOKEN = 'remotion-bucket';
85
94
  exports.CONCAT_FOLDER_TOKEN = 'remotion-concat';
86
95
  exports.REMOTION_CONCATED_TOKEN = 'remotion-concated-token';
@@ -0,0 +1,20 @@
1
+ import type { AwsRegion } from '../client';
2
+ import type { SerializedInputProps } from './constants';
3
+ type PropsType = 'input-props' | 'resolved-props' | 'default-props';
4
+ export declare const serializeOrThrow: (inputProps: Record<string, unknown>, propsType: PropsType) => string;
5
+ export declare const getNeedsToUpload: (type: 'still' | 'video-or-audio', stringifiedInputProps: string) => boolean;
6
+ export declare const serializeInputProps: ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }: {
7
+ stringifiedInputProps: string;
8
+ region: AwsRegion;
9
+ userSpecifiedBucketName: string | null;
10
+ propsType: PropsType;
11
+ needsToUpload: boolean;
12
+ }) => Promise<SerializedInputProps>;
13
+ export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, propsType, }: {
14
+ serialized: SerializedInputProps;
15
+ region: AwsRegion;
16
+ bucketName: string;
17
+ expectedBucketOwner: string;
18
+ propsType: PropsType;
19
+ }) => Promise<Record<string, unknown>>;
20
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeInputProps = exports.serializeInputProps = exports.getNeedsToUpload = exports.serializeOrThrow = void 0;
4
+ const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
5
+ const io_1 = require("../functions/helpers/io");
6
+ const constants_1 = require("./constants");
7
+ const random_hash_1 = require("./random-hash");
8
+ const stream_to_string_1 = require("./stream-to-string");
9
+ const serializeOrThrow = (inputProps, propsType) => {
10
+ try {
11
+ const payload = JSON.stringify(inputProps);
12
+ return payload;
13
+ }
14
+ catch (err) {
15
+ throw new Error(`Error serializing ${propsType}. Check it has no circular references or reduce the size if the object is big.`);
16
+ }
17
+ };
18
+ exports.serializeOrThrow = serializeOrThrow;
19
+ const getNeedsToUpload = (type, stringifiedInputProps) => {
20
+ const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
21
+ if (stringifiedInputProps.length > MAX_INLINE_PAYLOAD_SIZE) {
22
+ console.warn(`Warning: The props are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(stringifiedInputProps.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size, which may lead to slowdown.`);
23
+ return true;
24
+ }
25
+ return false;
26
+ };
27
+ exports.getNeedsToUpload = getNeedsToUpload;
28
+ const serializeInputProps = async ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }) => {
29
+ const hash = (0, random_hash_1.randomHash)();
30
+ if (needsToUpload) {
31
+ const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
32
+ region,
33
+ })).bucketName;
34
+ await (0, io_1.lambdaWriteFile)({
35
+ body: stringifiedInputProps,
36
+ bucketName,
37
+ region,
38
+ customCredentials: null,
39
+ downloadBehavior: null,
40
+ expectedBucketOwner: null,
41
+ key: makeKey(propsType, hash),
42
+ privacy: 'public',
43
+ });
44
+ return {
45
+ type: 'bucket-url',
46
+ hash,
47
+ };
48
+ }
49
+ return {
50
+ type: 'payload',
51
+ payload: stringifiedInputProps,
52
+ };
53
+ };
54
+ exports.serializeInputProps = serializeInputProps;
55
+ const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, propsType, }) => {
56
+ if (serialized.type === 'payload') {
57
+ return JSON.parse(serialized.payload);
58
+ }
59
+ try {
60
+ const response = await (0, io_1.lambdaReadFile)({
61
+ bucketName,
62
+ expectedBucketOwner,
63
+ key: makeKey(propsType, serialized.hash),
64
+ region,
65
+ });
66
+ const body = await (0, stream_to_string_1.streamToString)(response);
67
+ const payload = JSON.parse(body);
68
+ return payload;
69
+ }
70
+ catch (err) {
71
+ throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
72
+ }
73
+ };
74
+ exports.deserializeInputProps = deserializeInputProps;
75
+ const makeKey = (type, hash) => {
76
+ if (type === 'input-props') {
77
+ return (0, constants_1.inputPropsKey)(hash);
78
+ }
79
+ if (type === 'default-props') {
80
+ return (0, constants_1.defaultPropsKey)(hash);
81
+ }
82
+ return (0, constants_1.resolvedPropsKey)(hash);
83
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.1.0-alpha2",
3
+ "version": "4.1.0-alpha5",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -25,10 +25,10 @@
25
25
  "@aws-sdk/s3-request-presigner": "3.338.0",
26
26
  "aws-policies": "^1.0.1",
27
27
  "mime-types": "2.1.34",
28
- "@remotion/bundler": "4.1.0-alpha2",
29
- "@remotion/renderer": "4.1.0-alpha2",
30
- "remotion": "4.1.0-alpha2",
31
- "@remotion/cli": "4.1.0-alpha2"
28
+ "@remotion/bundler": "4.1.0-alpha5",
29
+ "@remotion/renderer": "4.1.0-alpha5",
30
+ "@remotion/cli": "4.1.0-alpha5",
31
+ "remotion": "4.1.0-alpha5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jonny/eslint-config": "3.0.266",
@@ -43,11 +43,11 @@
43
43
  "typescript": "4.9.5",
44
44
  "vitest": "0.31.1",
45
45
  "zip-lib": "^0.7.2",
46
- "@remotion/bundler": "4.1.0-alpha2",
47
- "@remotion/compositor-linux-arm64-gnu": "4.1.0-alpha2"
46
+ "@remotion/bundler": "4.1.0-alpha5",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.1.0-alpha5"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.1.0-alpha2"
50
+ "@remotion/bundler": "4.1.0-alpha5"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file
Binary file
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
4
- serialized: SerializedInputProps;
5
- region: AwsRegion;
6
- bucketName: string;
7
- expectedBucketOwner: string;
8
- }) => Promise<Record<string, unknown>>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeInputProps = void 0;
4
- const io_1 = require("../functions/helpers/io");
5
- const constants_1 = require("./constants");
6
- const stream_to_string_1 = require("./stream-to-string");
7
- const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
8
- if (serialized.type === 'payload') {
9
- return JSON.parse(serialized.payload);
10
- }
11
- try {
12
- const response = await (0, io_1.lambdaReadFile)({
13
- bucketName,
14
- expectedBucketOwner,
15
- key: (0, constants_1.inputPropsKey)(serialized.hash),
16
- region,
17
- });
18
- const body = await (0, stream_to_string_1.streamToString)(response);
19
- const payload = JSON.parse(body);
20
- return payload;
21
- }
22
- catch (err) {
23
- throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
24
- }
25
- };
26
- exports.deserializeInputProps = deserializeInputProps;
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const serializeInputProps: ({ inputProps, region, type, userSpecifiedBucketName, }: {
4
- inputProps: Record<string, unknown>;
5
- region: AwsRegion;
6
- type: 'still' | 'video-or-audio';
7
- userSpecifiedBucketName: string | null;
8
- }) => Promise<SerializedInputProps>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeInputProps = void 0;
4
- const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
5
- const io_1 = require("../functions/helpers/io");
6
- const constants_1 = require("./constants");
7
- const random_hash_1 = require("./random-hash");
8
- const serializeInputProps = async ({ inputProps = {}, region, type, userSpecifiedBucketName, }) => {
9
- try {
10
- const payload = JSON.stringify(inputProps);
11
- const hash = (0, random_hash_1.randomHash)();
12
- const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
13
- if (payload.length > MAX_INLINE_PAYLOAD_SIZE) {
14
- console.warn(`Warning: inputProps are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(payload.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size.`);
15
- const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
16
- region,
17
- })).bucketName;
18
- await (0, io_1.lambdaWriteFile)({
19
- body: payload,
20
- bucketName,
21
- region,
22
- customCredentials: null,
23
- downloadBehavior: null,
24
- expectedBucketOwner: null,
25
- key: (0, constants_1.inputPropsKey)(hash),
26
- privacy: 'public',
27
- });
28
- return {
29
- type: 'bucket-url',
30
- hash,
31
- };
32
- }
33
- return {
34
- type: 'payload',
35
- payload,
36
- };
37
- }
38
- catch (err) {
39
- throw new Error('Error serializing inputProps. Check it has no circular references or reduce the size if the object is big.');
40
- }
41
- };
42
- exports.serializeInputProps = serializeInputProps;