@remotion/lambda 4.0.166 → 4.0.168

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 (51) hide show
  1. package/dist/api/render-still-on-lambda.js +1 -1
  2. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +1 -4
  3. package/dist/functions/helpers/get-current-region.d.ts +1 -1
  4. package/dist/functions/helpers/streamify-response.d.ts +14 -7
  5. package/dist/functions/helpers/streamify-response.js +41 -29
  6. package/dist/functions/index.d.ts +4 -0
  7. package/dist/functions/index.js +3 -2
  8. package/dist/functions/streaming/streaming.js +2 -2
  9. package/dist/shared/aws-clients.js +13 -8
  10. package/dist/shared/call-lambda.js +33 -8
  11. package/package.json +9 -11
  12. package/remotionlambda-arm64.zip +0 -0
  13. package/dist/functions/helpers/check-if-render-exists.d.ts +0 -3
  14. package/dist/functions/helpers/check-if-render-exists.js +0 -15
  15. package/dist/functions/helpers/delete-chunks.d.ts +0 -9
  16. package/dist/functions/helpers/delete-chunks.js +0 -25
  17. package/dist/functions/helpers/get-cleanup-progress.d.ts +0 -8
  18. package/dist/functions/helpers/get-cleanup-progress.js +0 -33
  19. package/dist/functions/helpers/get-encoding-metadata.d.ts +0 -7
  20. package/dist/functions/helpers/get-encoding-metadata.js +0 -15
  21. package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +0 -1
  22. package/dist/functions/helpers/get-encoding-progress-step-size.js +0 -7
  23. package/dist/functions/helpers/get-files-to-delete.d.ts +0 -8
  24. package/dist/functions/helpers/get-files-to-delete.js +0 -18
  25. package/dist/functions/helpers/get-final-encoding-status.d.ts +0 -6
  26. package/dist/functions/helpers/get-final-encoding-status.js +0 -18
  27. package/dist/functions/helpers/get-folder-size.d.ts +0 -1
  28. package/dist/functions/helpers/get-folder-size.js +0 -8
  29. package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +0 -3
  30. package/dist/functions/helpers/get-lambdas-invoked-stats.js +0 -2
  31. package/dist/functions/helpers/get-post-render-data.d.ts +0 -8
  32. package/dist/functions/helpers/get-post-render-data.js +0 -22
  33. package/dist/functions/helpers/get-render-metadata.d.ts +0 -8
  34. package/dist/functions/helpers/get-render-metadata.js +0 -17
  35. package/dist/functions/helpers/get-rendered-frames-progress.d.ts +0 -8
  36. package/dist/functions/helpers/get-rendered-frames-progress.js +0 -37
  37. package/dist/functions/helpers/get-time-to-finish.d.ts +0 -5
  38. package/dist/functions/helpers/get-time-to-finish.js +0 -13
  39. package/dist/functions/helpers/streaming-payloads.d.ts +0 -19
  40. package/dist/functions/helpers/streaming-payloads.js +0 -25
  41. package/dist/functions/helpers/write-post-render-data.d.ts +0 -9
  42. package/dist/functions/helpers/write-post-render-data.js +0 -18
  43. package/dist/functions/merge.d.ts +0 -9
  44. package/dist/functions/merge.js +0 -61
  45. package/dist/shared/chunk-progress.d.ts +0 -8
  46. package/dist/shared/chunk-progress.js +0 -2034
  47. package/dist/shared/parse-chunk-key.d.ts +0 -5
  48. package/dist/shared/parse-chunk-key.js +0 -15
  49. package/dist/shared/parse-lambda-initialized-key.d.ts +0 -5
  50. package/dist/shared/parse-lambda-initialized-key.js +0 -15
  51. package/remotion-lambda-cli.js +0 -12
@@ -39,7 +39,7 @@ const internalRenderStillOnLambda = async (input) => {
39
39
  }
40
40
  },
41
41
  timeoutInTest: 120000,
