@remotion/cli 3.2.25 → 3.2.26-crf.18

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/benchmark.d.ts +1 -0
  2. package/dist/benchmark.js +180 -0
  3. package/dist/bundle.d.ts +1 -0
  4. package/dist/bundle.js +32 -0
  5. package/dist/compositions.js +2 -1
  6. package/dist/config/bundle-out-dir.d.ts +2 -0
  7. package/dist/config/bundle-out-dir.js +12 -0
  8. package/dist/config/get-public-path.d.ts +2 -0
  9. package/dist/config/get-public-path.js +12 -0
  10. package/dist/config/image-format.js +8 -1
  11. package/dist/config/log.d.ts +1 -1
  12. package/dist/determine-image-format.d.ts +11 -0
  13. package/dist/determine-image-format.js +48 -0
  14. package/dist/editor/components/Button.d.ts +4 -0
  15. package/dist/editor/components/Button.js +24 -0
  16. package/dist/editor/components/PreviewZoomControls.d.ts +2 -0
  17. package/dist/editor/components/PreviewZoomControls.js +49 -0
  18. package/dist/editor/helpers/normalize-wheel.d.ts +5 -0
  19. package/dist/editor/helpers/normalize-wheel.js +20 -0
  20. package/dist/event-source-events.d.ts +3 -0
  21. package/dist/event-source.js +1 -1
  22. package/dist/get-cli-options.d.ts +11 -3
  23. package/dist/get-cli-options.js +22 -28
  24. package/dist/get-env.d.ts +1 -1
  25. package/dist/get-env.js +58 -6
  26. package/dist/get-final-output-codec.d.ts +9 -5
  27. package/dist/get-final-output-codec.js +56 -56
  28. package/dist/get-render-media-options.d.ts +7 -0
  29. package/dist/get-render-media-options.js +44 -0
  30. package/dist/index.d.ts +21 -4
  31. package/dist/index.js +13 -3
  32. package/dist/initialize-cli.d.ts +1 -0
  33. package/dist/initialize-cli.js +22 -0
  34. package/dist/lambda-command.js +0 -2
  35. package/dist/parse-command-line.d.ts +1 -1
  36. package/dist/parse-command-line.js +1 -12
  37. package/dist/prepare-entry-point.d.ts +12 -0
  38. package/dist/prepare-entry-point.js +37 -0
  39. package/dist/preview-server/routes.d.ts +2 -1
  40. package/dist/preview-server/routes.js +4 -2
  41. package/dist/preview-server/start-server.d.ts +1 -1
  42. package/dist/preview-server/start-server.js +2 -1
  43. package/dist/preview.js +10 -4
  44. package/dist/print-help.js +6 -3
  45. package/dist/progress-bar.js +3 -1
  46. package/dist/render.js +22 -32
  47. package/dist/still.js +15 -25
  48. package/dist/validate-image-format.d.ts +2 -0
  49. package/dist/validate-image-format.js +15 -0
  50. package/dist/versions.js +1 -1
  51. package/dist/webpack-cache.d.ts +12 -0
  52. package/dist/webpack-cache.js +66 -0
  53. package/package.json +7 -7
