@remotion/lambda 4.0.14 → 4.0.16

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.
package/dist/cli/log.d.ts CHANGED
@@ -2,24 +2,24 @@ export declare const Log: {
2
2
  verbose: (message?: any, ...optionalParams: any[]) => void;
3
3
  verboseAdvanced: (options: {
4
4
  indent: boolean;
5
- logLevel: "verbose" | "info" | "warn" | "error";
5
+ logLevel: "info" | "error" | "verbose" | "warn";
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: "verbose" | "info" | "warn" | "error";
12
+ logLevel: "info" | "error" | "verbose" | "warn";
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: "verbose" | "info" | "warn" | "error";
17
+ logLevel: "info" | "error" | "verbose" | "warn";
18
18
  }, message?: any, ...optionalParams: any[]) => void;
19
19
  error: (message?: any, ...optionalParams: any[]) => void;
20
20
  errorAdvanced: (options: {
21
21
  indent: boolean;
22
- logLevel: "verbose" | "info" | "warn" | "error";
22
+ logLevel: "info" | "error" | "verbose" | "warn";
23
23
  } & {
24
24
  tag?: string | undefined;
25
25
  }, message?: any, ...optionalParams: any[]) => void;
@@ -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";
@@ -82,12 +82,16 @@ const lambdaWriteFile = async (params) => {
82
82
  if (remainingRetries === 0) {
83
83
  throw err;
84
84
  }
85
+ const backoff = 2 ** (2 - remainingRetries) * 2000;
86
+ await new Promise((resolve) => {
87
+ setTimeout(resolve, backoff);
88
+ });
85
89
  console.warn('Failed to write file to Lambda:');
86
90
  console.warn(err);
87
91
  console.warn(`Retrying (${remainingRetries} retries remaining)...`);
88
92
  return (0, exports.lambdaWriteFile)({
89
93
  ...params,
90
- retries: (remainingRetries !== null && remainingRetries !== void 0 ? remainingRetries : 0) - 1,
94
+ retries: remainingRetries - 1,
91
95
  });
92
96
  }
93
97
  };
@@ -0,0 +1,2 @@
1
+ import type { RenderMediaOnDownload } from '@remotion/renderer';
2
+ export declare const onDownloadsHelper: () => RenderMediaOnDownload;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onDownloadsHelper = void 0;
4
+ const onDownloadsHelper = () => {
5
+ const downloads = {};
6
+ return (src) => {
7
+ console.log('Downloading', src);
8
+ downloads[src] = 0;
9
+ return ({ percent, downloaded }) => {
10
+ if (percent === null) {
11
+ console.log(`Download progress (${src}): ${downloaded} bytes. Don't know final size of download, no Content-Length header.`);
12
+ return;
13
+ }
14
+ if (
15
+ // Only report every 10% change
16
+ downloads[src] > percent - 0.1 &&
17
+ percent !== 1) {
18
+ return;
19
+ }
20
+ downloads[src] = percent;
21
+ console.log(`Download progress (${src}): ${downloaded} bytes, ${(percent * 100).toFixed(1)}%`);
22
+ if (percent === 1) {
23
+ console.log(`Download complete: ${src}`);
24
+ }
25
+ };
26
+ };
27
+ };
28
+ exports.onDownloadsHelper = onDownloadsHelper;
@@ -4,16 +4,16 @@ declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
4
4
  type: z.ZodLiteral<"render-id-determined">;
5
5
  renderId: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- renderId: string;
8
7
  type: "render-id-determined";
9
- }, {
10
8
  renderId: string;
9
+ }, {
11
10
  type: "render-id-determined";
11
+ renderId: string;
12
12
  }>]>;
13
13
  export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
14
14
  export declare const isStreamingPayload: (str: string) => false | {
15
- renderId: string;
16
15
  type: "render-id-determined";
16
+ renderId: string;
17
17
  };
18
18
  export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
19
19
  export {};
@@ -44,8 +44,9 @@ const innerHandler = async (params, responseStream, context) => {
44
44
  params,
45
45
  renderId,
46
46
  });
47
- responseStream.write(JSON.stringify(response));
48
- responseStream.end();
47
+ responseStream.write(JSON.stringify(response), () => {
48
+ responseStream.end();
49
+ });
49
50
  return;
50
51
  }
51
52
  if (params.type === constants_1.LambdaRoutines.start) {
@@ -57,8 +58,9 @@ const innerHandler = async (params, responseStream, context) => {
57
58
  const response = await (0, start_1.startHandler)(params, {
58
59
  expectedBucketOwner: currentUserId,
59
60
  });
60
- responseStream.write(JSON.stringify(response));
61
- responseStream.end();
61
+ responseStream.write(JSON.stringify(response), () => {
62
+ responseStream.end();
63
+ });
62
64
  return;
63
65
  }
64
66
  if (params.type === constants_1.LambdaRoutines.launch) {
@@ -72,8 +74,9 @@ const innerHandler = async (params, responseStream, context) => {
72
74
  expectedBucketOwner: currentUserId,
73
75
  getRemainingTimeInMillis: context.getRemainingTimeInMillis,
74
76
  });
75
- responseStream.write(JSON.stringify(response));
76
- responseStream.end();
77
+ responseStream.write(JSON.stringify(response), () => {
78
+ responseStream.end();
79
+ });
77
80
  return;
78
81
  }
