@remotion/lambda 4.0.181 → 4.0.182

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 (53) hide show
  1. package/dist/api/deploy-site.d.ts +4 -4
  2. package/dist/api/deploy-site.js +12 -6
  3. package/dist/api/render-media-on-lambda.d.ts +1 -0
  4. package/dist/api/render-media-on-lambda.js +5 -0
  5. package/dist/cli/commands/render/render.js +7 -0
  6. package/dist/cli/commands/sites/create.js +6 -2
  7. package/dist/cli/helpers/find-function-name.js +1 -1
  8. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +1 -4
  9. package/dist/functions/helpers/check-if-render-exists.d.ts +3 -0
  10. package/dist/functions/helpers/check-if-render-exists.js +15 -0
  11. package/dist/functions/helpers/delete-chunks.d.ts +9 -0
  12. package/dist/functions/helpers/delete-chunks.js +25 -0
  13. package/dist/functions/helpers/get-cleanup-progress.d.ts +10 -0
  14. package/dist/functions/helpers/get-cleanup-progress.js +35 -0
  15. package/dist/functions/helpers/get-encoding-metadata.d.ts +7 -0
  16. package/dist/functions/helpers/get-encoding-metadata.js +15 -0
  17. package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +1 -0
  18. package/dist/functions/helpers/get-encoding-progress-step-size.js +7 -0
  19. package/dist/functions/helpers/get-files-to-delete.d.ts +10 -0
  20. package/dist/functions/helpers/get-files-to-delete.js +52 -0
  21. package/dist/functions/helpers/get-final-encoding-status.d.ts +6 -0
  22. package/dist/functions/helpers/get-final-encoding-status.js +18 -0
  23. package/dist/functions/helpers/get-folder-size.d.ts +1 -0
  24. package/dist/functions/helpers/get-folder-size.js +8 -0
  25. package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +8 -0
  26. package/dist/functions/helpers/get-lambdas-invoked-stats.js +14 -0
  27. package/dist/functions/helpers/get-post-render-data.d.ts +8 -0
  28. package/dist/functions/helpers/get-post-render-data.js +22 -0
  29. package/dist/functions/helpers/get-render-metadata.d.ts +8 -0
  30. package/dist/functions/helpers/get-render-metadata.js +17 -0
  31. package/dist/functions/helpers/get-rendered-frames-progress.d.ts +8 -0
  32. package/dist/functions/helpers/get-rendered-frames-progress.js +37 -0
  33. package/dist/functions/helpers/get-time-to-finish.d.ts +5 -0
  34. package/dist/functions/helpers/get-time-to-finish.js +13 -0
  35. package/dist/functions/helpers/streaming-payloads.d.ts +19 -0
  36. package/dist/functions/helpers/streaming-payloads.js +25 -0
  37. package/dist/functions/helpers/write-post-render-data.d.ts +9 -0
  38. package/dist/functions/helpers/write-post-render-data.js +18 -0
  39. package/dist/functions/merge.d.ts +9 -0
  40. package/dist/functions/merge.js +61 -0
  41. package/dist/internals.d.ts +5 -5
  42. package/dist/shared/chunk-progress.d.ts +9 -0
  43. package/dist/shared/chunk-progress.js +2034 -0
  44. package/dist/shared/get-aws-urls.d.ts +5 -0
  45. package/dist/shared/get-aws-urls.js +5 -1
  46. package/dist/shared/parse-chunk-key.d.ts +5 -0
  47. package/dist/shared/parse-chunk-key.js +15 -0
  48. package/dist/shared/parse-lambda-initialized-key.d.ts +5 -0
  49. package/dist/shared/parse-lambda-initialized-key.js +15 -0
  50. package/dist/shared/serialize-props.d.ts +14 -0
  51. package/dist/shared/serialize-props.js +36 -0
  52. package/package.json +9 -9
  53. package/remotionlambda-arm64.zip +0 -0
@@ -1,4 +1,4 @@
1
- import type { GitSource, WebpackOverrideFn } from '@remotion/bundler';
1
+ import { type GitSource, type WebpackOverrideFn } from '@remotion/bundler';
2
2
  import type { ToOptions } from '@remotion/renderer';