package/dist/get-env.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const getEnvironmentVariables: () => Promise<Record<string, string>>;
1
+ export declare const getEnvironmentVariables: (onUpdate: (newProps: Record<string, string>) => void) => Promise<Record<string, string>>;
package/dist/get-env.js CHANGED
@@ -7,6 +7,7 @@ exports.getEnvironmentVariables = void 0;
7
7
  const dotenv_1 = __importDefault(require("dotenv"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
+ const chalk_1 = require("./chalk");
10
11
  const config_1 = require("./config");
11
12
  const find_closest_package_json_1 = require("./find-closest-package-json");
12
13
  const log_1 = require("./log");
@@ -19,9 +20,54 @@ function getProcessEnv() {
19
20
  }
20
21
  return env;
21
22
  }
22
- const getEnvForEnvFile = async (processEnv, envFile) => {
23
+ const watchEnvFile = ({ processEnv, envFile, onUpdate, existedBefore, }) => {
24
+ const listener = async () => {
25
+ try {
26
+ const file = await fs_1.default.promises.readFile(envFile, 'utf-8');
27
+ onUpdate({
28
+ ...processEnv,
29
+ ...dotenv_1.default.parse(file),
30
+ });
31
+ if (existedBefore) {
32
+ log_1.Log.info(chalk_1.chalk.blueBright(`Updated env file ${envFile}`));
33
+ }
34
+ else {
35
+ log_1.Log.info(chalk_1.chalk.blueBright(`Added env file ${envFile}`));
36
+ }
37
+ fs_1.default.unwatchFile(envFile, listener);
38
+ watchEnvFile({
39
+ envFile,
40
+ existedBefore: true,
41
+ onUpdate,
42
+ processEnv,
43
+ });
44
+ }
45
+ catch (err) {
46
+ // No error message if user did not have a .env file from the beginning
47
+ if (!existedBefore && !fs_1.default.existsSync(envFile)) {
48
+ return;
49
+ }
50
+ if (fs_1.default.existsSync(envFile) && existedBefore) {
51
+ log_1.Log.error(`${envFile} update failed with error ${err}`);
52
+ }
53
+ else {
54
+ log_1.Log.warn(`${envFile} was deleted.`);
55
+ fs_1.default.unwatchFile(envFile, listener);
56
+ watchEnvFile({
57
+ envFile,
58
+ existedBefore: false,
59
+ onUpdate,
60
+ processEnv,
61
+ });
62
+ }
63
+ }
64
+ };
65
+ fs_1.default.watchFile(envFile, { interval: 100 }, listener);
66
+ };
67
+ const getEnvForEnvFile = async (processEnv, envFile, onUpdate) => {
23
68
  try {
24
69
  const envFileData = await fs_1.default.promises.readFile(envFile);
70
+ watchEnvFile({ processEnv, envFile, onUpdate, existedBefore: true });
25
71
  return {
26
72
  ...processEnv,
27
73
  ...dotenv_1.default.parse(envFileData),
@@ -33,7 +79,7 @@ const getEnvForEnvFile = async (processEnv, envFile) => {
33
79
  process.exit(1);
34
80
  }
35
81
  };
36
- const getEnvironmentVariables = () => {
82
+ const getEnvironmentVariables = (onUpdate) => {
37
83
  const processEnv = getProcessEnv();
38
84
  if (parse_command_line_1.parsedCli['env-file']) {
39
85
  const envFile = path_1.default.resolve(process.cwd(), parse_command_line_1.parsedCli['env-file']);
@@ -43,24 +89,30 @@ const getEnvironmentVariables = () => {
43
89
  log_1.Log.error('Check that your path is correct and try again.');
44
90
  process.exit(1);
45
91
  }
46
- return getEnvForEnvFile(processEnv, envFile);
92
+ return getEnvForEnvFile(processEnv, envFile, onUpdate);
47
93
  }
48
94
  const remotionRoot = (0, find_closest_package_json_1.findRemotionRoot)();
49
95
  const configFileSetting = config_1.ConfigInternals.getDotEnvLocation();
50
96
  if (configFileSetting) {
51
97
  const envFile = path_1.default.resolve(remotionRoot, configFileSetting);
52
98
  if (!fs_1.default.existsSync(envFile)) {
53
- log_1.Log.error('You specifed a custom .env file using `Config.Rendering.setDotEnvLocation()` in the config file but it could not be found');
99
+ log_1.Log.error('You specified a custom .env file using `Config.Rendering.setDotEnvLocation()` in the config file but it could not be found');
54
100
  log_1.Log.error('We looked for the file at:', envFile);
55
101
  log_1.Log.error('Check that your path is correct and try again.');
56
102
  process.exit(1);
57
103
  }
58
- return getEnvForEnvFile(processEnv, envFile);
104
+ return getEnvForEnvFile(processEnv, envFile, onUpdate);
59
105
  }
60
106
  const defaultEnvFile = path_1.default.resolve(remotionRoot, '.env');
61
107
  if (!fs_1.default.existsSync(defaultEnvFile)) {
108
+ watchEnvFile({
109
+ processEnv,
110
+ envFile: defaultEnvFile,
111
+ onUpdate,
112
+ existedBefore: false,
113
+ });
62
114
  return Promise.resolve(processEnv);
63
115
  }
64
- return getEnvForEnvFile(processEnv, defaultEnvFile);
116
+ return getEnvForEnvFile(processEnv, defaultEnvFile, onUpdate);
65
117
  };
66
118
  exports.getEnvironmentVariables = getEnvironmentVariables;
@@ -1,6 +1,10 @@
1
1
  import type { Codec, CodecOrUndefined } from '@remotion/renderer';
2
- export declare const getFinalOutputCodec: ({ codec: inputCodec, fileExtension, emitWarning, }: {
3
- codec: CodecOrUndefined;
4
- fileExtension: string | null;
5
- emitWarning: boolean;
6
- }) => Codec;
2
+ export declare const getFinalOutputCodec: ({ cliFlag, configFile, downloadName, outName, }: {
3
+ cliFlag: CodecOrUndefined;
4
+ outName: string | null;
5
+ downloadName: string | null;
6
+ configFile: Codec | null;
7
+ }) => {
8
+ codec: Codec;
9
+ reason: string;
10
+ };
@@ -2,62 +2,62 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFinalOutputCodec = void 0;
4
4
  const renderer_1 = require("@remotion/renderer");
5
- const log_1 = require("./log");
6
- const getFinalOutputCodec = ({ codec: inputCodec, fileExtension, emitWarning, }) => {
7
- if (inputCodec === undefined && fileExtension === 'webm') {
8
- if (emitWarning) {
9
- log_1.Log.info('You have specified a .webm extension, using the VP8 encoder. Use --codec=vp9 to use the Vp9 encoder.');
10
- }
11
- return 'vp8';
12
- }
13
- if (inputCodec === undefined && fileExtension === 'hevc') {
14
- if (emitWarning) {
15
- log_1.Log.info('You have specified a .hevc extension, using the H265 encoder.');
16
- }
17
- return 'h265';
18
- }
19
- if (inputCodec === undefined && fileExtension === 'mp3') {
20
- if (emitWarning) {
21
- log_1.Log.info('You have specified a .mp3 extension, using the MP3 encoder.');
22
- }
23
- return 'mp3';
24
- }
25
- if (inputCodec === undefined && fileExtension === 'mov') {
26
- if (emitWarning) {
27
- log_1.Log.info('You have specified a .mov extension, using the Apple ProRes encoder.');
28
- }
29
- return 'prores';
30
- }
31
- if (inputCodec === undefined && fileExtension === 'wav') {
32
- if (emitWarning) {
33
- log_1.Log.info('You have specified a .wav extension, using the WAV encoder.');
34
- }
35
- return 'wav';
36
- }
37
- if (inputCodec === undefined && fileExtension === 'aac') {
38
- if (emitWarning) {
39
- log_1.Log.info('You have specified a .aac extension, using the AAC encoder.');
40
- }
41
- return 'aac';
42
- }
43
- if (inputCodec === undefined && fileExtension === 'm4a') {
44
- if (emitWarning) {
45
- log_1.Log.info('You have specified a .m4a extension, using the AAC encoder.');
46
- }
47
- return 'aac';
48
- }
49
- if (inputCodec === undefined && fileExtension === 'mkv') {
50
- if (emitWarning) {
51
- log_1.Log.info('You have specified a .mkv extension, using the H264 encoder and WAV audio format.');
52
- }
53
- return 'h264-mkv';
54
- }
55
- if (inputCodec === undefined && fileExtension === 'gif') {
56
- if (emitWarning) {
57
- log_1.Log.info('You have specified a .gif extension, rendering a GIF');
58
- }
59
- return 'gif';
5
+ const fileExtensions = {
6
+ webm: 'vp8',
7
+ hevc: 'h265',
8
+ mp3: 'mp3',
9
+ mov: 'prores',
10
+ wav: 'wav',
11
+ aac: 'aac',
12
+ mkv: 'h264-mkv',
13
+ gif: 'gif',
14
+ mp4: 'h264',
15
+ m4a: 'aac',
16
+ };
17
+ const deriveExtensionFromFilename = (extension) => {
18
+ var _a;
19
+ if (extension === null) {
20
+ return null;
60
21
  }
61
- return inputCodec !== null && inputCodec !== void 0 ? inputCodec : renderer_1.RenderInternals.DEFAULT_CODEC;
22
+ return (_a = fileExtensions[extension]) !== null && _a !== void 0 ? _a : null;
23
+ };
24
+ const getFinalOutputCodec = ({ cliFlag, configFile, downloadName, outName, }) => {
25
+ const downloadNameExtension = renderer_1.RenderInternals.getExtensionOfFilename(downloadName);
26
+ const outNameExtension = renderer_1.RenderInternals.getExtensionOfFilename(outName);
27
+ const derivedDownloadCodec = deriveExtensionFromFilename(downloadNameExtension);
28
+ const derivedOutNameCodec = deriveExtensionFromFilename(outNameExtension);
29
+ if (derivedDownloadCodec &&
30
+ derivedOutNameCodec &&
31
+ derivedDownloadCodec !== derivedOutNameCodec) {
32
+ throw new TypeError(`The download name is ${downloadName} but the output name is ${outName}. The file extensions must match`);
33
+ }
34
+ if (derivedDownloadCodec) {
35
+ if (cliFlag && derivedDownloadCodec !== cliFlag) {
36
+ throw new TypeError(`The download name is ${downloadName} but --codec=${cliFlag} was passed. The download name implies a codec of ${derivedDownloadCodec} which does not align with the --codec flag.`);
37
+ }
38
+ return {
39
+ codec: derivedDownloadCodec,
40
+ reason: 'derived from download name',
41
+ };
42
+ }
43
+ if (derivedOutNameCodec) {
44
+ if (cliFlag && derivedOutNameCodec !== cliFlag) {
45
+ throw new TypeError(`The out name is ${outName} but --codec=${cliFlag} was passed. The out name implies a codec of ${derivedOutNameCodec} which does not align with the --codec flag.`);
46
+ }
47
+ return {
48
+ codec: derivedOutNameCodec,
49
+ reason: 'derived from out name',
50
+ };
51
+ }
52
+ if (cliFlag) {
53
+ return { codec: cliFlag, reason: 'from --codec flag' };
54
+ }
55
+ if (configFile) {
56
+ return {
57
+ codec: configFile,
58
+ reason: 'Config file',
59
+ };
60
+ }
61
+ return { codec: renderer_1.RenderInternals.DEFAULT_CODEC, reason: 'default' };
62
62
  };
63
63
  exports.getFinalOutputCodec = getFinalOutputCodec;
@@ -0,0 +1,7 @@
1
+ import type { Codec, RenderMediaOptions } from '@remotion/renderer';
2
+ export declare const getRenderMediaOptions: ({ outputLocation, config, serveUrl, codec, }: {
3
+ outputLocation: RenderMediaOptions['outputLocation'];
4
+ config: RenderMediaOptions['composition'];
5
+ serveUrl: string;
6
+ codec: Codec;
7
+ }) => Promise<RenderMediaOptions>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRenderMediaOptions = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
5
+ const config_1 = require("./config");
6
+ const get_cli_options_1 = require("./get-cli-options");
7
+ const getRenderMediaOptions = async ({ outputLocation, config, serveUrl, codec, }) => {
8
+ const { proResProfile, concurrency, frameRange, overwrite, inputProps, envVariables, quality, crf, pixelFormat, imageFormat, browserExecutable, ffmpegExecutable, ffprobeExecutable, scale, chromiumOptions, port, numberOfGifLoops, everyNthFrame, muted, enforceAudioTrack, ffmpegOverride, } = await (0, get_cli_options_1.getCliOptions)({
9
+ isLambda: false,
10
+ type: 'series',
11
+ codec,
12
+ });
13
+ return {
14
+ outputLocation,
15
+ composition: config,
16
+ crf,
17
+ envVariables,
18
+ ffmpegExecutable,
19
+ ffprobeExecutable,
20
+ frameRange,
21
+ imageFormat,
22
+ inputProps,
23
+ overwrite,
24
+ pixelFormat,
25
+ proResProfile,
26
+ quality,
27
+ dumpBrowserLogs: renderer_1.RenderInternals.isEqualOrBelowLogLevel(config_1.ConfigInternals.Logging.getLogLevel(), 'verbose'),
28
+ chromiumOptions,
29
+ timeoutInMilliseconds: config_1.ConfigInternals.getCurrentPuppeteerTimeout(),
30
+ scale,
31
+ port,
32
+ numberOfGifLoops,
33
+ everyNthFrame,
34
+ verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(config_1.ConfigInternals.Logging.getLogLevel(), 'verbose'),
35
+ muted,
36
+ enforceAudioTrack,
37
+ browserExecutable,
38
+ ffmpegOverride,
39
+ concurrency,
40
+ serveUrl,
41
+ codec,
42
+ };
43
+ };
44
+ exports.getRenderMediaOptions = getRenderMediaOptions;
package/dist/index.d.ts CHANGED
@@ -70,12 +70,12 @@ export declare const CliInternals: {
70
70
  getCliOptions: (options: {
71
71
  isLambda: boolean;
72
72
  type: "still" | "series" | "get-compositions";
73
+ codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
73
74
  }) => Promise<{
74
75
  puppeteerTimeout: number;
75
76
  concurrency: number | null;
76
77
  frameRange: import("@remotion/renderer").FrameRange | null;
77
78
  shouldOutputImageSequence: boolean;
78
- codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
79
79
  inputProps: object;
80
80
  envVariables: Record<string, string>;
81
81
  quality: number | undefined;
@@ -90,7 +90,7 @@ export declare const CliInternals: {
90
90
  browserExecutable: import("@remotion/renderer").BrowserExecutable;
91
91
  ffmpegExecutable: import("@remotion/renderer").FfmpegExecutable;
92
92
  ffprobeExecutable: import("@remotion/renderer").FfmpegExecutable;
93
- logLevel: "verbose" | "info" | "warn" | "error";
93
+ logLevel: "error" | "verbose" | "info" | "warn";
94
94
  scale: number;
95
95
  chromiumOptions: import("@remotion/renderer").ChromiumOptions;
96
96
  overwrite: boolean;
@@ -100,9 +100,9 @@ export declare const CliInternals: {
100
100
  publicDir: string | null;
101
101
  ffmpegOverride: import("@remotion/renderer").FfmpegOverrideFn;
102
102
  }>;
103
- parseCommandLine: (type: "sequence" | "still" | "lambda" | "preview" | "versions") => void;
103
+ parseCommandLine: () => void;
104
104
  loadConfig: (remotionRoot: string) => Promise<string | null>;
105
- initializeRenderCli: (remotionRoot: string, type: "sequence" | "still" | "lambda" | "preview") => Promise<void>;
105
+ initializeCli: (remotionRoot: string) => Promise<void>;
106
106
  BooleanFlags: string[];
107
107
  quietFlagProvided: () => boolean;
108
108
  parsedCli: import("./parse-command-line").CommandLineOptions & import("minimist").ParsedArgs;
@@ -115,4 +115,21 @@ export declare const CliInternals: {
115
115
  }) => string;
116
116
  getFileSizeDownloadBar: (downloaded: number) => string;
117
117
  findRemotionRoot: () => string;
118
+ getFinalCodec: (options: {
119
+ downloadName: string | null;
120
+ outName: string | null;
121
+ }) => {
122
+ codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
123
+ reason: string;
124
+ };
125
+ determineFinalImageFormat: ({ downloadName, outName, configImageFormat, cliFlag, isLambda, }: {
126
+ downloadName: string | null;
127
+ outName: string | null;
128
+ configImageFormat: "png" | "jpeg" | "none" | null;
129
+ cliFlag: "png" | "jpeg" | "none" | null;
130
+ isLambda: boolean;
131
+ }) => {
132
+ format: import("@remotion/renderer").StillImageFormat;
133
+ source: string;
134
+ };
118
135
  };
package/dist/index.js CHANGED
@@ -16,17 +16,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CliInternals = exports.overrideRemotion = exports.ConfigInternals = exports.cli = void 0;
18
18
  const renderer_1 = require("@remotion/renderer");
19
+ const benchmark_1 = require("./benchmark");
19
20
  const chalk_1 = require("./chalk");
20
21
  const check_version_1 = require("./check-version");
21
22
  const compositions_1 = require("./compositions");
22
23
  const index_1 = require("./config/index");
24
+ const determine_image_format_1 = require("./determine-image-format");
23
25
  const download_progress_1 = require("./download-progress");
24
26
  const find_closest_package_json_1 = require("./find-closest-package-json");
25
27
  const format_bytes_1 = require("./format-bytes");
26
28
  const get_cli_options_1 = require("./get-cli-options");
27
29
  const get_config_file_name_1 = require("./get-config-file-name");
28
30
  const handle_common_errors_1 = require("./handle-common-errors");
29
- const initialize_render_cli_1 = require("./initialize-render-cli");
31
+ const initialize_cli_1 = require("./initialize-cli");
30
32
  const lambda_command_1 = require("./lambda-command");
31
33
  const load_config_1 = require("./load-config");
32
34
  const log_1 = require("./log");
@@ -54,6 +56,7 @@ const cli = async () => {
54
56
  await (0, versions_1.validateVersionsBeforeCommand)(remotionRoot);
55
57
  }
56
58
  const errorSymbolicationLock = renderer_1.RenderInternals.registerErrorSymbolicationLock();
59
+ await (0, initialize_cli_1.initializeCli)(remotionRoot);
57
60
  try {
58
61
  if (command === 'compositions') {
59
62
  await (0, compositions_1.listCompositionsCommand)(remotionRoot);
@@ -76,12 +79,17 @@ const cli = async () => {
76
79
  else if (command === versions_1.VERSIONS_COMMAND) {
77
80
  await (0, versions_1.versionsCommand)(remotionRoot);
78
81
  }
82
+ else if (command === 'benchmark') {
83
+ await (0, benchmark_1.benchmarkCommand)(remotionRoot, parse_command_line_1.parsedCli._.slice(1));
84
+ }
79
85
  else if (command === 'help') {
80
86
  (0, print_help_1.printHelp)();
81
87
  process.exit(0);
82
88
  }
83
89
  else {
84
- log_1.Log.error(`Command ${command} not found.`);
90
+ if (command) {
91
+ log_1.Log.error(`Command ${command} not found.`);
92
+ }
85
93
  (0, print_help_1.printHelp)();
86
94
  process.exit(1);
87
95
  }
@@ -109,7 +117,7 @@ exports.CliInternals = {
109
117
  getCliOptions: get_cli_options_1.getCliOptions,
110
118
  parseCommandLine: parse_command_line_1.parseCommandLine,
111
119
  loadConfig: get_config_file_name_1.loadConfig,
112
- initializeRenderCli: initialize_render_cli_1.initializeRenderCli,
120
+ initializeCli: initialize_cli_1.initializeCli,
113
121
  BooleanFlags: parse_command_line_1.BooleanFlags,
114
122
  quietFlagProvided: parse_command_line_1.quietFlagProvided,
115
123
  parsedCli: parse_command_line_1.parsedCli,
@@ -117,4 +125,6 @@ exports.CliInternals = {
117
125
  formatBytes: format_bytes_1.formatBytes,
118
126
  getFileSizeDownloadBar: download_progress_1.getFileSizeDownloadBar,
119
127
  findRemotionRoot: find_closest_package_json_1.findRemotionRoot,
128
+ getFinalCodec: get_cli_options_1.getFinalCodec,
129
+ determineFinalImageFormat: determine_image_format_1.determineFinalImageFormat,
120
130
  };
@@ -0,0 +1 @@
1
+ export declare const initializeCli: (remotionRoot: string) => Promise<void>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeCli = void 0;
4
+ const get_config_file_name_1 = require("./get-config-file-name");
5
+ const log_1 = require("./log");
6
+ const parse_command_line_1 = require("./parse-command-line");
7
+ const initializeCli = async (remotionRoot) => {
8
+ const appliedName = await (0, get_config_file_name_1.loadConfig)(remotionRoot);
9
+ (0, parse_command_line_1.parseCommandLine)();
10
+ // Only now Log.verbose is available
11
+ log_1.Log.verbose('Remotion root directory:', remotionRoot);
12
+ if (remotionRoot !== process.cwd()) {
13
+ log_1.Log.warn(`Warning: The root directory of your project is ${remotionRoot}, but you are executing this command from ${process.cwd()}. The recommendation is to execute commands from the root directory.`);
14
+ }
15
+ if (appliedName) {
16
+ log_1.Log.verbose(`Applied configuration from ${appliedName}.`);
17
+ }
18
+ else {
19
+ log_1.Log.verbose('No config file loaded.');
20
+ }
21
+ };
22
+ exports.initializeCli = initializeCli;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lambdaCommand = void 0;
4
- const initialize_render_cli_1 = require("./initialize-render-cli");
5
4
  const log_1 = require("./log");
6
5
  const parse_command_line_1 = require("./parse-command-line");
7
6
  const get_package_manager_1 = require("./preview-server/get-package-manager");
@@ -12,7 +11,6 @@ const lambdaCommand = async (remotionRoot) => {
12
11
  paths: [remotionRoot],
13
12
  });
14
13
  const { LambdaInternals } = require(path);
15
- await (0, initialize_render_cli_1.initializeRenderCli)(remotionRoot, 'lambda');
16
14
  await LambdaInternals.executeCommand(parse_command_line_1.parsedCli._.slice(1));
17
15
  process.exit(0);
18
16
  }
@@ -41,5 +41,5 @@ export declare type CommandLineOptions = {
41
41
  };
42
42
  export declare const BooleanFlags: string[];
43
43
  export declare const parsedCli: CommandLineOptions & minimist.ParsedArgs;
44
- export declare const parseCommandLine: (type: 'still' | 'sequence' | 'lambda' | 'preview' | 'versions') => void;
44
+ export declare const parseCommandLine: () => void;
45
45
  export declare const quietFlagProvided: () => boolean;
@@ -33,7 +33,7 @@ exports.BooleanFlags = [
33
33
  exports.parsedCli = (0, minimist_1.default)(process.argv.slice(2), {
34
34
  boolean: exports.BooleanFlags,
35
35
  });
36
- const parseCommandLine = (type) => {
36
+ const parseCommandLine = () => {
37
37
  if (exports.parsedCli['pixel-format']) {
38
38
  config_1.Config.Output.setPixelFormat(exports.parsedCli['pixel-format']);
39
39
  }
@@ -81,17 +81,9 @@ const parseCommandLine = (type) => {
81
81
  config_1.Config.Puppeteer.setTimeoutInMilliseconds(exports.parsedCli.timeout);
82
82
  }
83
83
  if (exports.parsedCli.frames) {
84
- if (type === 'still') {
85
- log_1.Log.error('--frames flag was passed to the `still` command. This flag only works with the `render` command. Did you mean `--frame`? See reference: https://www.remotion.dev/docs/cli/');
86
- process.exit(1);
87
- }
88
84
  config_1.ConfigInternals.setFrameRangeFromCli(exports.parsedCli.frames);
89
85
  }
90
86
  if (exports.parsedCli.frame) {
91
- if (type === 'sequence') {
92
- log_1.Log.error('--frame flag was passed to the `render` command. This flag only works with the `still` command. Did you mean `--frames`? See reference: https://www.remotion.dev/docs/cli/');
93
- process.exit(1);
94
- }
95
87
  config_1.ConfigInternals.setStillFrame(Number(exports.parsedCli.frame));
96
88
  }
97
89
  if (exports.parsedCli.png) {
@@ -105,9 +97,6 @@ const parseCommandLine = (type) => {
105
97
  if (typeof exports.parsedCli.crf !== 'undefined') {
106
98
  config_1.Config.Output.setCrf(exports.parsedCli.crf);
107
99
  }
108
- if (exports.parsedCli.codec) {
109
- config_1.Config.Output.setCodec(exports.parsedCli.codec);
110
- }
111
100
  if (exports.parsedCli['every-nth-frame']) {
112
101
  config_1.Config.Rendering.setEveryNthFrame(exports.parsedCli['every-nth-frame']);
113
102
  }
@@ -0,0 +1,12 @@
1
+ import type { RenderStep } from './step';
2
+ export declare const prepareEntryPoint: ({ file, otherSteps, publicPath, outDir, remotionRoot, }: {
3
+ file: string;
4
+ otherSteps: RenderStep[];
5
+ outDir: string | null;
6
+ publicPath: string | null;
7
+ remotionRoot: string;
8
+ }) => Promise<{
9
+ urlOrBundle: string;
10
+ steps: RenderStep[];
11
+ shouldDelete: boolean;
12
+ }>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prepareEntryPoint = void 0;
7
+ const renderer_1 = require("@remotion/renderer");
8
+ const promises_1 = require("fs/promises");
9
+ const path_1 = __importDefault(require("path"));
10
+ const process_1 = require("process");
11
+ const log_1 = require("./log");
12
+ const setup_cache_1 = require("./setup-cache");
13
+ const prepareEntryPoint = async ({ file, otherSteps, publicPath, outDir, remotionRoot, }) => {
14
+ if (renderer_1.RenderInternals.isServeUrl(file)) {
15
+ return { urlOrBundle: file, steps: otherSteps, shouldDelete: false };
16
+ }
17
+ const joined = path_1.default.resolve(process.cwd(), file);
18
+ try {
19
+ const stats = await (0, promises_1.stat)(joined);
20
+ if (stats.isDirectory()) {
21
+ return { urlOrBundle: joined, steps: otherSteps, shouldDelete: false };
22
+ }
23
+ }
24
+ catch (err) {
25
+ log_1.Log.error(`No file or directory exists at ${joined}.`);
26
+ (0, process_1.exit)(1);
27
+ }
28
+ const urlOrBundle = await (0, setup_cache_1.bundleOnCliOrTakeServeUrl)({
29
+ fullPath: joined,
30
+ steps: ['bundling', ...otherSteps],
31
+ outDir,
32
+ publicPath,
33
+ remotionRoot,
34
+ });
35
+ return { urlOrBundle, steps: ['bundling', ...otherSteps], shouldDelete: true };
36
+ };
37
+ exports.prepareEntryPoint = prepareEntryPoint;
@@ -1,12 +1,13 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'http';
2
2
  import type { LiveEventsServer } from './live-events';
3
- export declare const handleRoutes: ({ hash, hashPrefix, request, response, liveEventsServer, getCurrentInputProps, remotionRoot, userPassedPublicDir, }: {
3
+ export declare const handleRoutes: ({ hash, hashPrefix, request, response, liveEventsServer, getCurrentInputProps, getEnvVariables, remotionRoot, userPassedPublicDir, }: {
4
4
  hash: string;
5
5
  hashPrefix: string;
6
6
  request: IncomingMessage;
7
7
  response: ServerResponse;
8
8
  liveEventsServer: LiveEventsServer;
9
9
  getCurrentInputProps: () => object;
10
+ getEnvVariables: () => Record<string, string>;
10
11
  remotionRoot: string;
11
12
  userPassedPublicDir: string | null;
12
13
  }) => void | Promise<void>;
@@ -25,7 +25,7 @@ const static404 = (response) => {
25
25
  response.writeHead(404);
26
26
  response.end('The static/ prefix has been changed, this URL is no longer valid.');
27
27
  };
28
- const handleFallback = async ({ remotionRoot, hash, response, getCurrentInputProps, }) => {
28
+ const handleFallback = async ({ remotionRoot, hash, response, getCurrentInputProps, getEnvVariables, }) => {
29
29
  const [edit] = await editorGuess;
30
30
  const displayName = (0, open_in_editor_1.getDisplayNameForEditor)(edit ? edit.command : null);
31
31
  response.setHeader('content-type', 'text/html');
@@ -35,6 +35,7 @@ const handleFallback = async ({ remotionRoot, hash, response, getCurrentInputPro
35
35
  staticHash: hash,
36
36
  baseDir: '/',
37
37
  editorName: displayName,
38
+ envVariables: getEnvVariables(),
38
39
  inputProps: getCurrentInputProps(),
39
40
  remotionRoot,
40
41
  previewServerCommand: packageManager === 'unknown' ? null : packageManager.startCommand,
@@ -117,7 +118,7 @@ const handleFavicon = (_, response) => {
117
118
  const readStream = (0, fs_1.createReadStream)(filePath);
118
119
  readStream.pipe(response);
119
120
  };
120
- const handleRoutes = ({ hash, hashPrefix, request, response, liveEventsServer, getCurrentInputProps, remotionRoot, userPassedPublicDir, }) => {
121
+ const handleRoutes = ({ hash, hashPrefix, request, response, liveEventsServer, getCurrentInputProps, getEnvVariables, remotionRoot, userPassedPublicDir, }) => {
121
122
  const url = new URL(request.url, 'http://localhost');
122
123
  if (url.pathname === '/api/update') {
123
124
  return handleUpdate(remotionRoot, request, response);
@@ -156,6 +157,7 @@ const handleRoutes = ({ hash, hashPrefix, request, response, liveEventsServer, g
156
157
  hash,
157
158
  response,
158
159
  getCurrentInputProps,
160
+ getEnvVariables,
159
161
  });
160
162
  };
161
163
  exports.handleRoutes = handleRoutes;
@@ -3,7 +3,7 @@ import type { LiveEventsServer } from './live-events';
3
3
  export declare const startServer: (entry: string, userDefinedComponent: string, options: {
4
4
  webpackOverride: WebpackOverrideFn;
5
5
  getCurrentInputProps: () => object;
6
- envVariables?: Record<string, string>;
6
+ getEnvVariables: () => Record<string, string>;
7
7
  port: number | null;
8
8
  maxTimelineTracks?: number;
9
9
  remotionRoot: string;
@@ -26,7 +26,7 @@ const startServer = async (entry, userDefinedComponent, options) => {
26
26
  outDir: tmpDir,
27
27
  environment: 'development',
28
28
  webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : config_1.ConfigInternals.getWebpackOverrideFn(),
29
- envVariables: (_b = options === null || options === void 0 ? void 0 : options.envVariables) !== null && _b !== void 0 ? _b : {},
29
+ envVariables: (_b = options === null || options === void 0 ? void 0 : options.getEnvVariables()) !== null && _b !== void 0 ? _b : {},
30
30
  maxTimelineTracks: (_c = options === null || options === void 0 ? void 0 : options.maxTimelineTracks) !== null && _c !== void 0 ? _c : 15,
31
31
  entryPoints: [
32
32
  require.resolve('./hot-middleware/client'),
@@ -62,6 +62,7 @@ const startServer = async (entry, userDefinedComponent, options) => {
62
62
  response,
63
63
  liveEventsServer,
64
64
  getCurrentInputProps: options.getCurrentInputProps,
65
+ getEnvVariables: options.getEnvVariables,
65
66
  remotionRoot: options.remotionRoot,
66
67
  userPassedPublicDir: options.userPassedPublicDir,
67
68
  });