79
82
  if (params.type === constants_1.LambdaRoutines.status) {
@@ -85,8 +88,9 @@ const innerHandler = async (params, responseStream, context) => {
85
88
  expectedBucketOwner: currentUserId,
86
89
  timeoutInMilliseconds,
87
90
  });
88
- responseStream.write(JSON.stringify(response));
89
- responseStream.end();
91
+ responseStream.write(JSON.stringify(response), () => {
92
+ responseStream.end();
93
+ });
90
94
  return;
91
95
  }
92
96
  if (params.type === constants_1.LambdaRoutines.renderer) {
@@ -102,8 +106,9 @@ const innerHandler = async (params, responseStream, context) => {
102
106
  expectedBucketOwner: currentUserId,
103
107
  isWarm,
104
108
  });
105
- responseStream.write(JSON.stringify(response));
106
- responseStream.end();
109
+ responseStream.write(JSON.stringify(response), () => {
110
+ responseStream.end();
111
+ });
107
112
  return;
108
113
  }
109
114
  if (params.type === constants_1.LambdaRoutines.info) {
@@ -111,8 +116,9 @@ const innerHandler = async (params, responseStream, context) => {
111
116
  isWarm,
112
117
  });
113
118
  const response = await (0, info_1.infoHandler)(params);
114
- responseStream.write(JSON.stringify(response));
115
- responseStream.end();
119
+ responseStream.write(JSON.stringify(response), () => {
120
+ responseStream.end();
121
+ });
116
122
  return;
117
123
  }
118
124
  if (params.type === constants_1.LambdaRoutines.compositions) {
@@ -122,8 +128,9 @@ const innerHandler = async (params, responseStream, context) => {
122
128
  const response = await (0, compositions_1.compositionsHandler)(params, {
123
129
  expectedBucketOwner: currentUserId,
124
130
  });
125
- responseStream.write(JSON.stringify(response));
126
- responseStream.end();
131
+ responseStream.write(JSON.stringify(response), () => {
132
+ responseStream.end();
133
+ });
127
134
  return;
128
135
  }
129
136
  throw new Error(constants_1.COMMAND_NOT_FOUND);
@@ -16,6 +16,7 @@ const get_browser_instance_1 = require("./helpers/get-browser-instance");
16
16
  const get_chromium_executable_path_1 = require("./helpers/get-chromium-executable-path");
17
17
  const get_current_region_1 = require("./helpers/get-current-region");
18
18
  const io_1 = require("./helpers/io");
19
+ const on_downloads_logger_1 = require("./helpers/on-downloads-logger");
19
20
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
20
21
  const renderHandler = async (params, options, logs) => {
21
22
  var _a;
@@ -63,7 +64,6 @@ const renderHandler = async (params, options, logs) => {
63
64
  codec: params.codec,
64
65
  preferLossless: true,
65
66
  }))}`);
66
- const downloads = {};
67
67
  const resolvedProps = await resolvedPropsPromise;
68
68
  const serializedInputPropsWithCustomSchema = await inputPropsPromise;
69
69
  await new Promise((resolve, reject) => {
@@ -127,27 +127,7 @@ const renderHandler = async (params, options, logs) => {
127
127
  crf: (_c = params.crf) !== null && _c !== void 0 ? _c : null,
128
128
  pixelFormat: (_d = params.pixelFormat) !== null && _d !== void 0 ? _d : renderer_1.RenderInternals.DEFAULT_PIXEL_FORMAT,
129
129
  proResProfile: params.proResProfile,
130
- onDownload: (src) => {
131
- console.log('Downloading', src);
132
- downloads[src] = 0;
133
- return ({ percent, downloaded }) => {
134
- if (percent === null) {
135
- console.log(`Download progress (${src}): ${downloaded} bytes. Don't know final size of download, no Content-Length header.`);
136
- return;
137
- }
138
- if (
139
- // Only report every 10% change
140
- downloads[src] > percent - 0.1 &&
141
- percent !== 1) {
142
- return;
143
- }
144
- downloads[src] = percent;
145
- console.log(`Download progress (${src}): ${downloaded} bytes, ${(percent * 100).toFixed(1)}%`);
146
- if (percent === 1) {
147
- console.log(`Download complete: ${src}`);
148
- }
149
- };
150
- },
130
+ onDownload: (0, on_downloads_logger_1.onDownloadsHelper)(),
151
131
  overwrite: false,
152
132
  chromiumOptions: params.chromiumOptions,
153
133
  scale: params.scale,