42
- retriesRemaining: 0,
42
+ retriesRemaining: 1,
43
43
  })
44
44
  .then(() => {
45
45
  reject(new Error('Expected response to be streamed'));
@@ -3,8 +3,5 @@ export declare const planFrameRanges: ({ framesPerLambda, frameRange, everyNthFr
3
3
  frameRange: [number, number];
4
4
  everyNthFrame: number;
5
5
  }) => {
6
- chunks: [
7
- number,
8
- number
9
- ][];
6
+ chunks: [number, number][];
10
7
  };
@@ -1 +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
+ 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,14 +1,21 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { Stream } from 'stream';
4
- export declare class ResponseStream extends Stream.Writable {
3
+ import { Writable } from 'stream';
4
+ type Chunk = {
5
+ PayloadChunk: {
6
+ Payload: string | Buffer | null;
7
+ };
8
+ InvokeComplete: boolean;
9
+ };
10
+ export declare class ResponseStream extends Writable {
11
+ private queue;
12
+ private waitingResolve;
5
13
  private response;
6
- _contentType?: string;
7
- _isBase64Encoded?: boolean;
8
14
  constructor();
9
- _write(chunk: string, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
15
+ _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
16
+ _finish(): void;
10
17
  getBufferedData(): Buffer;
11
- setContentType(contentType: string): void;
12
- setIsBase64Encoded(isBase64Encoded: boolean): void;
18
+ [Symbol.asyncIterator](): AsyncGenerator<Chunk, void, void>;
13
19
  }
14
20
  export declare function streamifyResponse(handler: Function): Function;
21
+ export {};
@@ -2,33 +2,58 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.streamifyResponse = exports.ResponseStream = void 0;
4
4
  const stream_1 = require("stream");
5
- class ResponseStream extends stream_1.Stream.Writable {
5
+ class ResponseStream extends stream_1.Writable {
6
6
  constructor() {
7
7
  super();
8
+ this.queue = [];
9
+ this.waitingResolve = [];
8
10
  this.response = [];
9
11
  }
10
12
  _write(chunk, encoding, callback) {
13
+ const data = Buffer.from(chunk, encoding);
14
+ const resolve = this.waitingResolve.shift();
15
+ if (resolve) {
16
+ resolve({ PayloadChunk: { Payload: data }, InvokeComplete: false });
17
+ }
18
+ else {
19
+ this.queue.push({ PayloadChunk: { Payload: data }, InvokeComplete: false });
20
+ }
11
21
  this.response.push(Buffer.from(chunk, encoding));
12
22
  callback();
13
23
  }
24
+ _finish() {
25
+ const resolve = this.waitingResolve.shift();
26
+ if (resolve) {
27
+ resolve({ PayloadChunk: { Payload: null }, InvokeComplete: true });
28
+ }
29
+ else {
30
+ this.queue.push({ PayloadChunk: { Payload: null }, InvokeComplete: true });
31
+ }
32
+ }
14
33
  getBufferedData() {
15
34
  return Buffer.concat(this.response);
16
35
  }
17
- setContentType(contentType) {
18
- this._contentType = contentType;
19
- }
20
- setIsBase64Encoded(isBase64Encoded) {
21
- this._isBase64Encoded = isBase64Encoded;
36
+ async *[Symbol.asyncIterator]() {
37
+ while (true) {
38
+ if (this.queue.length > 0) {
39
+ yield this.queue.shift();
40
+ }
41
+ else {
42
+ // Wait for new data to be written
43
+ yield new Promise((resolve) => {
44
+ this.waitingResolve.push((data) => {
45
+ Promise.resolve(data).then((d) => {
46
+ if (d) {
47
+ resolve(d);
48
+ }
49
+ });
50
+ });
51
+ });
52
+ }
53
+ }
22
54
  }
23
55
  }
24
56
  exports.ResponseStream = ResponseStream;
25
- function patchArgs(argList) {
26
- if (!(argList[1] instanceof ResponseStream)) {
27
- const responseStream = new ResponseStream();
28
- argList.splice(1, 0, responseStream);
29
- }
30
- return argList[1];
31
- }
32
57
  function streamifyResponse(handler) {
33
58
  // Check if we are inside Lambda
34
59
  if (process.env.AWS_LAMBDA_FUNCTION_VERSION &&
@@ -38,21 +63,8 @@ function streamifyResponse(handler) {
38
63
  // @ts-expect-error
39
64
  return awslambda.streamifyResponse(handler);
40
65
  }
41
- return new Proxy(handler, {
42
- async apply(target, _, argList) {
43
- const responseStream = patchArgs(argList);
44
- await target(...argList);
45
- return {
46
- EventStream: [
47
- {
48
- PayloadChunk: {
49
- Payload: responseStream.getBufferedData(),
50
- },
51
- InvokeComplete: true,
52
- },
53
- ],
54
- };
55
- },
56
- });
66
+ return () => {
67
+ throw new Error('Lambda not detected');
68
+ };
57
69
  }
58
70
  exports.streamifyResponse = streamifyResponse;
@@ -1,6 +1,10 @@
1
+ import type { LambdaPayload } from '../shared/constants';
2
+ import type { RequestContext } from './helpers/request-context';
3
+ import type { ResponseStream } from './helpers/streamify-response';
1
4
  export type OrError<T> = T | {
2
5
  type: 'error';
3
6
  message: string;
4
7
  stack: string;
5
8
  };
9
+ export declare const routine: (params: LambdaPayload, responseStream: ResponseStream, context: RequestContext) => Promise<void>;
6
10
  export declare const handler: Function;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handler = void 0;
3
+ exports.handler = exports.routine = void 0;
4
4
  const renderer_1 = require("@remotion/renderer");
5
5
  const constants_1 = require("../shared/constants");
6
6
  const compositions_1 = require("./compositions");
@@ -183,4 +183,5 @@ const routine = async (params, responseStream, context) => {
183
183
  await responseWriter.end();
184
184
  }
185
185
  };
186
- exports.handler = (0, streamify_response_1.streamifyResponse)(routine);
186
+ exports.routine = routine;
187
+ exports.handler = (0, streamify_response_1.streamifyResponse)(exports.routine);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeStreamPayload = exports.messageTypeIdToMessageType = exports.formatMap = void 0;
4
- const pure_1 = require("@remotion/renderer/pure");
4
+ const streaming_1 = require("@remotion/streaming");
5
5
  const framesRendered = 'frames-rendered';
6
6
  const errorOccurred = 'error-occurred';
7
7
  const renderIdDetermined = 'render-id-determined';
@@ -49,7 +49,7 @@ const makeStreamPayload = ({ message }) => {
49
49
  const body = exports.formatMap[message.type] === 'json'
50
50
  ? new TextEncoder().encode(JSON.stringify(message.payload))
51
51
  : message.payload;
52
- return pure_1.NoReactAPIs.makeStreamPayloadMessage({
52
+ return (0, streaming_1.makeStreamPayloadMessage)({
53
53
  body,
54
54
  nonce: messageTypeToMessageId(message.type),
55
55
  status: 0,
@@ -126,6 +126,13 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
126
126
  });
127
127
  if (!_clients[key]) {
128
128
  (0, check_credentials_1.checkCredentials)();
129
+ const lambdaOptions = service === 'lambda'
130
+ ? {
131
+ httpsAgent: {
132
+ maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER * 2,
133
+ },
134
+ }
135
+ : undefined;
129
136
  const client = customCredentials
130
137
  ? new Client({
131
138
  region: (_a = customCredentials.region) !== null && _a !== void 0 ? _a : 'us-east-1',
@@ -136,19 +143,17 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
136
143
  }
137
144
  : undefined,
138
145
  endpoint: customCredentials.endpoint,
146
+ requestHandler: lambdaOptions,
139
147
  })
140
148
  : process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK
141
- ? new Client({ region })
149
+ ? new Client({
150
+ region,
151
+ requestHandler: lambdaOptions,
152
+ })
142
153
  : new Client({
143
154
  region,
144
155
  credentials: getCredentials(),
145
- requestHandler: service === 'lambda'
146
- ? {
147
- httpsAgent: {
148
- maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER + 50,
149
- },
150
- }
151
- : undefined,
156
+ requestHandler: lambdaOptions,
152
157
  });
153
158
  if (process.env.REMOTION_DISABLE_AWS_CLIENT_CACHE) {
154
159
  return client;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.callLambdaWithStreaming = exports.callLambda = void 0;
4
4
  const client_lambda_1 = require("@aws-sdk/client-lambda");
5
- const pure_1 = require("@remotion/renderer/pure");
6
- const streaming_1 = require("../functions/streaming/streaming");
5
+ const streaming_1 = require("@remotion/streaming");
6
+ const streaming_2 = require("../functions/streaming/streaming");
7
7
  const aws_clients_1 = require("./aws-clients");
8
8
  const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
9
9
  const parseJsonOrThrowSource = (data, type) => {
@@ -37,7 +37,8 @@ const callLambdaWithStreaming = async (options) => {
37
37
  if (options.retriesRemaining === 0) {
38
38
  throw err;
39
39
  }
40
- if (!err.message.includes(INVALID_JSON_MESSAGE)) {
40
+ if (!err.message.includes(INVALID_JSON_MESSAGE) &&
41
+ !err.message.includes(LAMBDA_STREAM_STALL)) {
41
42
  throw err;
42
43
  }
43
44
  return (0, exports.callLambdaWithStreaming)({
@@ -62,14 +63,37 @@ const callLambdaWithoutRetry = async ({ functionName, type, payload, region, tim
62
63
  throw new Error(`Invalid JSON (${type}): ${JSON.stringify(decoded)}`);
63
64
  }
64
65
  };
65
- const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
66
- const res = await (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
66
+ const STREAM_STALL_TIMEOUT = 7000;
67
+ const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
68
+ const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type, payload, }) => {
69
+ const resProm = (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
67
70
  FunctionName: functionName,
68
71
  Payload: JSON.stringify({ type, ...payload }),
69
72
  }));
70
- const { onData, clear } = pure_1.NoReactAPIs.makeStreamer((status, messageTypeId, data) => {
71
- const messageType = (0, streaming_1.messageTypeIdToMessageType)(messageTypeId);
72
- const innerPayload = streaming_1.formatMap[messageType] === 'json'
73
+ let cleanup = () => undefined;
74
+ const timeout = new Promise((_resolve, reject) => {
75
+ const int = setTimeout(() => {
76
+ reject(new Error(LAMBDA_STREAM_STALL));
77
+ }, STREAM_STALL_TIMEOUT);
78
+ cleanup = () => {
79
+ clearTimeout(int);
80
+ };
81
+ });
82
+ const res = await Promise.race([resProm, timeout]);
83
+ cleanup();
84
+ return res;
85
+ };
86
+ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
87
+ const res = await invokeStreamOrTimeout({
88
+ functionName,
89
+ payload,
90
+ region,
91
+ timeoutInTest,
92
+ type,
93
+ });
94
+ const { onData, clear } = (0, streaming_1.makeStreamer)((status, messageTypeId, data) => {
95
+ const messageType = (0, streaming_2.messageTypeIdToMessageType)(messageTypeId);
96
+ const innerPayload = streaming_2.formatMap[messageType] === 'json'
73
97
  ? parseJsonOrThrowSource(data, messageType)
74
98
  : data;
75
99
  const message = {
@@ -97,6 +121,7 @@ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload
97
121
  }
98
122
  throw new Error(`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.`);
99
123
  }
124
+ break;
100
125
  }
101
126
  }
102
127
  clear();
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.166",
3
+ "version": "4.0.168",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
7
- "bin": {
8
- "remotion-lambda": "remotion-lambda-cli.js"
9
- },
10
7
  "author": "Jonny Burger <jonny@remotion.dev>",
11
8
  "license": "MIT",
12
9
  "repository": {
@@ -25,10 +22,11 @@
25
22
  "@aws-sdk/s3-request-presigner": "3.583.0",
26
23
  "mime-types": "2.1.34",
27
24
  "zod": "3.22.3",
28
- "@remotion/bundler": "4.0.166",
29
- "@remotion/cli": "4.0.166",
30
- "remotion": "4.0.166",
31
- "@remotion/renderer": "4.0.166"
25
+ "@remotion/bundler": "4.0.168",
26
+ "@remotion/cli": "4.0.168",
27
+ "@remotion/streaming": "4.0.168",
28
+ "@remotion/renderer": "4.0.168",
29
+ "remotion": "4.0.168"
32
30
  },
33
31
  "devDependencies": {
34
32
  "@jonny/eslint-config": "3.0.281",
@@ -44,11 +42,11 @@
44
42
  "ts-node": "10.9.2",
45
43
  "vitest": "0.31.1",
46
44
  "zip-lib": "^0.7.2",
47
- "@remotion/bundler": "4.0.166",
48
- "@remotion/compositor-linux-arm64-gnu": "4.0.166"
45
+ "@remotion/bundler": "4.0.168",
46
+ "@remotion/compositor-linux-arm64-gnu": "4.0.168"
49
47
  },
50
48
  "peerDependencies": {
51
- "@remotion/bundler": "4.0.166"
49
+ "@remotion/bundler": "4.0.168"
52
50
  },
53
51
  "publishConfig": {
54
52
  "access": "public"
Binary file
@@ -1,3 +0,0 @@
1
- import type { _Object } from '@aws-sdk/client-s3';
2
- import type { AwsRegion } from '../../client';
3
- export declare const checkIfRenderExists: (contents: _Object[], renderId: string, bucketName: string, region: AwsRegion) => void;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkIfRenderExists = void 0;
4
- const constants_1 = require("../../shared/constants");
5
- const checkIfRenderExists = (contents, renderId, bucketName, region) => {
6
- const initializedExists = Boolean(contents.find((c) => {
7
- var _a;
8
- return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.overallProgressKey)(renderId));
9
- }));
10
- if (!initializedExists) {
11
- // ! Error message is checked in progress handler and will be retried. Make sure to update
12
- throw new TypeError(`No render with ID "${renderId}" found in bucket ${bucketName} and region ${region}`);
13
- }
14
- };
15
- exports.checkIfRenderExists = checkIfRenderExists;
@@ -1,9 +0,0 @@
1
- import type { _Object } from '@aws-sdk/client-s3';
2
- import type { AwsRegion } from '../../pricing/aws-regions';
3
- import type { CleanupJob } from './get-files-to-delete';
4
- export declare const cleanupFiles: ({ bucket, region, contents, jobs, }: {
5
- bucket: string;
6
- region: AwsRegion;
7
- contents: _Object[];
8
- jobs: CleanupJob[];
9
- }) => Promise<number>;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanupFiles = void 0;
4
- const clean_items_1 = require("../../api/clean-items");
5
- const cleanupFiles = async ({ bucket, region, contents, jobs, }) => {
6
- const start = Date.now();
7
- await (0, clean_items_1.cleanItems)({
8
- bucket,
9
- region,
10
- list: jobs.map((item) => {
11
- var _a;
12
- if (item.type === 'exact') {
13
- return item.name;
14
- }
15
- if (item.type === 'prefix') {
16
- return (_a = contents.find((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith(item.name); })) === null || _a === void 0 ? void 0 : _a.Key;
17
- }
18
- throw new Error('unexpected in deleteChunks()');
19
- }),
20
- onAfterItemDeleted: () => undefined,
21
- onBeforeItemDeleted: () => undefined,
22
- });
23
- return Date.now() - start;
24
- };
25
- exports.cleanupFiles = cleanupFiles;
@@ -1,8 +0,0 @@
1
- import type { _Object } from '@aws-sdk/client-s3';
2
- import type { CleanupInfo } from '../../shared/constants';
3
- export declare const getCleanupProgress: ({ contents, output, chunkCount, renderId, }: {
4
- contents: _Object[];
5
- output: string | null;
6
- chunkCount: number;
7
- renderId: string;
8
- }) => null | CleanupInfo;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCleanupProgress = void 0;
4
- const get_files_to_delete_1 = require("./get-files-to-delete");
5
- const getCleanupProgress = ({ contents, output, chunkCount, renderId, }) => {
6
- if (output === null) {
7
- return null;
8
- }
9
- const filesToDelete = (0, get_files_to_delete_1.getFilesToDelete)({
10
- chunkCount,
11
- renderId,
12
- });
13
- const filesStillThere = contents.filter((c) => {
14
- return filesToDelete.find((f) => {
15
- var _a;
16
- if (f.type === 'exact') {
17
- return f.name === c.Key;
18
- }
19
- if (f.type === 'prefix') {
20
- return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith(f.name);
21
- }
22
- throw new Error('Unexpected in getCleanupProgress');
23
- });
24
- });
25
- const filesDeleted = Math.max(0, filesToDelete.length - filesStillThere.length);
26
- return {
27
- minFilesToDelete: filesToDelete.length,
28
- filesDeleted,
29
- // We don't know. Only if post render data is saved, we know the timing
30
- doneIn: null,
31
- };
32
- };
33
- exports.getCleanupProgress = getCleanupProgress;
@@ -1,7 +0,0 @@
1
- import type { _Object } from '@aws-sdk/client-s3';
2
- import type { EncodingProgress } from '../../defaults';
3
- export declare const getEncodingMetadata: ({ exists, frameCount, stepSize, }: {
4
- exists: _Object | undefined;
5
- frameCount: number;
6
- stepSize: number;
7
- }) => EncodingProgress | null;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEncodingMetadata = void 0;
4
- const chunk_progress_1 = require("../../shared/chunk-progress");
5
- const getEncodingMetadata = ({ exists, frameCount, stepSize, }) => {
6
- if (!exists) {
7
- return null;
8
- }
9
- const framesEncoded = (0, chunk_progress_1.getProgressOfChunk)(exists.ETag);
10
- // We only report every 100 frames encoded so that we are able to report up to 2000 * 100 ETags => 200000 frames
11
- return {
12
- framesEncoded: Math.min(frameCount, framesEncoded * stepSize),
13
- };
14
- };
15
- exports.getEncodingMetadata = getEncodingMetadata;
@@ -1 +0,0 @@
1
- export declare const getEncodingProgressStepSize: (totalFrames: number) => number;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEncodingProgressStepSize = void 0;
4
- const getEncodingProgressStepSize = (totalFrames) => {
5
- return Math.min(100, Math.max(5, totalFrames / 10));
6
- };
7
- exports.getEncodingProgressStepSize = getEncodingProgressStepSize;
@@ -1,8 +0,0 @@
1
- export type CleanupJob = {
2
- name: string;
3
- type: 'exact' | 'prefix';
4
- };
5
- export declare const getFilesToDelete: ({ chunkCount, renderId, }: {
6
- chunkCount: number;
7
- renderId: string;
8
- }) => CleanupJob[];
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFilesToDelete = void 0;
4
- const constants_1 = require("../../shared/constants");
5
- const getFilesToDelete = ({ chunkCount, renderId, }) => {
6
- const lambdaTimings = new Array(chunkCount)
7
- .fill(true)
8
- .map((_x, i) => (0, constants_1.lambdaTimingsPrefixForChunk)(renderId, i));
9
- return [
10
- ...lambdaTimings.map((i) => {
11
- return {
12
- name: i,
13
- type: 'prefix',
14
- };
15
- }),
16
- ];
17
- };
18
- exports.getFilesToDelete = getFilesToDelete;
@@ -1,6 +0,0 @@
1
- import type { EncodingProgress, RenderMetadata } from '../../shared/constants';
2
- export declare const getFinalEncodingStatus: ({ encodingProgress, renderMetadata, outputFileExists, }: {
3
- encodingProgress: EncodingProgress | null;
4
- renderMetadata: RenderMetadata | null;
5
- outputFileExists: boolean;
6
- }) => EncodingProgress | null;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFinalEncodingStatus = void 0;
4
- const getFinalEncodingStatus = ({ encodingProgress, renderMetadata, outputFileExists, }) => {
5
- if (!renderMetadata) {
6
- return null;
7
- }
8
- if (encodingProgress) {
9
- return encodingProgress;
10
- }
11
- if (outputFileExists) {
12
- return {
13
- framesEncoded: renderMetadata.videoConfig.durationInFrames,
14
- };
15
- }
16
- return null;
17
- };
18
- exports.getFinalEncodingStatus = getFinalEncodingStatus;
@@ -1 +0,0 @@
1
- export declare function getFolderSizeRecursively(folder: string): number;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFolderSizeRecursively = void 0;
4
- const get_files_in_folder_1 = require("./get-files-in-folder");
5
- function getFolderSizeRecursively(folder) {
6
- return (0, get_files_in_folder_1.getFolderFiles)(folder).reduce((a, b) => a + b.size, 0);
7
- }
8
- exports.getFolderSizeRecursively = getFolderSizeRecursively;
@@ -1,3 +0,0 @@
1
- export type LambdaInvokeStats = {
2
- lambdasInvoked: number;
3
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../../pricing/aws-regions';
2
- import type { PostRenderData } from '../../shared/constants';
3
- export declare const getPostRenderData: ({ bucketName, renderId, region, expectedBucketOwner, }: {
4
- bucketName: string;
5
- renderId: string;
6
- region: AwsRegion;
7
- expectedBucketOwner: string;
8
- }) => Promise<PostRenderData | null>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPostRenderData = void 0;
4
- const constants_1 = require("../../shared/constants");
5
- const stream_to_string_1 = require("../../shared/stream-to-string");
6
- const io_1 = require("./io");
7
- const getPostRenderData = async ({ bucketName, renderId, region, expectedBucketOwner, }) => {
8
- try {
9
- const data = await (0, io_1.lambdaReadFile)({
10
- bucketName,
11
- key: (0, constants_1.postRenderDataKey)(renderId),
12
- region,
13
- expectedBucketOwner,
14
- });
15
- return JSON.parse(await (0, stream_to_string_1.streamToString)(data));
16
- }
17
- catch (err) {
18
- // Does not exist
19
- return null;
20
- }
21
- };
22
- exports.getPostRenderData = getPostRenderData;
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../../pricing/aws-regions';
2
- import type { RenderMetadata } from '../../shared/constants';
3
- export declare const getRenderMetadata: ({ bucketName, renderId, region, expectedBucketOwner, }: {
4
- bucketName: string;
5
- renderId: string;
6
- region: AwsRegion;
7
- expectedBucketOwner: string;
8
- }) => Promise<RenderMetadata>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRenderMetadata = void 0;
4
- const constants_1 = require("../../shared/constants");
5
- const stream_to_string_1 = require("../../shared/stream-to-string");
6
- const io_1 = require("./io");
7
- const getRenderMetadata = async ({ bucketName, renderId, region, expectedBucketOwner, }) => {
8
- const Body = await (0, io_1.lambdaReadFile)({
9
- bucketName,
10
- key: (0, constants_1.renderMetadataKey)(renderId),
11
- region,
12
- expectedBucketOwner,
13
- });
14
- const renderMetadataResponse = JSON.parse(await (0, stream_to_string_1.streamToString)(Body));
15
- return renderMetadataResponse;
16
- };
17
- exports.getRenderMetadata = getRenderMetadata;