3
3
  import type { BrowserSafeApis } from '@remotion/renderer/client';
4
4
  import type { AwsRegion } from '../pricing/aws-regions';
@@ -59,11 +59,11 @@ export declare const internalDeploySite: (args_0: MandatoryParameters & {
59
59
  getValue: ({ commandLine }: {
60
60
  commandLine: Record<string, unknown>;
61
61
  }) => {
62
- value: "error" | "verbose" | "info" | "warn";
62
+ value: "verbose" | "info" | "warn" | "error";
63
63
  source: string;
64
64
  };
65
- setConfig: (newLogLevel: "error" | "verbose" | "info" | "warn") => void;
66
- type: "error" | "verbose" | "info" | "warn";
65
+ setConfig: (newLogLevel: "verbose" | "info" | "warn" | "error") => void;
66
+ type: "verbose" | "info" | "warn" | "error";
67
67
  };
68
68
  readonly throwIfSiteExists: {
69
69
  cliFlag: string;
@@ -20,7 +20,7 @@ const validate_site_name_1 = require("../shared/validate-site-name");
20
20
  const bucket_exists_1 = require("./bucket-exists");
21
21
  const upload_dir_1 = require("./upload-dir");
22
22
  const mandatoryDeploySite = async ({ bucketName, entryPoint, siteName, options, region, privacy, gitSource, throwIfSiteExists, }) => {
23
- var _a, _b, _c, _d;
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
24
  (0, validate_aws_region_1.validateAwsRegion)(region);
25
25
  (0, validate_bucketname_1.validateBucketName)(bucketName, {
26
26
  mustStartWithRemotion: !(options === null || options === void 0 ? void 0 : options.bypassBucketNameValidation),
@@ -49,12 +49,18 @@ const mandatoryDeploySite = async ({ bucketName, entryPoint, siteName, options,
49
49
  publicPath: `/${subFolder}/`,
50
50
  webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : ((f) => f),
51
51
  enableCaching: (_b = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _b !== void 0 ? _b : true,
52
- publicDir: options === null || options === void 0 ? void 0 : options.publicDir,
53
- rootDir: options === null || options === void 0 ? void 0 : options.rootDir,
54
- ignoreRegisterRootWarning: options === null || options === void 0 ? void 0 : options.ignoreRegisterRootWarning,
55
- onProgress: (_c = options === null || options === void 0 ? void 0 : options.onBundleProgress) !== null && _c !== void 0 ? _c : (() => undefined),
52
+ publicDir: (_c = options === null || options === void 0 ? void 0 : options.publicDir) !== null && _c !== void 0 ? _c : null,
53
+ rootDir: (_d = options === null || options === void 0 ? void 0 : options.rootDir) !== null && _d !== void 0 ? _d : null,
54
+ ignoreRegisterRootWarning: (_e = options === null || options === void 0 ? void 0 : options.ignoreRegisterRootWarning) !== null && _e !== void 0 ? _e : false,
55
+ onProgress: (_f = options === null || options === void 0 ? void 0 : options.onBundleProgress) !== null && _f !== void 0 ? _f : (() => undefined),
56
56
  entryPoint,
57
57
  gitSource,
58
+ bufferStateDelayInMilliseconds: null,
59
+ maxTimelineTracks: null,
60
+ onDirectoryCreated: () => undefined,
61
+ onPublicDirCopyProgress: () => undefined,
62
+ onSymlinkDetected: () => undefined,
63
+ outDir: null,
58
64
  }),
59
65
  ]);
60
66
  if (throwIfSiteExists && files.length > 0) {
@@ -74,7 +80,7 @@ const mandatoryDeploySite = async ({ bucketName, entryPoint, siteName, options,
74
80
  bucket: bucketName,
75
81
  region,
76
82
  localDir: bundled,
77
- onProgress: (_d = options === null || options === void 0 ? void 0 : options.onUploadProgress) !== null && _d !== void 0 ? _d : (() => undefined),
83
+ onProgress: (_g = options === null || options === void 0 ? void 0 : options.onUploadProgress) !== null && _g !== void 0 ? _g : (() => undefined),
78
84
  keyPrefix: subFolder,
79
85
  privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
80
86
  toUpload,
@@ -51,6 +51,7 @@ export type RenderMediaOnLambdaOutput = {
51
51
  cloudWatchMainLogs: string;
52
52
  lambdaInsightsLogs: string;
53
53
  folderInS3Console: string;
54
+ progressJsonInConsole: string;
54
55
  };
55
56
  export declare const internalRenderMediaOnLambdaRaw: (input: InnerRenderMediaOnLambdaInput) => Promise<RenderMediaOnLambdaOutput>;
56
57
  export declare const renderMediaOnLambdaOptionalToRequired: (options: RenderMediaOnLambdaInput) => InnerRenderMediaOnLambdaInput;
@@ -43,6 +43,11 @@ const internalRenderMediaOnLambdaRaw = async (input) => {
43
43
  functionName,
44
44
  region,
45
45
  }),
46
+ progressJsonInConsole: (0, get_aws_urls_1.getProgressJsonUrl)({
47
+ bucketName: res.bucketName,
48
+ renderId: res.renderId,
49
+ region,
50
+ }),
46
51
  };
47
52
  }
48
53
  catch (err) {
@@ -245,6 +245,13 @@ const renderCommand = async (args, remotionRoot, logLevel) => {
245
245
  log_1.Log.info({ indent: false, logLevel }, cli_1.CliInternals.chalk.gray(`Bucket: ${cli_1.CliInternals.makeHyperlink({ text: res.bucketName, fallback: res.bucketName, url: `https://${(0, get_aws_region_1.getAwsRegion)()}.console.aws.amazon.com/s3/buckets/${res.bucketName}/?region=${(0, get_aws_region_1.getAwsRegion)()}` })}`));
246
246
  log_1.Log.info({ indent: false, logLevel }, cli_1.CliInternals.chalk.gray(`Function: ${cli_1.CliInternals.makeHyperlink({ text: functionName, fallback: functionName, url: `https://${(0, get_aws_region_1.getAwsRegion)()}.console.aws.amazon.com/lambda/home#/functions/${functionName}?tab=code` })}`));
247
247
  log_1.Log.info({ indent: false, logLevel }, cli_1.CliInternals.chalk.gray(`Render ID: ${cli_1.CliInternals.makeHyperlink({ text: res.renderId, fallback: res.renderId, url: res.folderInS3Console })}`));
248
+ log_1.Log.info({ indent: false, logLevel }, cli_1.CliInternals.chalk.gray(`progress.json: ${cli_1.CliInternals.makeHyperlink({
249
+ text: (clickInstruction) => {
250
+ return `${clickInstruction} to view`;
251
+ },
252
+ fallback: res.progressJsonInConsole,
253
+ url: res.progressJsonInConsole,
254
+ })}`));
248
255
  log_1.Log.info({
249
256
  indent: false,
250
257
  logLevel,
@@ -16,7 +16,7 @@ const progress_bar_1 = require("../../helpers/progress-bar");
16
16
  const quit_1 = require("../../helpers/quit");
17
17
  const log_1 = require("../../log");
18
18
  exports.SITES_CREATE_SUBCOMMAND = 'create';
19
- const { folderExpiryOption, publicDirOption, throwIfSiteExistsOption } = client_1.BrowserSafeApis.options;
19
+ const { folderExpiryOption, publicDirOption, throwIfSiteExistsOption, disableGitSourceOption, } = client_1.BrowserSafeApis.options;
20
20
  const sitesCreateSubcommand = async (args, remotionRoot, logLevel) => {
21
21
  var _a, _b, _c, _d;
22
22
  const { file, reason } = cli_1.CliInternals.findEntryPoint({
@@ -87,6 +87,10 @@ const sitesCreateSubcommand = async (args, remotionRoot, logLevel) => {
87
87
  const throwIfSiteExists = throwIfSiteExistsOption.getValue({
88
88
  commandLine: cli_1.CliInternals.parsedCli,
89
89
  }).value;
90
+ const disableGitSource = disableGitSourceOption.getValue({
91
+ commandLine: cli_1.CliInternals.parsedCli,
92
+ }).value;
93
+ const gitSource = cli_1.CliInternals.getGitSource({ remotionRoot, disableGitSource });
90
94
  const { serveUrl, siteName, stats } = await internals_1.LambdaInternals.internalDeploySite({
91
95
  entryPoint: file,
92
96
  siteName: desiredSiteName !== null && desiredSiteName !== void 0 ? desiredSiteName : (0, random_hash_1.randomHash)(),
@@ -119,7 +123,7 @@ const sitesCreateSubcommand = async (args, remotionRoot, logLevel) => {
119
123
  },
120
124
  region: (0, get_aws_region_1.getAwsRegion)(),
121
125
  privacy: (_d = args_1.parsedLambdaCli.privacy) !== null && _d !== void 0 ? _d : 'public',
122
- gitSource: null,
126
+ gitSource,
123
127
  indent: false,
124
128
  logLevel,
125
129
  throwIfSiteExists,
@@ -36,8 +36,8 @@ const findFunctionName = async (logLevel) => {
36
36
  }
37
37
  log_1.Log.info(logOptions, 'Prefer using one of those functions by passing their name to `--function-name` or removing it entirely.');
38
38
  }
39
- return cliFlag;
40
39
  }
40
+ return cliFlag;
41
41
  }
42
42
  if (lambdasWithMatchingVersion.length === 0) {
43
43
  log_1.Log.error({ indent: false, logLevel }, `No Lambda functions with version ${version_1.VERSION} found in your account.`);
@@ -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
  };
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,15 @@
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.initalizedMetadataKey)(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;
@@ -0,0 +1,9 @@
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>;
@@ -0,0 +1,25 @@
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;
@@ -0,0 +1,10 @@
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, hasAudio, hasVideo, }: {
4
+ contents: _Object[];
5
+ output: string | null;
6
+ chunkCount: number;
7
+ renderId: string;
8
+ hasAudio: boolean;
9
+ hasVideo: boolean;
10
+ }) => null | CleanupInfo;
@@ -0,0 +1,35 @@
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, hasAudio, hasVideo, }) => {
6
+ if (output === null) {
7
+ return null;
8
+ }
9
+ const filesToDelete = (0, get_files_to_delete_1.getFilesToDelete)({
10
+ chunkCount,
11
+ renderId,
12
+ hasAudio,
13
+ hasVideo,
14
+ });
15
+ const filesStillThere = contents.filter((c) => {
16
+ return filesToDelete.find((f) => {
17
+ var _a;
18
+ if (f.type === 'exact') {
19
+ return f.name === c.Key;
20
+ }
21
+ if (f.type === 'prefix') {
22
+ return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith(f.name);
23
+ }
24
+ throw new Error('Unexpected in getCleanupProgress');
25
+ });
26
+ });
27
+ const filesDeleted = Math.max(0, filesToDelete.length - filesStillThere.length);
28
+ return {
29
+ minFilesToDelete: filesToDelete.length,
30
+ filesDeleted,
31
+ // We don't know. Only if post render data is saved, we know the timing
32
+ doneIn: null,
33
+ };
34
+ };
35
+ exports.getCleanupProgress = getCleanupProgress;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1 @@
1
+ export declare const getEncodingProgressStepSize: (totalFrames: number) => number;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,10 @@
1
+ export type CleanupJob = {
2
+ name: string;
3
+ type: 'exact' | 'prefix';
4
+ };
5
+ export declare const getFilesToDelete: ({ chunkCount, renderId, hasVideo, hasAudio, }: {
6
+ chunkCount: number;
7
+ renderId: string;
8
+ hasVideo: boolean;
9
+ hasAudio: boolean;
10
+ }) => CleanupJob[];
@@ -0,0 +1,52 @@
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, hasVideo, hasAudio, }) => {
6
+ const videoChunks = hasVideo
7
+ ? new Array(chunkCount).fill(true).map((_x, i) => (0, constants_1.chunkKeyForIndex)({
8
+ index: i,
9
+ renderId,
10
+ type: 'video',
11
+ }))
12
+ : [];
13
+ const audioChunks = hasAudio
14
+ ? new Array(chunkCount).fill(true).map((_x, i) => (0, constants_1.chunkKeyForIndex)({
15
+ index: i,
16
+ renderId,
17
+ type: 'audio',
18
+ }))
19
+ : [];
20
+ const lambdaTimings = new Array(chunkCount)
21
+ .fill(true)
22
+ .map((_x, i) => (0, constants_1.lambdaTimingsPrefixForChunk)(renderId, i));
23
+ return [
24
+ {
25
+ name: (0, constants_1.lambdaChunkInitializedPrefix)(renderId),
26
+ type: 'prefix',
27
+ },
28
+ ...videoChunks.map((i) => {
29
+ return {
30
+ name: i,
31
+ type: 'exact',
32
+ };
33
+ }),
34
+ ...audioChunks.map((i) => {
35
+ return {
36
+ name: i,
37
+ type: 'exact',
38
+ };
39
+ }),
40
+ ...lambdaTimings.map((i) => {
41
+ return {
42
+ name: i,
43
+ type: 'prefix',
44
+ };
45
+ }),
46
+ {
47
+ name: (0, constants_1.encodingProgressKey)(renderId),
48
+ type: 'exact',
49
+ },
50
+ ];
51
+ };
52
+ exports.getFilesToDelete = getFilesToDelete;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1 @@
1
+ export declare function getFolderSizeRecursively(folder: string): number;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,8 @@
1
+ import type { _Object } from '@aws-sdk/client-s3';
2
+ export type LambdaInvokeStats = {
3
+ lambdasInvoked: number;
4
+ };
5
+ export declare const getLambdasInvokedStats: ({ contents, renderId, }: {
6
+ contents: _Object[];
7
+ renderId: string;
8
+ }) => LambdaInvokeStats;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLambdasInvokedStats = void 0;
4
+ const constants_1 = require("../../shared/constants");
5
+ const parse_lambda_initialized_key_1 = require("../../shared/parse-lambda-initialized-key");
6
+ const getLambdasInvokedStats = ({ contents, renderId, }) => {
7
+ const lambdasInvoked = contents
8
+ .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
9
+ .filter((c) => (0, parse_lambda_initialized_key_1.parseLambdaInitializedKey)(c.Key).attempt === 1);
10
+ return {
11
+ lambdasInvoked: lambdasInvoked.length,
12
+ };
13
+ };
14
+ exports.getLambdasInvokedStats = getLambdasInvokedStats;
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,8 @@
1
+ import type { _Object } from '@aws-sdk/client-s3';
2
+ export declare const getRenderedFramesProgress: ({ contents, renderId, framesPerLambda, everyNthFrame, frameRange, }: {
3
+ contents: _Object[];
4
+ renderId: string;
5
+ framesPerLambda: number;
6
+ frameRange: [number, number];
7
+ everyNthFrame: number;
8
+ }) => number;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRenderedFramesProgress = void 0;
4
+ const chunk_progress_1 = require("../../shared/chunk-progress");
5
+ const constants_1 = require("../../shared/constants");
6
+ const parse_chunk_key_1 = require("../../shared/parse-chunk-key");
7
+ const parse_lambda_initialized_key_1 = require("../../shared/parse-lambda-initialized-key");
8
+ const plan_frame_ranges_1 = require("../chunk-optimization/plan-frame-ranges");
9
+ const getRenderedFramesProgress = ({ contents, renderId, framesPerLambda, everyNthFrame, frameRange, }) => {
10
+ const chunkProgress = {};
11
+ const { chunks } = (0, plan_frame_ranges_1.planFrameRanges)({
12
+ everyNthFrame,
13
+ frameRange,
14
+ framesPerLambda,
15
+ });
16
+ // Sort, so only the latest attempt is used
17
+ const sortedChunks = contents
18
+ .filter((c) => {
19
+ return c.Key.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId));
20
+ })
21
+ .sort((a, b) => {
22
+ return a.Key.localeCompare(b.Key);
23
+ });
24
+ for (const chunk of sortedChunks) {
25
+ const key = (0, parse_lambda_initialized_key_1.parseLambdaInitializedKey)(chunk.Key);
26
+ chunkProgress[key.chunk] = (0, chunk_progress_1.getProgressOfChunk)(chunk.ETag);
27
+ }
28
+ for (const chunk of contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); })) {
29
+ const parsed = (0, parse_chunk_key_1.parseLambdaChunkKey)(chunk.Key);
30
+ const frameRangeInChunk = chunks[parsed.chunk];
31
+ chunkProgress[parsed.chunk] =
32
+ frameRangeInChunk[1] - frameRangeInChunk[0] + 1;
33
+ }
34
+ const framesRendered = Object.values(chunkProgress).reduce((a, b) => a + b, 0);
35
+ return framesRendered;
36
+ };
37
+ exports.getRenderedFramesProgress = getRenderedFramesProgress;
@@ -0,0 +1,5 @@
1
+ import type { RenderMetadata } from '../../defaults';
2
+ export declare const getTimeToFinish: ({ renderMetadata, lastModified, }: {
3
+ renderMetadata: RenderMetadata | null;
4
+ lastModified: number | null;
5
+ }) => number | null;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTimeToFinish = void 0;
4
+ const getTimeToFinish = ({ renderMetadata, lastModified, }) => {
5
+ if (!lastModified) {
6
+ return null;
7
+ }
8
+ if (!renderMetadata) {
9
+ return null;
10
+ }
11
+ return Math.max(0, lastModified - renderMetadata.startedDate);
12
+ };
13
+ exports.getTimeToFinish = getTimeToFinish;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import type { ResponseStream } from './streamify-response';
3
+ declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
4
+ type: z.ZodLiteral<"render-id-determined">;
5
+ renderId: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ type: "render-id-determined";
8
+ renderId: string;
9
+ }, {
10
+ type: "render-id-determined";
11
+ renderId: string;
12
+ }>]>;
13
+ export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
14
+ export declare const isStreamingPayload: (str: string) => false | {
15
+ type: "render-id-determined";
16
+ renderId: string;
17
+ };
18
+ export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
19
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendProgressEvent = exports.isStreamingPayload = void 0;
4
+ const zod_1 = require("zod");
5
+ const streamingPayloadSchema = zod_1.z.discriminatedUnion('type', [
6
+ zod_1.z.object({
7
+ type: zod_1.z.literal('render-id-determined'),
8
+ renderId: zod_1.z.string(),
9
+ }),
10
+ ]);
11
+ const isStreamingPayload = (str) => {
12
+ try {
13
+ const parsed = JSON.parse(str);
14
+ return streamingPayloadSchema.parse(parsed);
15
+ }
16
+ catch (_a) {
17
+ return false;
18
+ }
19
+ };
20
+ exports.isStreamingPayload = isStreamingPayload;
21
+ const sendProgressEvent = (responseStream, payload) => {
22
+ const stringified = JSON.stringify(payload);
23
+ responseStream.write(stringified);
24
+ };
25
+ exports.sendProgressEvent = sendProgressEvent;
@@ -0,0 +1,9 @@
1
+ import type { AwsRegion } from '../../pricing/aws-regions';
2
+ import type { PostRenderData } from '../../shared/constants';
3
+ export declare const writePostRenderData: ({ bucketName, renderId, postRenderData, expectedBucketOwner, region, }: {
4
+ bucketName: string;
5
+ renderId: string;
6
+ postRenderData: PostRenderData;
7
+ expectedBucketOwner: string;
8
+ region: AwsRegion;
9
+ }) => Promise<void>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writePostRenderData = void 0;
4
+ const constants_1 = require("../../shared/constants");
5
+ const io_1 = require("./io");
6
+ const writePostRenderData = async ({ bucketName, renderId, postRenderData, expectedBucketOwner, region, }) => {
7
+ await (0, io_1.lambdaWriteFile)({
8
+ bucketName,
9
+ key: (0, constants_1.postRenderDataKey)(renderId),
10
+ privacy: 'private',
11
+ body: JSON.stringify(postRenderData),
12
+ expectedBucketOwner,
13
+ region,
14
+ downloadBehavior: null,
15
+ customCredentials: null,
16
+ });
17
+ };
18
+ exports.writePostRenderData = writePostRenderData;