@@ -27,6 +27,7 @@ const get_chromium_executable_path_1 = require("./helpers/get-chromium-executabl
27
27
  const get_current_region_1 = require("./helpers/get-current-region");
28
28
  const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-metadata");
29
29
  const io_1 = require("./helpers/io");
30
+ const on_downloads_logger_1 = require("./helpers/on-downloads-logger");
30
31
  const validate_composition_1 = require("./helpers/validate-composition");
31
32
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
32
33
  const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, renderId, }) => {
@@ -141,7 +142,7 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
141
142
  cancelSignal: null,
142
143
  indent: false,
143
144
  onBrowserLog: null,
144
- onDownload: null,
145
+ onDownload: (0, on_downloads_logger_1.onDownloadsHelper)(),
145
146
  port: null,
146
147
  server,
147
148
  logLevel: lambdaParams.logLevel,
@@ -10,7 +10,7 @@ const callLambda = async ({ functionName, type, payload, region, receivedStreami
10
10
  Payload: JSON.stringify({ type, ...payload }),
11
11
  }));
12
12
  const events = res.EventStream;
13
- let responsePayload = new Uint8Array();
13
+ let responsePayload = '';
14
14
  for await (const event of events) {
15
15
  // There are two types of events you can get on a stream.
16
16
  // `PayloadChunk`: These contain the actual raw bytes of the chunk
@@ -23,7 +23,7 @@ const callLambda = async ({ functionName, type, payload, region, receivedStreami
23
23
  receivedStreamingPayload(streamPayload);
24
24
  continue;
25
25
  }
26
- responsePayload = Buffer.concat([responsePayload, Buffer.from(decoded)]);
26
+ responsePayload += decoded;
27
27
  }
28
28
  if (event.InvokeComplete) {
29
29
  if (event.InvokeComplete.ErrorCode) {
@@ -35,8 +35,7 @@ const callLambda = async ({ functionName, type, payload, region, receivedStreami
35
35
  }
36
36
  }
37
37
  }
38
- const string = Buffer.from(responsePayload).toString();
39
- const json = parseJson(string);
38
+ const json = parseJson(responsePayload.trim());
40
39
  return json;
41
40
  };
42
41
  exports.callLambda = callLambda;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.14",
3
+ "version": "4.0.16",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -13,23 +13,23 @@
13
13
  "url": "https://github.com/JonnyBurger/remotion"
14
14
  },
15
15
  "dependencies": {
16
- "@aws-sdk/abort-controller": "3.370.0",
17
- "@aws-sdk/client-cloudwatch-logs": "3.370.0",
18
- "@aws-sdk/client-iam": "3.370.0",
19
- "@aws-sdk/client-lambda": "3.370.0",
20
- "@aws-sdk/client-s3": "3.370.0",
21
- "@aws-sdk/client-service-quotas": "3.370.0",
22
- "@aws-sdk/client-sts": "3.370.0",
23
- "@aws-sdk/credential-providers": "3.370.0",
24
- "@aws-sdk/lib-storage": "3.370.0",
25
- "@aws-sdk/s3-request-presigner": "3.370.0",
16
+ "@aws-sdk/abort-controller": "3.374.0",
17
+ "@aws-sdk/client-cloudwatch-logs": "3.382.0",
18
+ "@aws-sdk/client-iam": "3.382.0",
19
+ "@aws-sdk/client-lambda": "3.382.0",
20
+ "@aws-sdk/client-s3": "3.382.0",
21
+ "@aws-sdk/client-service-quotas": "3.382.0",
22
+ "@aws-sdk/client-sts": "3.382.0",
23
+ "@aws-sdk/credential-providers": "3.382.0",
24
+ "@aws-sdk/lib-storage": "3.382.0",
25
+ "@aws-sdk/s3-request-presigner": "3.382.0",
26
26
  "aws-policies": "^1.0.1",
27
27
  "mime-types": "2.1.34",
28
28
  "zod": "3.21.4",
29
- "remotion": "4.0.14",
30
- "@remotion/cli": "4.0.14",
31
- "@remotion/renderer": "4.0.14",
32
- "@remotion/bundler": "4.0.14"
29
+ "@remotion/bundler": "4.0.16",
30
+ "@remotion/cli": "4.0.16",
31
+ "@remotion/renderer": "4.0.16",
32
+ "remotion": "4.0.16"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.266",
@@ -44,11 +44,11 @@
44
44
  "typescript": "4.9.5",
45
45
  "vitest": "0.31.1",
46
46
  "zip-lib": "^0.7.2",
47
- "@remotion/bundler": "4.0.14",
48
- "@remotion/compositor-linux-arm64-gnu": "4.0.14"
47
+ "@remotion/bundler": "4.0.16",
48
+ "@remotion/compositor-linux-arm64-gnu": "4.0.16"
49
49
  },
50
50
  "peerDependencies": {
51
- "@remotion/bundler": "4.0.14"
51
+ "@remotion/bundler": "4.0.16"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
Binary file