@remotion/lambda 4.0.2 → 4.0.3

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.
@@ -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_props_1 = require("../shared/serialize-props");
7
+ const compress_props_1 = require("../shared/compress-props");
8
8
  /**
9
9
  * @description Returns the compositions from a serveUrl
10
10
  * @see [Documentation](https://remotion.dev/docs/lambda/getcompositionsonlambda)
@@ -20,13 +20,13 @@ const serialize_props_1 = require("../shared/serialize-props");
20
20
  */
21
21
  const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, }) => {
22
22
  var _a;
23
- const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps, 'input-props');
24
- const serializedInputProps = await (0, serialize_props_1.serializeInputProps)({
23
+ const stringifiedInputProps = (0, compress_props_1.serializeOrThrow)(inputProps, 'input-props');
24
+ const serializedInputProps = await (0, compress_props_1.compressInputProps)({
25
25
  stringifiedInputProps,
26
26
  region,
27
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
28
  propsType: 'input-props',
29
- needsToUpload: (0, serialize_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
29
+ needsToUpload: (0, compress_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
30
30
  });
31
31
  try {
32
32
  const res = await (0, call_lambda_1.callLambda)({
@@ -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_props_1 = require("../shared/serialize-props");
6
+ const compress_props_1 = require("../shared/compress-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,11 +19,11 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
19
19
  durationInFrames: 1,
20
20
  });
21
21
  (0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
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)({
22
+ const stringifiedInputProps = (0, compress_props_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
23
+ const serialized = await (0, compress_props_1.compressInputProps)({
24
24
  stringifiedInputProps,
25
25
  region,
26
- needsToUpload: (0, serialize_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
26
+ needsToUpload: (0, compress_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
27
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
28
  propsType: 'input-props',
29
29
  });
@@ -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_props_1 = require("../shared/serialize-props");
8
+ const compress_props_1 = require("../shared/compress-props");
9
9
  /**
10
10
  * @description Renders a still frame on Lambda
11
11
  * @link https://remotion.dev/docs/lambda/renderstillonlambda
@@ -27,11 +27,11 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
27
27
  if (quality) {
28
28
  throw new Error('The `quality` option is deprecated. Use `jpegQuality` instead.');
29
29
  }
30
- const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps, 'input-props');
31
- const serializedInputProps = await (0, serialize_props_1.serializeInputProps)({
30
+ const stringifiedInputProps = (0, compress_props_1.serializeOrThrow)(inputProps, 'input-props');
31
+ const serializedInputProps = await (0, compress_props_1.compressInputProps)({
32
32
  stringifiedInputProps,
33
33
  region,
34
- needsToUpload: (0, serialize_props_1.getNeedsToUpload)('still', stringifiedInputProps),
34
+ needsToUpload: (0, compress_props_1.getNeedsToUpload)('still', stringifiedInputProps),
35
35
  userSpecifiedBucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
36
36
  propsType: 'input-props',
37
37
  });
@@ -19,6 +19,7 @@ const find_function_name_1 = require("../../helpers/find-function-name");
19
19
  const quit_1 = require("../../helpers/quit");
20
20
  const log_1 = require("../../log");
21
21
  const progress_1 = require("./progress");
22
+ const remotion_1 = require("remotion");
22
23
  exports.RENDER_COMMAND = 'render';
23
24
  const renderCommand = async (args, remotionRoot) => {
24
25
  var _a, _b, _c, _d, _e, _f, _g;
@@ -56,7 +57,11 @@ const renderCommand = async (args, remotionRoot) => {
56
57
  envVariables,
57
58
  height,
58
59
  indent: false,
59
- inputProps,
60
+ serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
61
+ indent: undefined,
62
+ staticBase: null,
63
+ data: inputProps,
64
+ }).serializedString,
60
65
  port,
61
66
  puppeteerInstance: undefined,
62
67
  serveUrlOrWebpackUrl: serveUrl,
@@ -15,6 +15,7 @@ const get_aws_region_1 = require("../get-aws-region");
15
15
  const find_function_name_1 = require("../helpers/find-function-name");
16
16
  const quit_1 = require("../helpers/quit");
17
17
  const log_1 = require("../log");
18
+ const remotion_1 = require("remotion");
18
19
  exports.STILL_COMMAND = 'still';
19
20
  const stillCommand = async (args, remotionRoot) => {
20
21
  var _a, _b, _c, _d, _e, _f;
@@ -53,7 +54,11 @@ const stillCommand = async (args, remotionRoot) => {
53
54
  browserExecutable,
54
55
  chromiumOptions,
55
56
  envVariables,
56
- inputProps,
57
+ serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
58
+ indent: undefined,
59
+ staticBase: null,
60
+ data: inputProps,
61
+ }).serializedString,
57
62
  port,
58
63
  puppeteerInstance: undefined,
59
64
  timeoutInMilliseconds: puppeteerTimeout,
package/dist/cli/log.d.ts CHANGED
@@ -2,19 +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: "verbose" | "info" | "warn" | "error";
6
6
  } & {
7
7
  tag?: string | undefined;
8
8
  }, message?: any, ...optionalParams: any[]) => void;
9
9
  info: (message?: any, ...optionalParams: any[]) => void;
10
10
  infoAdvanced: (options: {
11
11
  indent: boolean;
12
- logLevel: "error" | "verbose" | "info" | "warn";
12
+ logLevel: "verbose" | "info" | "warn" | "error";
13
13
  }, message?: any, ...optionalParams: any[]) => void;
14
14
  warn: (message?: any, ...optionalParams: any[]) => void;
15
15
  warnAdvanced: (options: {
16
16
  indent: boolean;
17
- logLevel: "error" | "verbose" | "info" | "warn";
17
+ logLevel: "verbose" | "info" | "warn" | "error";
18
18
  }, message?: any, ...optionalParams: any[]) => void;
19
19
  error: (message?: any, ...optionalParams: any[]) => void;
20
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
  };
@@ -8,7 +8,7 @@ const defaults_1 = require("../defaults");
8
8
  const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
9
9
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
10
10
  const get_current_region_1 = require("./helpers/get-current-region");
11
- const serialize_props_1 = require("../shared/serialize-props");
11
+ const compress_props_1 = require("../shared/compress-props");
12
12
  const compositionsHandler = async (lambdaParams, options) => {
13
13
  var _a, _b, _c;
14
14
  if (lambdaParams.type !== defaults_1.LambdaRoutines.compositions) {
@@ -27,7 +27,7 @@ const compositionsHandler = async (lambdaParams, options) => {
27
27
  }).then((b) => b.bucketName),
28
28
  (0, get_browser_instance_1.getBrowserInstance)(lambdaParams.logLevel, false, (_b = lambdaParams.chromiumOptions) !== null && _b !== void 0 ? _b : {}),
29
29
  ]);
30
- const inputProps = await (0, serialize_props_1.deserializeInputProps)({
30
+ const serializedInputPropsWithCustomSchema = await (0, compress_props_1.decompressInputProps)({
31
31
  bucketName,
32
32
  expectedBucketOwner: options.expectedBucketOwner,
33
33
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
@@ -42,7 +42,7 @@ const compositionsHandler = async (lambdaParams, options) => {
42
42
  const compositions = await renderer_1.RenderInternals.internalGetCompositions({
43
43
  serveUrlOrWebpackUrl: realServeUrl,
44
44
  puppeteerInstance: browserInstance,
45
- inputProps,
45
+ serializedInputPropsWithCustomSchema,
46
46
  envVariables: (_c = lambdaParams.envVariables) !== null && _c !== void 0 ? _c : {},
47
47
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
48
48
  chromiumOptions: lambdaParams.chromiumOptions,
@@ -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";
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProgress = void 0;
4
4
  const renderer_1 = require("@remotion/renderer");
5
5
  const remotion_1 = require("remotion");
6
- const chunk_progress_1 = require("../../shared/chunk-progress");
7
6
  const constants_1 = require("../../shared/constants");
8
7
  const calculate_chunk_times_1 = require("./calculate-chunk-times");
9
8
  const calculate_price_from_bucket_1 = require("./calculate-price-from-bucket");
@@ -140,11 +139,6 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
140
139
  renderId,
141
140
  })
142
141
  : 0;
143
- console.log('etags', contents
144
- .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
145
- .map((c) => {
146
- return (0, chunk_progress_1.getProgressOfChunk)(c.ETag);
147
- }));
148
142
  const allChunks = chunks.length === ((_f = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _f !== void 0 ? _f : Infinity);
149
143
  const renderSize = contents
150
144
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
@@ -5,7 +5,7 @@ type ValidateCompositionOptions = {
5
5
  serveUrl: string;
6
6
  composition: string;
7
7
  browserInstance: Await<ReturnType<typeof openBrowser>>;
8
- inputProps: Record<string, unknown>;
8
+ serializedInputPropsWithCustomSchema: string;
9
9
  envVariables: Record<string, string>;
10
10
  timeoutInMilliseconds: number;
11
11
  chromiumOptions: ChromiumOptions;
@@ -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<VideoConfig>;
18
+ export declare const validateComposition: ({ serveUrl, composition, browserInstance, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<VideoConfig>;
19
19
  export {};
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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
- const validateComposition = async ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
6
+ const validateComposition = async ({ serveUrl, composition, browserInstance, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
7
7
  const { metadata: comp } = await renderer_1.RenderInternals.internalSelectComposition({
8
8
  id: composition,
9
9
  puppeteerInstance: browserInstance,
10
- inputProps,
10
+ serializedInputPropsWithCustomSchema,
11
11
  envVariables,
12
12
  timeoutInMilliseconds,
13
13
  chromiumOptions,
@@ -23,8 +23,6 @@ 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,
28
26
  };
29
27
  };
30
28
  exports.validateComposition = validateComposition;
@@ -56,7 +56,7 @@ const timer_1 = require("./helpers/timer");
56
56
  const validate_composition_1 = require("./helpers/validate-composition");
57
57
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
58
58
  const write_post_render_data_1 = require("./helpers/write-post-render-data");
59
- const serialize_props_1 = require("../shared/serialize-props");
59
+ const compress_props_1 = require("../shared/compress-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({
@@ -136,20 +136,20 @@ const innerLaunchHandler = async (params, options) => {
136
136
  }
137
137
  }, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
138
138
  const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, params.chromiumOptions);
139
- const inputPropsPromise = (0, serialize_props_1.deserializeInputProps)({
139
+ const inputPropsPromise = (0, compress_props_1.decompressInputProps)({
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
144
  propsType: 'input-props',
145
145
  });
146
- const inputProps = await inputPropsPromise;
147
- renderer_1.RenderInternals.Log.info('Validating composition, input props:', inputProps);
146
+ const serializedInputPropsWithCustomSchema = await inputPropsPromise;
147
+ renderer_1.RenderInternals.Log.info('Validating composition, input props:', serializedInputPropsWithCustomSchema);
148
148
  const comp = await (0, validate_composition_1.validateComposition)({
149
149
  serveUrl: params.serveUrl,
150
150
  composition: params.composition,
151
151
  browserInstance,
152
- inputProps,
152
+ serializedInputPropsWithCustomSchema,
153
153
  envVariables: (_b = params.envVariables) !== null && _b !== void 0 ? _b : {},
154
154
  timeoutInMilliseconds: params.timeoutInMilliseconds,
155
155
  chromiumOptions: params.chromiumOptions,
@@ -191,25 +191,15 @@ const innerLaunchHandler = async (params, options) => {
191
191
  });
192
192
  const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
193
193
  const reqSend = (0, timer_1.timer)('sending off requests');
194
- const serializedResolved = (0, serialize_props_1.serializeOrThrow)(comp.props, 'resolved-props');
195
- const serializedDefault = (0, serialize_props_1.serializeOrThrow)(comp.defaultProps, 'default-props');
196
- const needsToUpload = (0, serialize_props_1.getNeedsToUpload)('video-or-audio', serializedResolved + serializedDefault);
197
- const [serializedResolvedProps, serializedDefaultProps] = await Promise.all([
198
- (0, serialize_props_1.serializeInputProps)({
199
- propsType: 'resolved-props',
200
- region: (0, get_current_region_1.getCurrentRegionInFunction)(),
201
- stringifiedInputProps: serializedResolved,
202
- userSpecifiedBucketName: params.bucketName,
203
- needsToUpload,
204
- }),
205
- (0, serialize_props_1.serializeInputProps)({
206
- propsType: 'default-props',
207
- region: (0, get_current_region_1.getCurrentRegionInFunction)(),
208
- stringifiedInputProps: serializedDefault,
209
- userSpecifiedBucketName: params.bucketName,
210
- needsToUpload,
211
- }),
212
- ]);
194
+ const serializedResolved = (0, compress_props_1.serializeOrThrow)(comp.props, 'resolved-props');
195
+ const needsToUpload = (0, compress_props_1.getNeedsToUpload)('video-or-audio', serializedResolved + params.inputProps);
196
+ const serializedResolvedProps = await (0, compress_props_1.compressInputProps)({
197
+ propsType: 'resolved-props',
198
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
199
+ stringifiedInputProps: serializedResolved,
200
+ userSpecifiedBucketName: params.bucketName,
201
+ needsToUpload,
202
+ });
213
203
  const lambdaPayloads = chunks.map((chunkPayload) => {
214
204
  var _a;
215
205
  const payload = {
@@ -248,7 +238,6 @@ const innerLaunchHandler = async (params, options) => {
248
238
  version: version_1.VERSION,
249
239
  },
250
240
  resolvedProps: serializedResolvedProps,
251
- defaultProps: serializedDefaultProps,
252
241
  };
253
242
  return payload;
254
243
  });
@@ -17,7 +17,7 @@ const get_chromium_executable_path_1 = require("./helpers/get-chromium-executabl
17
17
  const get_current_region_1 = require("./helpers/get-current-region");
18
18
  const io_1 = require("./helpers/io");
19
19
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
20
- const serialize_props_1 = require("../shared/serialize-props");
20
+ const compress_props_1 = require("../shared/compress-props");
21
21
  const renderHandler = async (params, options, logs) => {
22
22
  var _a;
23
23
  if (params.type !== constants_1.LambdaRoutines.renderer) {
@@ -26,27 +26,20 @@ 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, serialize_props_1.deserializeInputProps)({
29
+ const inputPropsPromise = (0, compress_props_1.decompressInputProps)({
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
34
  propsType: 'input-props',
35
35
  });
36
- const resolvedPropsPromise = (0, serialize_props_1.deserializeInputProps)({
36
+ const resolvedPropsPromise = (0, compress_props_1.decompressInputProps)({
37
37
  bucketName: params.bucketName,
38
38
  expectedBucketOwner: options.expectedBucketOwner,
39
39
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
40
40
  serialized: params.resolvedProps,
41
41
  propsType: 'resolved-props',
42
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
43
  const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, (_a = params.chromiumOptions) !== null && _a !== void 0 ? _a : {});
51
44
  const outputPath = renderer_1.RenderInternals.tmpDir('remotion-render-');
52
45
  if (typeof params.chunk !== 'number') {
@@ -71,9 +64,8 @@ const renderHandler = async (params, options, logs) => {
71
64
  preferLossless: true,
72
65
  }))}`);
73
66
  const downloads = {};
74
- const inputProps = await inputPropsPromise;
75
67
  const resolvedProps = await resolvedPropsPromise;
76
- const defaultProps = await defaultPropsPromise;
68
+ const serializedInputPropsWithCustomSchema = await inputPropsPromise;
77
69
  await new Promise((resolve, reject) => {
78
70
  var _a, _b, _c, _d;
79
71
  renderer_1.RenderInternals.internalRenderMedia({
@@ -83,11 +75,9 @@ const renderHandler = async (params, options, logs) => {
83
75
  fps: params.fps,
84
76
  height: params.height,
85
77
  width: params.width,
86
- props: resolvedProps,
87
- defaultProps,
88
78
  },
89
79
  imageFormat: params.imageFormat,
90
- inputProps,
80
+ serializedInputPropsWithCustomSchema,
91
81
  frameRange: params.frameRange,
92
82
  onProgress: ({ renderedFrames, encodedFrames, stitchStage }) => {
93
83
  if (renderedFrames % 5 === 0 &&
@@ -176,6 +166,7 @@ const renderHandler = async (params, options, logs) => {
176
166
  indent: false,
177
167
  onCtrlCExit: () => undefined,
178
168
  server: undefined,
169
+ serializedResolvedPropsWithCustomSchema: resolvedProps,
179
170
  })
180
171
  .then(({ slowestFrames }) => {
181
172
  console.log(`Slowest frames:`);
@@ -29,7 +29,8 @@ const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-me
29
29
  const io_1 = require("./helpers/io");
30
30
  const validate_composition_1 = require("./helpers/validate-composition");
31
31
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
32
- const serialize_props_1 = require("../shared/serialize-props");
32
+ const compress_props_1 = require("../shared/compress-props");
33
+ const remotion_1 = require("remotion");
33
34
  const innerStillHandler = async (lambdaParams, renderId, options) => {
34
35
  var _a, _b, _c, _d, _e, _f;
35
36
  if (lambdaParams.type !== constants_1.LambdaRoutines.still) {
@@ -54,7 +55,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
54
55
  const outputDir = renderer_1.RenderInternals.tmpDir('remotion-render-');
55
56
  const outputPath = node_path_1.default.join(outputDir, 'output');
56
57
  const region = (0, get_current_region_1.getCurrentRegionInFunction)();
57
- const inputProps = await (0, serialize_props_1.deserializeInputProps)({
58
+ const serializedInputPropsWithCustomSchema = await (0, compress_props_1.decompressInputProps)({
58
59
  bucketName,
59
60
  expectedBucketOwner: options.expectedBucketOwner,
60
61
  region,
@@ -78,7 +79,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
78
79
  serveUrl,
79
80
  browserInstance,
80
81
  composition: lambdaParams.composition,
81
- inputProps,
82
+ serializedInputPropsWithCustomSchema,
82
83
  envVariables: (_c = lambdaParams.envVariables) !== null && _c !== void 0 ? _c : {},
83
84
  chromiumOptions: lambdaParams.chromiumOptions,
84
85
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
@@ -131,7 +132,11 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
131
132
  durationInFrames: composition.durationInFrames,
132
133
  }),
133
134
  imageFormat: lambdaParams.imageFormat,
134
- inputProps,
135
+ serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
136
+ data: lambdaParams.inputProps,
137
+ indent: undefined,
138
+ staticBase: null,
139
+ }).serializedString,
135
140
  overwrite: false,
136
141
  puppeteerInstance: browserInstance,
137
142
  jpegQuality: (_f = lambdaParams.jpegQuality) !== null && _f !== void 0 ? _f : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
@@ -146,6 +151,11 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
146
151
  port: null,
147
152
  server,
148
153
  logLevel: lambdaParams.logLevel,
154
+ serializedResolvedPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
155
+ indent: undefined,
156
+ staticBase: null,
157
+ data: composition.props,
158
+ }).serializedString,
149
159
  });
150
160
  const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, (0, expected_out_name_1.getCredentialsFromOutName)(lambdaParams.outName));
151
161
  const { size } = await node_fs_1.default.promises.stat(outputPath);
@@ -0,0 +1,20 @@
1
+ import type { AwsRegion } from '../client';
2
+ import type { SerializedInputProps } from './constants';
3
+ type PropsType = 'input-props' | 'resolved-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 compressInputProps: ({ 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 decompressInputProps: ({ serialized, region, bucketName, expectedBucketOwner, propsType, }: {
14
+ serialized: SerializedInputProps;
15
+ region: AwsRegion;
16
+ bucketName: string;
17
+ expectedBucketOwner: string;
18
+ propsType: PropsType;
19
+ }) => Promise<string>;
20
+ export {};
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decompressInputProps = exports.compressInputProps = 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 serialize_props_1 = require("./serialize-props");
10
+ const serializeOrThrow = (inputProps, propsType) => {
11
+ try {
12
+ const payload = (0, serialize_props_1.serializeJSONWithDate)({
13
+ indent: undefined,
14
+ staticBase: null,
15
+ data: inputProps,
16
+ });
17
+ return payload.serializedString;
18
+ }
19
+ catch (err) {
20
+ throw new Error(`Error serializing ${propsType}. Check it has no circular references or reduce the size if the object is big.`);
21
+ }
22
+ };
23
+ exports.serializeOrThrow = serializeOrThrow;
24
+ const getNeedsToUpload = (type, stringifiedInputProps) => {
25
+ const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
26
+ if (stringifiedInputProps.length > MAX_INLINE_PAYLOAD_SIZE) {
27
+ 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.`);
28
+ return true;
29
+ }
30
+ return false;
31
+ };
32
+ exports.getNeedsToUpload = getNeedsToUpload;
33
+ const compressInputProps = async ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }) => {
34
+ const hash = (0, random_hash_1.randomHash)();
35
+ if (needsToUpload) {
36
+ const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
37
+ region,
38
+ })).bucketName;
39
+ await (0, io_1.lambdaWriteFile)({
40
+ body: stringifiedInputProps,
41
+ bucketName,
42
+ region,
43
+ customCredentials: null,
44
+ downloadBehavior: null,
45
+ expectedBucketOwner: null,
46
+ key: makeKey(propsType, hash),
47
+ privacy: 'public',
48
+ });
49
+ return {
50
+ type: 'bucket-url',
51
+ hash,
52
+ };
53
+ }
54
+ return {
55
+ type: 'payload',
56
+ payload: stringifiedInputProps,
57
+ };
58
+ };
59
+ exports.compressInputProps = compressInputProps;
60
+ const decompressInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, propsType, }) => {
61
+ if (serialized.type === 'payload') {
62
+ return serialized.payload;
63
+ }
64
+ try {
65
+ const response = await (0, io_1.lambdaReadFile)({
66
+ bucketName,
67
+ expectedBucketOwner,
68
+ key: makeKey(propsType, serialized.hash),
69
+ region,
70
+ });
71
+ const body = await (0, stream_to_string_1.streamToString)(response);
72
+ const payload = body;
73
+ return payload;
74
+ }
75
+ catch (err) {
76
+ throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
77
+ }
78
+ };
79
+ exports.decompressInputProps = decompressInputProps;
80
+ const makeKey = (type, hash) => {
81
+ if (type === 'input-props') {
82
+ return (0, constants_1.inputPropsKey)(hash);
83
+ }
84
+ return (0, constants_1.resolvedPropsKey)(hash);
85
+ };
@@ -221,7 +221,6 @@ export type LambdaPayloads = {
221
221
  timeoutInMilliseconds: number;
222
222
  chromiumOptions: ChromiumOptions;
223
223
  resolvedProps: SerializedInputProps;
224
- defaultProps: SerializedInputProps;
225
224
  scale: number;
226
225
  everyNthFrame: number;
227
226
  muted: boolean;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import https from 'https';
4
2
  import http from 'node:http';
5
3
  import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
@@ -1,20 +1,14 @@
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>>;
1
+ type SerializedJSONWithCustomFields = {
2
+ serializedString: string;
3
+ customDateUsed: boolean;
4
+ customFileUsed: boolean;
5
+ mapUsed: boolean;
6
+ setUsed: boolean;
7
+ };
8
+ export declare const FILE_TOKEN = "remotion-file:";
9
+ export declare const serializeJSONWithDate: ({ data, indent, staticBase, }: {
10
+ data: Record<string, unknown>;
11
+ indent: number | undefined;
12
+ staticBase: string | null;
13
+ }) => SerializedJSONWithCustomFields;
20
14
  export {};
@@ -1,83 +1,36 @@
1
1
  "use strict";
2
+ // Must keep this file in sync with the one in packages/core/src/input-props-serialization.ts!
2
3
  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);
4
+ exports.serializeJSONWithDate = exports.FILE_TOKEN = void 0;
5
+ const DATE_TOKEN = 'remotion-date:';
6
+ exports.FILE_TOKEN = 'remotion-file:';
7
+ const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
8
+ let customDateUsed = false;
9
+ let customFileUsed = false;
10
+ let mapUsed = false;
11
+ let setUsed = false;
12
+ const serializedString = JSON.stringify(data, function (key, value) {
13
+ const item = this[key];
14
+ if (item instanceof Date) {
15
+ customDateUsed = true;
16
+ return `${DATE_TOKEN}${item.toISOString()}`;
17
+ }
18
+ if (item instanceof Map) {
19
+ mapUsed = true;
20
+ return value;
21
+ }
22
+ if (item instanceof Set) {
23
+ setUsed = true;
24
+ return value;
25
+ }
26
+ if (typeof item === 'string' &&
27
+ staticBase !== null &&
28
+ item.startsWith(staticBase)) {
29
+ customFileUsed = true;
30
+ return `${exports.FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
31
+ }
32
+ return value;
33
+ }, indent);
34
+ return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
83
35
  };
36
+ exports.serializeJSONWithDate = serializeJSONWithDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
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.0.2",
29
- "@remotion/cli": "4.0.2",
30
- "@remotion/renderer": "4.0.2",
31
- "remotion": "4.0.2"
28
+ "@remotion/bundler": "4.0.3",
29
+ "@remotion/renderer": "4.0.3",
30
+ "remotion": "4.0.3",
31
+ "@remotion/cli": "4.0.3"
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.0.2",
47
- "@remotion/compositor-linux-arm64-gnu": "4.0.2"
46
+ "@remotion/bundler": "4.0.3",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.3"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.0.2"
50
+ "@remotion/bundler": "4.0.3"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file