@remotion/lambda 4.0.0-alpha.217 → 4.0.0-alpha10
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/admin/bundle-lambda.js +12 -12
- package/dist/admin/generate-etag-list.js +4 -4
- package/dist/admin/make-layer-public.js +4 -5
- package/dist/api/create-bucket.js +34 -1
- package/dist/api/create-function.js +4 -4
- package/dist/api/delete-function.d.ts +2 -2
- package/dist/api/delete-function.js +2 -2
- package/dist/api/delete-site.d.ts +4 -4
- package/dist/api/delete-site.js +4 -4
- package/dist/api/deploy-function.d.ts +8 -7
- package/dist/api/deploy-function.js +26 -25
- package/dist/api/deploy-site.d.ts +2 -1
- package/dist/api/deploy-site.js +7 -4
- package/dist/api/download-media.d.ts +1 -1
- package/dist/api/download-media.js +3 -3
- package/dist/api/get-compositions-on-lambda.d.ts +1 -1
- package/dist/api/get-functions.d.ts +3 -3
- package/dist/api/get-functions.js +7 -7
- package/dist/api/get-or-create-bucket.d.ts +2 -2
- package/dist/api/get-or-create-bucket.js +6 -6
- package/dist/api/get-render-progress.d.ts +1 -1
- package/dist/api/get-render-progress.js +5 -10
- package/dist/api/get-sites.d.ts +0 -1
- package/dist/api/iam-validation/user-permissions.js +2 -0
- package/dist/api/make-lambda-payload.d.ts +5 -0
- package/dist/api/make-lambda-payload.js +77 -0
- package/dist/api/render-media-on-lambda.d.ts +3 -3
- package/dist/api/render-media-on-lambda.js +4 -60
- package/dist/api/render-still-on-lambda.d.ts +1 -1
- package/dist/api/speculate-function-name.d.ts +3 -3
- package/dist/api/speculate-function-name.js +3 -3
- package/dist/api/upload-dir.js +7 -7
- package/dist/cli/commands/functions/deploy.js +6 -3
- package/dist/cli/commands/functions/ls.js +8 -3
- package/dist/cli/commands/functions/rm.js +12 -5
- package/dist/cli/commands/functions/rmall.js +12 -6
- package/dist/cli/commands/quotas/increase.js +2 -2
- package/dist/cli/commands/render/render.js +32 -14
- package/dist/cli/commands/sites/create.js +5 -1
- package/dist/cli/commands/sites/index.js +3 -0
- package/dist/cli/commands/still.js +24 -9
- package/dist/cli/help.js +4 -0
- package/dist/cli/index.js +3 -3
- package/dist/cli/log.d.ts +2 -0
- package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +1 -4
- package/dist/functions/helpers/clean-tmpdir.js +7 -7
- package/dist/functions/helpers/concat-videos.js +7 -7
- package/dist/functions/helpers/get-browser-instance.js +1 -0
- package/dist/functions/helpers/get-chromium-executable-path.js +7 -6
- package/dist/functions/helpers/get-current-region.d.ts +1 -1
- package/dist/functions/helpers/get-files-in-folder.js +5 -5
- package/dist/functions/helpers/io.d.ts +8 -2
- package/dist/functions/helpers/io.js +22 -2
- package/dist/functions/helpers/streamify-response.d.ts +16 -0
- package/dist/functions/helpers/streamify-response.js +67 -0
- package/dist/functions/helpers/validate-composition.d.ts +4 -3
- package/dist/functions/helpers/validate-composition.js +9 -12
- package/dist/functions/index.d.ts +1 -18
- package/dist/functions/index.js +31 -10
- package/dist/functions/launch.js +12 -13
- package/dist/functions/renderer.js +6 -6
- package/dist/functions/still.js +8 -7
- package/dist/index.d.ts +1 -1
- package/dist/internals.d.ts +2 -0
- package/dist/internals.js +3 -0
- package/dist/shared/aws-clients.js +2 -2
- package/dist/shared/call-lambda.js +27 -2
- package/dist/shared/constants.d.ts +47 -45
- package/dist/shared/deserialize-input-props.d.ts +1 -1
- package/dist/shared/function-zip-path.js +2 -2
- package/dist/shared/get-etag.js +4 -4
- package/dist/shared/hosted-layers.js +35 -119
- package/dist/shared/invoke-webhook.d.ts +3 -1
- package/dist/shared/invoke-webhook.js +4 -4
- package/dist/shared/make-s3-key.js +2 -2
- package/dist/shared/make-s3-url.js +2 -2
- package/dist/shared/read-dir.js +2 -2
- package/dist/shared/return-values.d.ts +5 -0
- package/dist/shared/serialize-input-props.d.ts +1 -1
- package/dist/shared/serialize-input-props.js +1 -1
- package/dist/shared/validate-privacy.d.ts +1 -1
- package/dist/shared/validate-privacy.js +5 -2
- package/package.json +89 -90
- package/remotionlambda-arm64.zip +0 -0
- package/remotionlambda-x64.zip +0 -0
- package/remotionlambda.zip +0 -0
|
@@ -26,27 +26,42 @@ const stillCommand = async (args, remotionRoot) => {
|
|
|
26
26
|
log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.STILL_COMMAND} <serve-url> <composition-id> [output-location]`);
|
|
27
27
|
(0, quit_1.quit)(1);
|
|
28
28
|
}
|
|
29
|
+
const { chromiumOptions, envVariables, inputProps, logLevel, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, browserExecutable, port, } = await cli_1.CliInternals.getCliOptions({
|
|
30
|
+
type: 'still',
|
|
31
|
+
isLambda: true,
|
|
32
|
+
remotionRoot,
|
|
33
|
+
});
|
|
29
34
|
const region = (0, get_aws_region_1.getAwsRegion)();
|
|
30
35
|
let composition = args[1];
|
|
31
36
|
if (!composition) {
|
|
32
37
|
log_1.Log.info('No compositions passed. Fetching compositions...');
|
|
33
38
|
(0, validate_serveurl_1.validateServeUrl)(serveUrl);
|
|
34
|
-
const
|
|
35
|
-
|
|
39
|
+
const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
|
|
40
|
+
args,
|
|
41
|
+
compositionIdFromUi: null,
|
|
42
|
+
indent: false,
|
|
43
|
+
serveUrlOrWebpackUrl: serveUrl,
|
|
44
|
+
verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
|
|
45
|
+
browserExecutable,
|
|
46
|
+
chromiumOptions,
|
|
47
|
+
downloadMap: undefined,
|
|
48
|
+
envVariables,
|
|
49
|
+
inputProps,
|
|
50
|
+
port,
|
|
51
|
+
puppeteerInstance: undefined,
|
|
52
|
+
timeoutInMilliseconds: puppeteerTimeout,
|
|
53
|
+
height,
|
|
54
|
+
width,
|
|
55
|
+
});
|
|
36
56
|
composition = compositionId;
|
|
37
57
|
}
|
|
38
58
|
const downloadName = (_a = args[2]) !== null && _a !== void 0 ? _a : null;
|
|
39
59
|
const outName = args_1.parsedLambdaCli['out-name'];
|
|
40
|
-
const { chromiumOptions, envVariables, inputProps, logLevel, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, } = await cli_1.CliInternals.getCliOptions({
|
|
41
|
-
type: 'still',
|
|
42
|
-
isLambda: true,
|
|
43
|
-
remotionRoot,
|
|
44
|
-
});
|
|
45
60
|
const functionName = await (0, find_function_name_1.findFunctionName)();
|
|
46
61
|
const maxRetries = (_b = args_1.parsedLambdaCli['max-retries']) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_MAX_RETRIES;
|
|
47
62
|
(0, validate_retries_1.validateMaxRetries)(maxRetries);
|
|
48
63
|
const privacy = (_c = args_1.parsedLambdaCli.privacy) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_OUTPUT_PRIVACY;
|
|
49
|
-
(0, validate_privacy_1.validatePrivacy)(privacy);
|
|
64
|
+
(0, validate_privacy_1.validatePrivacy)(privacy, true);
|
|
50
65
|
const { format: imageFormat, source: imageFormatReason } = cli_1.CliInternals.determineFinalStillImageFormat({
|
|
51
66
|
downloadName,
|
|
52
67
|
outName: outName !== null && outName !== void 0 ? outName : null,
|
|
@@ -104,7 +119,7 @@ const stillCommand = async (args, remotionRoot) => {
|
|
|
104
119
|
stack: err.stack,
|
|
105
120
|
stackFrame: frames,
|
|
106
121
|
});
|
|
107
|
-
await cli_1.CliInternals.handleCommonError(errorWithStackFrame);
|
|
122
|
+
await cli_1.CliInternals.handleCommonError(errorWithStackFrame, renderer_1.RenderInternals.getLogLevel());
|
|
108
123
|
(0, quit_1.quit)(1);
|
|
109
124
|
}
|
|
110
125
|
};
|
package/dist/cli/help.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printHelp = void 0;
|
|
4
4
|
const cli_1 = require("@remotion/cli");
|
|
5
5
|
const constants_1 = require("../shared/constants");
|
|
6
|
+
const compositions_1 = require("./commands/compositions");
|
|
6
7
|
const functions_1 = require("./commands/functions");
|
|
7
8
|
const policies_1 = require("./commands/policies/policies");
|
|
8
9
|
const quotas_1 = require("./commands/quotas");
|
|
@@ -28,6 +29,9 @@ const printHelp = () => {
|
|
|
28
29
|
log_1.Log.info(`${constants_1.BINARY_NAME} ${sites_1.SITES_COMMAND}`);
|
|
29
30
|
log_1.Log.info(cli_1.CliInternals.chalk.gray('Deploy and manage Remotion projects.'));
|
|
30
31
|
log_1.Log.info();
|
|
32
|
+
log_1.Log.info(`${constants_1.BINARY_NAME} ${compositions_1.COMPOSITIONS_COMMAND}`);
|
|
33
|
+
log_1.Log.info(cli_1.CliInternals.chalk.gray('Print list of composition IDs from a serve URL.'));
|
|
34
|
+
log_1.Log.info();
|
|
31
35
|
log_1.Log.info(`${constants_1.BINARY_NAME} ${policies_1.POLICIES_COMMAND}`);
|
|
32
36
|
log_1.Log.info(cli_1.CliInternals.chalk.gray('View and validate AWS policy files.'));
|
|
33
37
|
log_1.Log.info();
|
package/dist/cli/index.js
CHANGED
|
@@ -30,9 +30,9 @@ const requiresCredentials = (args) => {
|
|
|
30
30
|
if (args[1] === role_1.ROLE_SUBCOMMAND) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
if (args[0] === regions_1.REGIONS_COMMAND) {
|
|
35
|
+
return false;
|
|
36
36
|
}
|
|
37
37
|
return true;
|
|
38
38
|
};
|
package/dist/cli/log.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare const Log: {
|
|
|
3
3
|
verboseAdvanced: (options: {
|
|
4
4
|
indent: boolean;
|
|
5
5
|
logLevel: "verbose" | "info" | "warn" | "error";
|
|
6
|
+
} & {
|
|
7
|
+
tag?: string | undefined;
|
|
6
8
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
7
9
|
info: (message?: any, ...optionalParams: any[]) => void;
|
|
8
10
|
infoAdvanced: (options: {
|
|
@@ -4,21 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.deleteTmpDir = exports.deletedFilesSize = exports.deletedFiles = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
9
|
exports.deletedFiles = [];
|
|
10
10
|
exports.deletedFilesSize = 0;
|
|
11
11
|
const deleteAllFilesInAFolderRecursively = (path) => {
|
|
12
|
-
const files =
|
|
12
|
+
const files = node_fs_1.default.readdirSync(path);
|
|
13
13
|
files.forEach((file) => {
|
|
14
|
-
const filePath = (0,
|
|
14
|
+
const filePath = (0, node_path_1.join)(path, file);
|
|
15
15
|
try {
|
|
16
|
-
const stat =
|
|
16
|
+
const stat = node_fs_1.default.statSync(filePath);
|
|
17
17
|
if (stat.isDirectory()) {
|
|
18
18
|
deleteAllFilesInAFolderRecursively(filePath);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
21
|
+
node_fs_1.default.unlinkSync(filePath);
|
|
22
22
|
exports.deletedFilesSize += stat.size;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -29,7 +29,7 @@ const deleteAllFilesInAFolderRecursively = (path) => {
|
|
|
29
29
|
exports.deletedFiles.push(filePath);
|
|
30
30
|
});
|
|
31
31
|
if (path !== '/tmp') {
|
|
32
|
-
|
|
32
|
+
node_fs_1.default.rmSync(path, { recursive: true, force: true });
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
const deleteTmpDir = () => {
|
|
@@ -25,14 +25,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.concatVideosS3 = exports.getAllFilesS3 = void 0;
|
|
27
27
|
const renderer_1 = require("@remotion/renderer");
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const node_fs_1 = __importStar(require("node:fs"));
|
|
29
|
+
const node_path_1 = __importStar(require("node:path"));
|
|
30
30
|
const constants_1 = require("../../shared/constants");
|
|
31
31
|
const inspect_errors_1 = require("./inspect-errors");
|
|
32
32
|
const io_1 = require("./io");
|
|
33
33
|
const timer_1 = require("./timer");
|
|
34
34
|
const getChunkDownloadOutputLocation = ({ outdir, file, }) => {
|
|
35
|
-
return
|
|
35
|
+
return node_path_1.default.join(outdir, node_path_1.default.basename(file));
|
|
36
36
|
};
|
|
37
37
|
const downloadS3File = async ({ bucket, key, outdir, region, expectedBucketOwner, }) => {
|
|
38
38
|
const Body = await (0, io_1.lambdaReadFile)({
|
|
@@ -43,10 +43,10 @@ const downloadS3File = async ({ bucket, key, outdir, region, expectedBucketOwner
|
|
|
43
43
|
});
|
|
44
44
|
const outpath = getChunkDownloadOutputLocation({ outdir, file: key });
|
|
45
45
|
if (Buffer.isBuffer(Body)) {
|
|
46
|
-
return
|
|
46
|
+
return node_fs_1.promises.writeFile(outpath, Body);
|
|
47
47
|
}
|
|
48
48
|
return new Promise((resolve, reject) => {
|
|
49
|
-
Body.pipe((0,
|
|
49
|
+
Body.pipe((0, node_fs_1.createWriteStream)(outpath))
|
|
50
50
|
.on('error', (err) => reject(err))
|
|
51
51
|
.on('close', () => resolve());
|
|
52
52
|
});
|
|
@@ -129,7 +129,7 @@ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expect
|
|
|
129
129
|
};
|
|
130
130
|
exports.getAllFilesS3 = getAllFilesS3;
|
|
131
131
|
const concatVideosS3 = async ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, files, outdir, audioCodec, }) => {
|
|
132
|
-
const outfile = (0,
|
|
132
|
+
const outfile = (0, node_path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_CONCATED_TOKEN), 'concat.' + renderer_1.RenderInternals.getFileExtensionFromCodec(codec, audioCodec));
|
|
133
133
|
const combine = (0, timer_1.timer)('Combine videos');
|
|
134
134
|
const filelistDir = renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_FILELIST_TOKEN);
|
|
135
135
|
await renderer_1.RenderInternals.combineVideos({
|
|
@@ -144,7 +144,7 @@ const concatVideosS3 = async ({ onProgress, numberOfFrames, codec, fps, numberOf
|
|
|
144
144
|
audioCodec,
|
|
145
145
|
});
|
|
146
146
|
combine.end();
|
|
147
|
-
const cleanupChunksProm =
|
|
147
|
+
const cleanupChunksProm = node_fs_1.default.promises.rm(outdir, {
|
|
148
148
|
recursive: true,
|
|
149
149
|
});
|
|
150
150
|
return { outfile, cleanupChunksProm };
|
|
@@ -42,6 +42,7 @@ const getBrowserInstance = async (shouldDumpIo, chromiumOptions) => {
|
|
|
42
42
|
browserExecutable: execPath,
|
|
43
43
|
shouldDumpIo,
|
|
44
44
|
chromiumOptions: actualChromiumOptions,
|
|
45
|
+
indent: false,
|
|
45
46
|
});
|
|
46
47
|
_browserInstance.on('disconnected', () => {
|
|
47
48
|
console.log('Browser disconnected / crashed');
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.executablePath = void 0;
|
|
5
|
-
if (/^AWS_Lambda_nodejs(?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
process.env.
|
|
5
|
+
if (/^AWS_Lambda_nodejs(?:18)[.]x$/.test((_a = process.env.AWS_EXECUTION_ENV) !== null && _a !== void 0 ? _a : '') ===
|
|
6
|
+
true) {
|
|
7
|
+
process.env.FONTCONFIG_PATH = '/opt';
|
|
8
|
+
process.env.FONTCONFIG_FILE = '/opt/fonts.conf';
|
|
9
|
+
process.env.READ_ONLY_FS = '1';
|
|
10
|
+
process.env.COMPOSITOR_PATH = './compositor';
|
|
11
|
+
process.env.NO_COLOR = '1';
|
|
11
12
|
}
|
|
12
13
|
const executablePath = () => {
|
|
13
14
|
return '/opt/bin/chromium';
|
|
@@ -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" | "
|
|
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";
|
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getFolderFiles = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
function getFolderFiles(folder) {
|
|
10
|
-
const files =
|
|
10
|
+
const files = node_fs_1.default.readdirSync(folder);
|
|
11
11
|
const paths = [];
|
|
12
12
|
files.forEach((file) => {
|
|
13
|
-
const full =
|
|
13
|
+
const full = node_path_1.default.join(folder, file);
|
|
14
14
|
try {
|
|
15
|
-
const stat =
|
|
15
|
+
const stat = node_fs_1.default.statSync(full);
|
|
16
16
|
if (stat.isDirectory()) {
|
|
17
17
|
paths.push(...getFolderFiles(full));
|
|
18
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { ReadStream } from 'fs';
|
|
3
|
+
import type { ReadStream } from 'node:fs';
|
|
3
4
|
import type { Readable } from 'stream';
|
|
4
5
|
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
5
6
|
import type { CustomCredentials } from '../../shared/aws-clients';
|
|
@@ -20,7 +21,7 @@ export declare const lambdaDeleteFile: ({ bucketName, key, region, customCredent
|
|
|
20
21
|
key: string;
|
|
21
22
|
customCredentials: CustomCredentials | null;
|
|
22
23
|
}) => Promise<void>;
|
|
23
|
-
|
|
24
|
+
declare type LambdaWriteFileInput = {
|
|
24
25
|
bucketName: string;
|
|
25
26
|
key: string;
|
|
26
27
|
body: ReadStream | string;
|
|
@@ -29,6 +30,10 @@ export declare const lambdaWriteFile: ({ bucketName, key, body, region, privacy,
|
|
|
29
30
|
expectedBucketOwner: string | null;
|
|
30
31
|
downloadBehavior: DownloadBehavior | null;
|
|
31
32
|
customCredentials: CustomCredentials | null;
|
|
33
|
+
};
|
|
34
|
+
export declare const tryLambdaWriteFile: ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }: LambdaWriteFileInput) => Promise<void>;
|
|
35
|
+
export declare const lambdaWriteFile: (params: LambdaWriteFileInput & {
|
|
36
|
+
retries?: number;
|
|
32
37
|
}) => Promise<void>;
|
|
33
38
|
export declare const lambdaReadFile: ({ bucketName, key, region, expectedBucketOwner, }: {
|
|
34
39
|
bucketName: string;
|
|
@@ -44,3 +49,4 @@ export declare const lambdaHeadCommand: ({ bucketName, key, region, }: {
|
|
|
44
49
|
LastModified?: Date | undefined;
|
|
45
50
|
ContentLength?: number | undefined;
|
|
46
51
|
}>;
|
|
52
|
+
export {};
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.lambdaHeadCommand = exports.lambdaReadFile = exports.lambdaWriteFile = exports.lambdaDeleteFile = exports.lambdaLs = void 0;
|
|
6
|
+
exports.lambdaHeadCommand = exports.lambdaReadFile = exports.lambdaWriteFile = exports.tryLambdaWriteFile = exports.lambdaDeleteFile = exports.lambdaLs = void 0;
|
|
7
7
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
8
8
|
const mime_types_1 = __importDefault(require("mime-types"));
|
|
9
9
|
const aws_clients_1 = require("../../shared/aws-clients");
|
|
@@ -54,7 +54,7 @@ const lambdaDeleteFile = async ({ bucketName, key, region, customCredentials, })
|
|
|
54
54
|
}));
|
|
55
55
|
};
|
|
56
56
|
exports.lambdaDeleteFile = lambdaDeleteFile;
|
|
57
|
-
const
|
|
57
|
+
const tryLambdaWriteFile = async ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }) => {
|
|
58
58
|
await (0, aws_clients_1.getS3Client)(region, customCredentials).send(new client_s3_1.PutObjectCommand({
|
|
59
59
|
Bucket: bucketName,
|
|
60
60
|
Key: key,
|
|
@@ -71,6 +71,26 @@ const lambdaWriteFile = async ({ bucketName, key, body, region, privacy, expecte
|
|
|
71
71
|
ContentDisposition: (0, content_disposition_header_1.getContentDispositionHeader)(downloadBehavior),
|
|
72
72
|
}));
|
|
73
73
|
};
|
|
74
|
+
exports.tryLambdaWriteFile = tryLambdaWriteFile;
|
|
75
|
+
const lambdaWriteFile = async (params) => {
|
|
76
|
+
var _a;
|
|
77
|
+
const remainingRetries = (_a = params.retries) !== null && _a !== void 0 ? _a : 2;
|
|
78
|
+
try {
|
|
79
|
+
await (0, exports.tryLambdaWriteFile)(params);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (remainingRetries === 0) {
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
console.warn('Failed to write file to Lambda:');
|
|
86
|
+
console.warn(err);
|
|
87
|
+
console.warn(`Retrying (${remainingRetries} retries remaining)...`);
|
|
88
|
+
return (0, exports.lambdaWriteFile)({
|
|
89
|
+
...params,
|
|
90
|
+
retries: (remainingRetries !== null && remainingRetries !== void 0 ? remainingRetries : 0) - 1,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
74
94
|
exports.lambdaWriteFile = lambdaWriteFile;
|
|
75
95
|
const lambdaReadFile = async ({ bucketName, key, region, expectedBucketOwner, }) => {
|
|
76
96
|
const { Body } = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.GetObjectCommand({
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Stream } from 'stream';
|
|
3
|
+
export declare class ResponseStream extends Stream.Writable {
|
|
4
|
+
private response;
|
|
5
|
+
_contentType?: string;
|
|
6
|
+
_isBase64Encoded?: boolean;
|
|
7
|
+
constructor();
|
|
8
|
+
_write(chunk: string, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
9
|
+
getBufferedData(): Buffer;
|
|
10
|
+
setContentType(contentType: string): void;
|
|
11
|
+
setIsBase64Encoded(isBase64Encoded: boolean): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const HANDLER_STREAMING: unique symbol;
|
|
14
|
+
export declare const STREAM_RESPONSE = "response";
|
|
15
|
+
export declare function isInAWS(handler: Function): boolean;
|
|
16
|
+
export declare function streamifyResponse(handler: Function): Function;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.streamifyResponse = exports.isInAWS = exports.STREAM_RESPONSE = exports.HANDLER_STREAMING = exports.ResponseStream = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
class ResponseStream extends stream_1.Stream.Writable {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.response = [];
|
|
9
|
+
}
|
|
10
|
+
_write(chunk, encoding, callback) {
|
|
11
|
+
this.response.push(Buffer.from(chunk, encoding));
|
|
12
|
+
callback();
|
|
13
|
+
}
|
|
14
|
+
getBufferedData() {
|
|
15
|
+
return Buffer.concat(this.response);
|
|
16
|
+
}
|
|
17
|
+
setContentType(contentType) {
|
|
18
|
+
this._contentType = contentType;
|
|
19
|
+
}
|
|
20
|
+
setIsBase64Encoded(isBase64Encoded) {
|
|
21
|
+
this._isBase64Encoded = isBase64Encoded;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ResponseStream = ResponseStream;
|
|
25
|
+
exports.HANDLER_STREAMING = Symbol.for('aws.lambda.runtime.handler.streaming');
|
|
26
|
+
exports.STREAM_RESPONSE = 'response';
|
|
27
|
+
function isInAWS(handler) {
|
|
28
|
+
return (
|
|
29
|
+
// @ts-expect-error
|
|
30
|
+
handler[exports.HANDLER_STREAMING] !== undefined &&
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
handler[exports.HANDLER_STREAMING] === exports.STREAM_RESPONSE);
|
|
33
|
+
}
|
|
34
|
+
exports.isInAWS = isInAWS;
|
|
35
|
+
function streamifyResponse(handler) {
|
|
36
|
+
// Check for global awslambda
|
|
37
|
+
if (isInAWS(handler)) {
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
return awslambda.streamifyResponse(handler);
|
|
40
|
+
}
|
|
41
|
+
return new Proxy(handler, {
|
|
42
|
+
async apply(target, _, argList) {
|
|
43
|
+
const responseStream = patchArgs(argList);
|
|
44
|
+
await target(...argList);
|
|
45
|
+
return {
|
|
46
|
+
statusCode: 200,
|
|
47
|
+
headers: {
|
|
48
|
+
'content-type': responseStream._contentType || 'application/json',
|
|
49
|
+
},
|
|
50
|
+
...(responseStream._isBase64Encoded
|
|
51
|
+
? { isBase64Encoded: responseStream._isBase64Encoded }
|
|
52
|
+
: {}),
|
|
53
|
+
body: responseStream._isBase64Encoded
|
|
54
|
+
? responseStream.getBufferedData().toString('base64')
|
|
55
|
+
: responseStream.getBufferedData().toString(),
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.streamifyResponse = streamifyResponse;
|
|
61
|
+
function patchArgs(argList) {
|
|
62
|
+
if (!(argList[1] instanceof ResponseStream)) {
|
|
63
|
+
const responseStream = new ResponseStream();
|
|
64
|
+
argList.splice(1, 0, responseStream);
|
|
65
|
+
}
|
|
66
|
+
return argList[1];
|
|
67
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ChromiumOptions, DownloadMap, openBrowser } from '@remotion/renderer';
|
|
1
|
+
import type { ChromiumOptions, DownloadMap, LogLevel, openBrowser } from '@remotion/renderer';
|
|
2
2
|
import type { AnyCompMetadata } from 'remotion';
|
|
3
3
|
import type { Await } from '../../shared/await';
|
|
4
4
|
declare type ValidateCompositionOptions = {
|
|
5
5
|
serveUrl: string;
|
|
6
6
|
composition: string;
|
|
7
7
|
browserInstance: Await<ReturnType<typeof openBrowser>>;
|
|
8
|
-
inputProps: unknown
|
|
8
|
+
inputProps: Record<string, unknown>;
|
|
9
9
|
envVariables: Record<string, string> | undefined;
|
|
10
10
|
timeoutInMilliseconds: number;
|
|
11
11
|
chromiumOptions: ChromiumOptions;
|
|
@@ -13,6 +13,7 @@ declare type ValidateCompositionOptions = {
|
|
|
13
13
|
downloadMap: DownloadMap;
|
|
14
14
|
forceHeight: number | null;
|
|
15
15
|
forceWidth: number | null;
|
|
16
|
+
logLevel: LogLevel;
|
|
16
17
|
};
|
|
17
|
-
export declare const validateComposition: ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, downloadMap, forceHeight, forceWidth, }: ValidateCompositionOptions) => Promise<AnyCompMetadata>;
|
|
18
|
+
export declare const validateComposition: ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, downloadMap, forceHeight, forceWidth, logLevel, }: ValidateCompositionOptions) => Promise<AnyCompMetadata>;
|
|
18
19
|
export {};
|
|
@@ -3,27 +3,24 @@ 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, downloadMap, forceHeight, forceWidth, }) => {
|
|
7
|
-
const
|
|
6
|
+
const validateComposition = async ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, downloadMap, forceHeight, forceWidth, logLevel, }) => {
|
|
7
|
+
const comp = await (0, renderer_1.selectComposition)({
|
|
8
|
+
id: composition,
|
|
8
9
|
puppeteerInstance: browserInstance,
|
|
9
|
-
inputProps
|
|
10
|
+
inputProps,
|
|
10
11
|
envVariables,
|
|
11
12
|
timeoutInMilliseconds,
|
|
12
13
|
chromiumOptions,
|
|
13
14
|
port,
|
|
14
15
|
downloadMap,
|
|
15
16
|
browserExecutable: (0, get_chromium_executable_path_1.executablePath)(),
|
|
17
|
+
serveUrl,
|
|
18
|
+
verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
|
|
16
19
|
});
|
|
17
|
-
const found = compositions.find((c) => c.id === composition);
|
|
18
|
-
if (!found) {
|
|
19
|
-
throw new Error(`No composition with ID ${composition} found. Available compositions: ${compositions
|
|
20
|
-
.map((c) => c.id)
|
|
21
|
-
.join(', ')}`);
|
|
22
|
-
}
|
|
23
20
|
return {
|
|
24
|
-
...
|
|
25
|
-
height: forceHeight !== null && forceHeight !== void 0 ? forceHeight :
|
|
26
|
-
width: forceWidth !== null && forceWidth !== void 0 ? forceWidth :
|
|
21
|
+
...comp,
|
|
22
|
+
height: forceHeight !== null && forceHeight !== void 0 ? forceHeight : comp.height,
|
|
23
|
+
width: forceWidth !== null && forceWidth !== void 0 ? forceWidth : comp.width,
|
|
27
24
|
};
|
|
28
25
|
};
|
|
29
26
|
exports.validateComposition = validateComposition;
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const handler: (params: LambdaPayload, context: {
|
|
3
|
-
invokedFunctionArn: string;
|
|
4
|
-
getRemainingTimeInMillis: () => number;
|
|
5
|
-
}) => Promise<void> | Promise<{
|
|
6
|
-
compositions: import("remotion").AnyCompMetadata[];
|
|
7
|
-
}> | Promise<{
|
|
8
|
-
version: string;
|
|
9
|
-
}> | Promise<{
|
|
10
|
-
bucketName: string;
|
|
11
|
-
renderId: string;
|
|
12
|
-
}> | Promise<import("../shared/constants").RenderProgress> | Promise<Promise<{
|
|
13
|
-
output: string;
|
|
14
|
-
size: number;
|
|
15
|
-
bucketName: string;
|
|
16
|
-
estimatedPrice: import("../shared/constants").CostsInfo;
|
|
17
|
-
renderId: string;
|
|
18
|
-
}>>;
|
|
1
|
+
export declare const handler: Function;
|
package/dist/functions/index.js
CHANGED
|
@@ -7,13 +7,14 @@ const compositions_1 = require("./compositions");
|
|
|
7
7
|
const clean_tmpdir_1 = require("./helpers/clean-tmpdir");
|
|
8
8
|
const is_warm_1 = require("./helpers/is-warm");
|
|
9
9
|
const print_cloudwatch_helper_1 = require("./helpers/print-cloudwatch-helper");
|
|
10
|
+
const streamify_response_1 = require("./helpers/streamify-response");
|
|
10
11
|
const info_1 = require("./info");
|
|
11
12
|
const launch_1 = require("./launch");
|
|
12
13
|
const progress_1 = require("./progress");
|
|
13
14
|
const renderer_2 = require("./renderer");
|
|
14
15
|
const start_1 = require("./start");
|
|
15
16
|
const still_1 = require("./still");
|
|
16
|
-
|
|
17
|
+
exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, responseStream, context) => {
|
|
17
18
|
process.env.__RESERVED_IS_INSIDE_REMOTION_LAMBDA = 'true';
|
|
18
19
|
const timeoutInMilliseconds = context.getRemainingTimeInMillis();
|
|
19
20
|
if (!context || !context.invokedFunctionArn) {
|
|
@@ -28,16 +29,24 @@ const handler = (params, context) => {
|
|
|
28
29
|
inputProps: JSON.stringify(params.inputProps),
|
|
29
30
|
isWarm,
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
+
const response = await (0, still_1.stillHandler)(params, {
|
|
32
33
|
expectedBucketOwner: currentUserId,
|
|
33
34
|
});
|
|
35
|
+
responseStream.write(JSON.stringify(response));
|
|
36
|
+
responseStream.end();
|
|
37
|
+
return;
|
|
34
38
|
}
|
|
35
39
|
if (params.type === constants_1.LambdaRoutines.start) {
|
|
36
40
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.start, {
|
|
37
41
|
inputProps: JSON.stringify(params.inputProps),
|
|
38
42
|
isWarm,
|
|
39
43
|
});
|
|
40
|
-
|
|
44
|
+
const response = await (0, start_1.startHandler)(params, {
|
|
45
|
+
expectedBucketOwner: currentUserId,
|
|
46
|
+
});
|
|
47
|
+
responseStream.write(JSON.stringify(response));
|
|
48
|
+
responseStream.end();
|
|
49
|
+
return;
|
|
41
50
|
}
|
|
42
51
|
if (params.type === constants_1.LambdaRoutines.launch) {
|
|
43
52
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.launch, {
|
|
@@ -45,20 +54,25 @@ const handler = (params, context) => {
|
|
|
45
54
|
inputProps: JSON.stringify(params.inputProps),
|
|
46
55
|
isWarm,
|
|
47
56
|
});
|
|
48
|
-
|
|
57
|
+
await (0, launch_1.launchHandler)(params, {
|
|
49
58
|
expectedBucketOwner: currentUserId,
|
|
50
59
|
getRemainingTimeInMillis: context.getRemainingTimeInMillis,
|
|
51
60
|
});
|
|
61
|
+
responseStream.end();
|
|
62
|
+
return;
|
|
52
63
|
}
|
|
53
64
|
if (params.type === constants_1.LambdaRoutines.status) {
|
|
54
65
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.status, {
|
|
55
66
|
renderId: params.renderId,
|
|
56
67
|
isWarm,
|
|
57
68
|
});
|
|
58
|
-
|
|
69
|
+
const response = await (0, progress_1.progressHandler)(params, {
|
|
59
70
|
expectedBucketOwner: currentUserId,
|
|
60
71
|
timeoutInMilliseconds,
|
|
61
72
|
});
|
|
73
|
+
responseStream.write(JSON.stringify(response));
|
|
74
|
+
responseStream.end();
|
|
75
|
+
return;
|
|
62
76
|
}
|
|
63
77
|
if (params.type === constants_1.LambdaRoutines.renderer) {
|
|
64
78
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.renderer, {
|
|
@@ -68,25 +82,32 @@ const handler = (params, context) => {
|
|
|
68
82
|
inputProps: JSON.stringify(params.inputProps),
|
|
69
83
|
isWarm,
|
|
70
84
|
});
|
|
71
|
-
|
|
85
|
+
await (0, renderer_2.rendererHandler)(params, {
|
|
72
86
|
expectedBucketOwner: currentUserId,
|
|
73
87
|
isWarm,
|
|
74
88
|
});
|
|
89
|
+
responseStream.end();
|
|
90
|
+
return;
|
|
75
91
|
}
|
|
76
92
|
if (params.type === constants_1.LambdaRoutines.info) {
|
|
77
93
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.info, {
|
|
78
94
|
isWarm,
|
|
79
95
|
});
|
|
80
|
-
|
|
96
|
+
const response = await (0, info_1.infoHandler)(params);
|
|
97
|
+
responseStream.write(JSON.stringify(response));
|
|
98
|
+
responseStream.end();
|
|
99
|
+
return;
|
|
81
100
|
}
|
|
82
101
|
if (params.type === constants_1.LambdaRoutines.compositions) {
|
|
83
102
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.compositions, {
|
|
84
103
|
isWarm,
|
|
85
104
|
});
|
|
86
|
-
|
|
105
|
+
const response = await (0, compositions_1.compositionsHandler)(params, {
|
|
87
106
|
expectedBucketOwner: currentUserId,
|
|
88
107
|
});
|
|
108
|
+
responseStream.write(JSON.stringify(response));
|
|
109
|
+
responseStream.end();
|
|
110
|
+
return;
|
|
89
111
|
}
|
|
90
112
|
throw new Error(constants_1.COMMAND_NOT_FOUND);
|
|
91
|
-
};
|
|
92
|
-
exports.handler = handler;
|
|
113
|
+
});
|