@remotion/renderer 4.0.0-alpha5 → 4.0.0-alpha6

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 (54) hide show
  1. package/dist/assets/download-and-map-assets-to-file.js +6 -6
  2. package/dist/assets/download-file.d.ts +3 -2
  3. package/dist/assets/download-file.js +18 -3
  4. package/dist/assets/download-map.js +7 -7
  5. package/dist/assets/read-file.d.ts +1 -1
  6. package/dist/assets/read-file.js +2 -2
  7. package/dist/assets/sanitize-filepath.js +2 -2
  8. package/dist/audio-codec.d.ts +1 -1
  9. package/dist/browser/BrowserFetcher.js +13 -13
  10. package/dist/browser/BrowserRunner.d.ts +1 -1
  11. package/dist/browser/BrowserRunner.js +2 -2
  12. package/dist/browser/Launcher.js +4 -4
  13. package/dist/browser/NodeWebSocketTransport.js +4 -4
  14. package/dist/browser/get-download-destination.js +8 -8
  15. package/dist/call-ffmpeg.js +6 -3
  16. package/dist/client.d.ts +16 -4
  17. package/dist/combine-videos.js +6 -6
  18. package/dist/compositor/compose.js +8 -5
  19. package/dist/compositor/compositor.js +6 -4
  20. package/dist/delete-directory.js +3 -3
  21. package/dist/does-have-m2-bug.js +2 -2
  22. package/dist/ensure-output-directory.js +5 -5
  23. package/dist/ffmpeg-filter-file.js +7 -7
  24. package/dist/file-extensions.js +7 -1
  25. package/dist/find-closest-package-json.js +6 -6
  26. package/dist/get-concurrency.js +3 -3
  27. package/dist/get-extension-of-filename.js +2 -2
  28. package/dist/get-local-browser-executable.js +4 -4
  29. package/dist/get-video-threads-flag.js +3 -3
  30. package/dist/index.d.ts +16 -4
  31. package/dist/merge-audio-track.js +2 -2
  32. package/dist/mime-types.js +2 -2
  33. package/dist/offthread-video-server.d.ts +1 -1
  34. package/dist/offthread-video-server.js +2 -2
  35. package/dist/options/jpeg-quality.js +1 -1
  36. package/dist/prepare-server.js +4 -4
  37. package/dist/prestitcher-memory-usage.js +2 -2
  38. package/dist/puppeteer-screenshot.js +1 -1
  39. package/dist/render-frames.js +5 -5
  40. package/dist/render-media.js +9 -9
  41. package/dist/render-still.d.ts +2 -0
  42. package/dist/render-still.js +17 -6
  43. package/dist/resolve-asset-src.js +2 -2
  44. package/dist/screenshot-task.js +2 -2
  45. package/dist/serve-handler/index.d.ts +1 -1
  46. package/dist/serve-handler/index.js +15 -15
  47. package/dist/serve-handler/is-path-inside.js +3 -3
  48. package/dist/serve-static.js +2 -2
  49. package/dist/stitch-frames-to-video.js +13 -13
  50. package/dist/take-frame-and-compose.js +6 -6
  51. package/dist/tmp-dir.js +7 -7
  52. package/install-toolchain.mjs +2 -2
  53. package/package.json +9 -9
  54. package/types/ws/index.d.ts +5 -5
@@ -4,19 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.findRemotionRoot = exports.findClosestPackageJson = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const recursionLimit = 5;
10
10
  const findClosestPackageJson = () => {
11
11
  let currentDir = process.cwd();
12
12
  let possiblePackageJson = '';
13
13
  for (let i = 0; i < recursionLimit; i++) {
14
- possiblePackageJson = path_1.default.join(currentDir, 'package.json');
15
- const exists = fs_1.default.existsSync(possiblePackageJson);
14
+ possiblePackageJson = node_path_1.default.join(currentDir, 'package.json');
15
+ const exists = node_fs_1.default.existsSync(possiblePackageJson);
16
16
  if (exists) {
17
17
  return possiblePackageJson;
18
18
  }
19
- currentDir = path_1.default.dirname(currentDir);
19
+ currentDir = node_path_1.default.dirname(currentDir);
20
20
  }
21
21
  return null;
22
22
  };
@@ -26,6 +26,6 @@ const findRemotionRoot = () => {
26
26
  if (closestPackageJson === null) {
27
27
  return process.cwd();
28
28
  }
29
- return path_1.default.dirname(closestPackageJson);
29
+ return node_path_1.default.dirname(closestPackageJson);
30
30
  };
31
31
  exports.findRemotionRoot = findRemotionRoot;
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getActualConcurrency = void 0;
7
- const os_1 = __importDefault(require("os"));
7
+ const node_os_1 = __importDefault(require("node:os"));
8
8
  const getActualConcurrency = (userPreference) => {
9
9
  if (userPreference === null) {
10
- return Math.round(Math.min(8, Math.max(1, os_1.default.cpus().length / 2)));
10
+ return Math.round(Math.min(8, Math.max(1, node_os_1.default.cpus().length / 2)));
11
11
  }
12
- const max = os_1.default.cpus().length;
12
+ const max = node_os_1.default.cpus().length;
13
13
  const min = 1;
14
14
  let rounded;
15
15
  if (typeof userPreference === 'string') {
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getExtensionOfFilename = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const getExtensionOfFilename = (filename) => {
9
9
  if (filename === null) {
10
10
  return null;
11
11
  }
12
- const filenameArr = path_1.default.normalize(filename).split('.');
12
+ const filenameArr = node_path_1.default.normalize(filename).split('.');
13
13
  const hasExtension = filenameArr.length >= 2;
14
14
  const filenameArrLength = filenameArr.length;
15
15
  const extension = hasExtension ? filenameArr[filenameArrLength - 1] : null;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getLocalBrowserExecutable = exports.ensureLocalBrowser = void 0;
7
- const fs_1 = __importDefault(require("fs"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const BrowserFetcher_1 = require("./browser/BrowserFetcher");
9
9
  const create_browser_fetcher_1 = require("./browser/create-browser-fetcher");
10
10
  const revisions_1 = require("./browser/revisions");
@@ -38,7 +38,7 @@ const getSearchPathsForProduct = (product) => {
38
38
  const mapBrowserToProduct = (browser) => browser;
39
39
  const getLocalBrowser = (product) => {
40
40
  for (const p of getSearchPathsForProduct(product)) {
41
- if (fs_1.default.existsSync(p)) {
41
+ if (node_fs_1.default.existsSync(p)) {
42
42
  return p;
43
43
  }
44
44
  }
@@ -46,7 +46,7 @@ const getLocalBrowser = (product) => {
46
46
  };
47
47
  const getBrowserStatus = (product, browserExecutablePath) => {
48
48
  if (browserExecutablePath) {
49
- if (!fs_1.default.existsSync(browserExecutablePath)) {
49
+ if (!node_fs_1.default.existsSync(browserExecutablePath)) {
50
50
  console.warn(`Browser executable was specified as '${browserExecutablePath}' but the path doesn't exist.`);
51
51
  }
52
52
  return { path: browserExecutablePath, type: 'user-defined-path' };
@@ -56,7 +56,7 @@ const getBrowserStatus = (product, browserExecutablePath) => {
56
56
  return { path: localBrowser, type: 'local-browser' };
57
57
  }
58
58
  const revision = (0, BrowserFetcher_1.getRevisionInfo)(revisions_1.PUPPETEER_REVISIONS.chromium, product);
59
- if (revision.local && fs_1.default.existsSync(revision.executablePath)) {
59
+ if (revision.local && node_fs_1.default.existsSync(revision.executablePath)) {
60
60
  return { path: revision.executablePath, type: 'local-puppeteer-browser' };
61
61
  }
62
62
  return { type: 'no-browser' };
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getIdealVideoThreadsFlag = void 0;
7
- const os_1 = __importDefault(require("os"));
7
+ const node_os_1 = __importDefault(require("node:os"));
8
8
  const MEMORY_USAGE_PER_THREAD = 400000000; // 400MB
9
9
  const RESERVED_MEMORY = 2000000000;
10
10
  const getIdealVideoThreadsFlag = () => {
11
- const freeMemory = os_1.default.freemem();
12
- const cpus = os_1.default.cpus().length;
11
+ const freeMemory = node_os_1.default.freemem();
12
+ const cpus = node_os_1.default.cpus().length;
13
13
  const maxRecommendedBasedOnCpus = (cpus * 2) / 3;
14
14
  const maxRecommendedBasedOnMemory = (freeMemory - RESERVED_MEMORY) / MEMORY_USAGE_PER_THREAD;
15
15
  const maxRecommended = Math.min(maxRecommendedBasedOnCpus, maxRecommendedBasedOnMemory);
package/dist/index.d.ts CHANGED
@@ -59,7 +59,7 @@ export declare const RenderInternals: {
59
59
  ensureOutputDirectory: (outputLocation: string) => void;
60
60
  getRealFrameRange: (durationInFrames: number, frameRange: import("./frame-range").FrameRange | null) => [number, number];
61
61
  validatePuppeteerTimeout: (timeoutInMilliseconds: unknown) => void;
62
- downloadFile: ({ onProgress, url, to: toFn, }: {
62
+ downloadFile: (options: {
63
63
  url: string;
64
64
  to: (contentDisposition: string | null, contentType: string | null) => string;
65
65
  onProgress: ((progress: {
@@ -67,7 +67,7 @@ export declare const RenderInternals: {
67
67
  downloaded: number;
68
68
  totalSize: number | null;
69
69
  }) => void) | undefined;
70
- }) => Promise<{
70
+ }, retries?: number) => Promise<{
71
71
  sizeInBytes: number;
72
72
  to: string;
73
73
  }>;
@@ -260,7 +260,19 @@ export declare const RenderInternals: {
260
260
  gif: {
261
261
  default: import("./file-extensions").FileExtension;
262
262
  forAudioCodec: {
263
- [x: string]: {
263
+ "pcm-16": {
264
+ possible: import("./file-extensions").FileExtension[];
265
+ default: import("./file-extensions").FileExtension;
266
+ };
267
+ aac: {
268
+ possible: import("./file-extensions").FileExtension[];
269
+ default: import("./file-extensions").FileExtension;
270
+ };
271
+ mp3: {
272
+ possible: import("./file-extensions").FileExtension[];
273
+ default: import("./file-extensions").FileExtension;
274
+ };
275
+ opus: {
264
276
  possible: import("./file-extensions").FileExtension[];
265
277
  default: import("./file-extensions").FileExtension;
266
278
  };
@@ -271,7 +283,7 @@ export declare const RenderInternals: {
271
283
  readonly h264: readonly ["aac", "pcm-16"];
272
284
  readonly 'h264-mkv': readonly ["pcm-16"];
273
285
  readonly aac: readonly ["aac", "pcm-16"];
274
- readonly gif: const[];
286
+ readonly gif: ("pcm-16" | "aac" | "mp3" | "opus")[];
275
287
  readonly h265: readonly ["aac", "pcm-16"];
276
288
  readonly mp3: readonly ["mp3", "pcm-16"];
277
289
  readonly prores: readonly ["aac", "pcm-16"];
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.mergeAudioTrack = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const call_ffmpeg_1 = require("./call-ffmpeg");
9
9
  const chunk_1 = require("./chunk");
10
10
  const create_ffmpeg_complex_filter_1 = require("./create-ffmpeg-complex-filter");
@@ -29,7 +29,7 @@ const mergeAudioTrackUnlimited = async ({ outName, files, numberOfSeconds, downl
29
29
  const tempPath = (0, tmp_dir_1.tmpDir)('remotion-large-audio-mixing');
30
30
  try {
31
31
  const chunkNames = await Promise.all(chunked.map(async (chunkFiles, i) => {
32
- const chunkOutname = path_1.default.join(tempPath, `chunk-${i}.wav`);
32
+ const chunkOutname = node_path_1.default.join(tempPath, `chunk-${i}.wav`);
33
33
  await (0, exports.mergeAudioTrack)({
34
34
  files: chunkFiles,
35
35
  numberOfSeconds,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mimeContentType = exports.mimeLookup = exports.getExt = void 0;
4
- const path_1 = require("path");
4
+ const node_path_1 = require("node:path");
5
5
  const mime_db_1 = require("./mime-db");
6
6
  const extensions = {};
7
7
  const types = {};
@@ -17,7 +17,7 @@ function mimeLookup(path) {
17
17
  return false;
18
18
  }
19
19
  // get the extension ("ext" or ".ext" or full path)
20
- const ext = (0, path_1.extname)('.' + path)
20
+ const ext = (0, node_path_1.extname)('.' + path)
21
21
  .toLowerCase()
22
22
  .substr(1);
23
23
  if (!ext) {
@@ -1,4 +1,4 @@
1
- import type { RequestListener } from 'http';
1
+ import type { RequestListener } from 'node:http';
2
2
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
3
3
  import type { DownloadMap } from './assets/download-map';
4
4
  export declare const extractUrlAndSourceFromUrl: (url: string) => {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startOffthreadVideoServer = exports.extractUrlAndSourceFromUrl = void 0;
4
- const url_1 = require("url");
4
+ const node_url_1 = require("node:url");
5
5
  const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
6
6
  const compositor_1 = require("./compositor/compositor");
7
7
  const extractUrlAndSourceFromUrl = (url) => {
@@ -10,7 +10,7 @@ const extractUrlAndSourceFromUrl = (url) => {
10
10
  if (!query.trim()) {
11
11
  throw new Error('Expected query from ' + url);
12
12
  }
13
- const params = new url_1.URLSearchParams(query);
13
+ const params = new node_url_1.URLSearchParams(query);
14
14
  const src = params.get('src');
15
15
  if (!src) {
16
16
  throw new Error('Did not pass `src` parameter');
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  exports.jpegQualityOption = {
6
6
  name: 'JPEG Quality',
7
7
  cliFlag: '--jpeg-quality',
8
- description: ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "Sets the quality of the generated JPEG images. Must be an integer between 0 and 100. Default is to leave it up to the browser, current default is 80." })),
8
+ description: ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "Sets the quality of the generated JPEG images. Must be an integer between 0 and 100. Default: 80." })),
9
9
  ssrName: 'jpegQuality',
10
10
  docLink: 'https://www.remotion.dev/docs/renderer/render-media#jpeg-quality',
11
11
  };
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.prepareServer = void 0;
7
- const fs_1 = require("fs");
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const is_serve_url_1 = require("./is-serve-url");
10
10
  const serve_static_1 = require("./serve-static");
11
11
  const wait_for_symbolication_error_to_be_done_1 = require("./wait-for-symbolication-error-to-be-done");
@@ -29,8 +29,8 @@ const prepareServer = async ({ onDownload, onError, webpackConfigOrServeUrl, por
29
29
  });
30
30
  }
31
31
  // Check if the path has a `index.html` file
32
- const indexFile = path_1.default.join(webpackConfigOrServeUrl, 'index.html');
33
- const exists = (0, fs_1.existsSync)(indexFile);
32
+ const indexFile = node_path_1.default.join(webpackConfigOrServeUrl, 'index.html');
33
+ const exists = (0, node_fs_1.existsSync)(indexFile);
34
34
  if (!exists) {
35
35
  throw new Error(`Tried to serve the Webpack bundle on a HTTP server, but the file ${indexFile} does not exist. Is this a valid path to a Webpack bundle?`);
36
36
  }
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.shouldUseParallelEncoding = void 0;
7
- const os_1 = __importDefault(require("os"));
7
+ const node_os_1 = __importDefault(require("node:os"));
8
8
  const estimateMemoryUsageForPrestitcher = ({ width, height, }) => {
9
9
  // Empirically we detected that per 1 million pixels, FFMPEG uses around 1GB of memory, relatively independent of
10
10
  // the duration of the video.
@@ -13,7 +13,7 @@ const estimateMemoryUsageForPrestitcher = ({ width, height, }) => {
13
13
  return memoryUsageOfPixel * width * height;
14
14
  };
15
15
  const shouldUseParallelEncoding = ({ width, height, }) => {
16
- const freeMemory = os_1.default.freemem();
16
+ const freeMemory = node_os_1.default.freemem();
17
17
  const estimatedUsage = estimateMemoryUsageForPrestitcher({
18
18
  height,
19
19
  width,
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.screenshot = void 0;
27
- const assert = __importStar(require("assert"));
27
+ const assert = __importStar(require("node:assert"));
28
28
  const screenshot_task_1 = require("./screenshot-task");
29
29
  const screenshot = (options) => {
30
30
  if (options.jpegQuality) {
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.renderFrames = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const perf_hooks_1 = require("perf_hooks");
10
10
  const remotion_1 = require("remotion");
11
11
  const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
@@ -37,8 +37,8 @@ const validate_scale_1 = require("./validate-scale");
37
37
  const MAX_RETRIES_PER_FRAME = 1;
38
38
  const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpegQuality, quality, imageFormat = image_format_1.DEFAULT_VIDEO_IMAGE_FORMAT, frameRange, onError, envVariables, onBrowserLog, onFrameBuffer, onDownload, pagesArray, serveUrl, composition, timeoutInMilliseconds, scale = 1, actualConcurrency, everyNthFrame = 1, proxyPort, cancelSignal, downloadMap, muted, makeBrowser, browserReplacer, }) => {
39
39
  if (outputDir) {
40
- if (!fs_1.default.existsSync(outputDir)) {
41
- fs_1.default.mkdirSync(outputDir, {
40
+ if (!node_fs_1.default.existsSync(outputDir)) {
41
+ node_fs_1.default.mkdirSync(outputDir, {
42
42
  recursive: true,
43
43
  });
44
44
  }
@@ -162,7 +162,7 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpeg
162
162
  freePage,
163
163
  height,
164
164
  imageFormat,
165
- output: path_1.default.join(frameDir, (0, get_frame_padded_index_1.getFrameOutputFileName)({
165
+ output: node_path_1.default.join(frameDir, (0, get_frame_padded_index_1.getFrameOutputFileName)({
166
166
  frame,
167
167
  imageFormat,
168
168
  index,
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.renderMedia = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_os_1 = __importDefault(require("node:os"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
10
  const remotion_1 = require("remotion");
11
11
  const download_map_1 = require("./assets/download-map");
12
12
  const can_use_parallel_encoding_1 = require("./can-use-parallel-encoding");
@@ -67,7 +67,7 @@ const renderMedia = ({ proResProfile, crf, composition, inputProps, pixelFormat,
67
67
  });
68
68
  }
69
69
  const absoluteOutputLocation = outputLocation
70
- ? path_1.default.resolve(process.cwd(), outputLocation)
70
+ ? node_path_1.default.resolve(process.cwd(), outputLocation)
71
71
  : null;
72
72
  (0, validate_scale_1.validateScale)(scale);
73
73
  (0, validate_ffmpeg_override_1.validateFfmpegOverride)(ffmpegOverride);
@@ -110,11 +110,11 @@ const renderMedia = ({ proResProfile, crf, composition, inputProps, pixelFormat,
110
110
  const jpegQuality = imageFormat === 'jpeg' ? options.jpegQuality : undefined;
111
111
  (0, image_format_1.validateSelectedPixelFormatAndImageFormatCombination)(pixelFormat, imageFormat);
112
112
  const preEncodedFileLocation = parallelEncoding
113
- ? path_1.default.join(downloadMap.preEncode, 'pre-encode.' + (0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, audioCodec !== null && audioCodec !== void 0 ? audioCodec : null))
113
+ ? node_path_1.default.join(downloadMap.preEncode, 'pre-encode.' + (0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, audioCodec !== null && audioCodec !== void 0 ? audioCodec : null))
114
114
  : null;
115
115
  const outputDir = parallelEncoding
116
116
  ? null
117
- : fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'react-motion-render'));
117
+ : node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'react-motion-render'));
118
118
  if (((_h = options.internal) === null || _h === void 0 ? void 0 : _h.onCtrlCExit) && outputDir) {
119
119
  options.internal.onCtrlCExit(() => (0, delete_directory_1.deleteDirectory)(outputDir));
120
120
  }
@@ -348,15 +348,15 @@ const renderMedia = ({ proResProfile, crf, composition, inputProps, pixelFormat,
348
348
  .finally(() => {
349
349
  var _a;
350
350
  if (preEncodedFileLocation !== null &&
351
- fs_1.default.existsSync(preEncodedFileLocation)) {
352
- (0, delete_directory_1.deleteDirectory)(path_1.default.dirname(preEncodedFileLocation));
351
+ node_fs_1.default.existsSync(preEncodedFileLocation)) {
352
+ (0, delete_directory_1.deleteDirectory)(node_path_1.default.dirname(preEncodedFileLocation));
353
353
  }
354
354
  // Clean download map if it was not passed in
355
355
  if (!((_a = options.internal) === null || _a === void 0 ? void 0 : _a.downloadMap)) {
356
356
  (0, download_map_1.cleanDownloadMap)(downloadMap);
357
357
  }
358
358
  // Clean temporary image frames when rendering ends or fails
359
- if (outputDir && fs_1.default.existsSync(outputDir)) {
359
+ if (outputDir && node_fs_1.default.existsSync(outputDir)) {
360
360
  (0, delete_directory_1.deleteDirectory)(outputDir);
361
361
  }
362
362
  });
@@ -3,6 +3,7 @@ import type { AnySmallCompMetadata } from 'remotion';
3
3
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
4
4
  import type { DownloadMap } from './assets/download-map';
5
5
  import type { BrowserExecutable } from './browser-executable';
6
+ import type { BrowserLog } from './browser-log';
6
7
  import type { Browser as PuppeteerBrowser } from './browser/Browser';
7
8
  import type { StillImageFormat } from './image-format';
8
9
  import type { CancelSignal } from './make-cancel-signal';
@@ -23,6 +24,7 @@ declare type InnerStillOptions = {
23
24
  envVariables?: Record<string, string>;
24
25
  overwrite?: boolean;
25
26
  browserExecutable?: BrowserExecutable;
27
+ onBrowserLog?: (log: BrowserLog) => void;
26
28
  timeoutInMilliseconds?: number;
27
29
  chromiumOptions?: ChromiumOptions;
28
30
  scale?: number;
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.renderStill = void 0;
30
- const fs_1 = __importStar(require("fs"));
31
- const path_1 = __importDefault(require("path"));
30
+ const node_fs_1 = __importStar(require("node:fs"));
31
+ const node_path_1 = __importDefault(require("node:path"));
32
32
  const remotion_1 = require("remotion");
33
33
  const download_map_1 = require("./assets/download-map");
34
34
  const browser_1 = require("./browser");
@@ -47,7 +47,7 @@ const set_props_and_env_1 = require("./set-props-and-env");
47
47
  const take_frame_and_compose_1 = require("./take-frame-and-compose");
48
48
  const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
49
49
  const validate_scale_1 = require("./validate-scale");
50
- const innerRenderStill = async ({ composition, quality, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale = 1, proxyPort, cancelSignal, downloadMap, jpegQuality, }) => {
50
+ const innerRenderStill = async ({ composition, quality, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale = 1, proxyPort, cancelSignal, downloadMap, jpegQuality, onBrowserLog, }) => {
51
51
  if (quality) {
52
52
  throw new Error('quality has been renamed to jpegQuality. Please rename the option.');
53
53
  }
@@ -72,17 +72,17 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
72
72
  (0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
73
73
  (0, validate_scale_1.validateScale)(scale);
74
74
  output =
75
- typeof output === 'string' ? path_1.default.resolve(process.cwd(), output) : null;
75
+ typeof output === 'string' ? node_path_1.default.resolve(process.cwd(), output) : null;
76
76
  if (jpegQuality !== undefined && imageFormat !== 'jpeg') {
77
77
  throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
78
78
  }
79
79
  (0, jpeg_quality_1.validateJpegQuality)(jpegQuality);
80
80
  if (output) {
81
- if (fs_1.default.existsSync(output)) {
81
+ if (node_fs_1.default.existsSync(output)) {
82
82
  if (!overwrite) {
83
83
  throw new Error(`Cannot render still - "overwrite" option was set to false, but the output destination ${output} already exists.`);
84
84
  }
85
- const stat = (0, fs_1.statSync)(output);
85
+ const stat = (0, node_fs_1.statSync)(output);
86
86
  if (!stat.isFile()) {
87
87
  throw new Error(`The output location ${output} already exists, but is not a file, but something else (e.g. folder). Cannot save to it.`);
88
88
  }
@@ -110,8 +110,16 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
110
110
  onError: errorCallback,
111
111
  frame: null,
112
112
  });
113
+ const logCallback = (log) => {
114
+ onBrowserLog === null || onBrowserLog === void 0 ? void 0 : onBrowserLog({
115
+ stackTrace: log.stackTrace(),
116
+ text: log.text,
117
+ type: log.type,
118
+ });
119
+ };
113
120
  const cleanup = async () => {
114
121
  cleanUpJSException();
122
+ page.off('console', logCallback);
115
123
  if (puppeteerInstance) {
116
124
  await page.close();
117
125
  }
@@ -124,6 +132,9 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
124
132
  cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
125
133
  cleanup();
126
134
  });
135
+ if (onBrowserLog) {
136
+ page.on('console', logCallback);
137
+ }
127
138
  await (0, set_props_and_env_1.setPropsAndEnv)({
128
139
  inputProps,
129
140
  envVariables,
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveAssetSrc = void 0;
7
- const url_1 = __importDefault(require("url"));
7
+ const node_url_1 = __importDefault(require("node:url"));
8
8
  const resolveAssetSrc = (src) => {
9
9
  if (!src.startsWith('file:')) {
10
10
  return src;
11
11
  }
12
12
  const { protocol } = new URL(src);
13
13
  if (protocol === 'file:')
14
- return url_1.default.fileURLToPath(src);
14
+ return node_url_1.default.fileURLToPath(src);
15
15
  throw new TypeError(`Unexpected src ${src}`);
16
16
  };
17
17
  exports.resolveAssetSrc = resolveAssetSrc;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.screenshotTask = void 0;
7
- const fs_1 = __importDefault(require("fs"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const perf_1 = require("./perf");
9
9
  const screenshotTask = async ({ format, height, omitBackground, page, width, path, jpegQuality, clipRegion, }) => {
10
10
  var _a;
@@ -64,7 +64,7 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
64
64
  const saveMarker = (0, perf_1.startPerfMeasure)('save');
65
65
  const buffer = Buffer.from(result.data, 'base64');
66
66
  if (path)
67
- await fs_1.default.promises.writeFile(path, buffer);
67
+ await node_fs_1.default.promises.writeFile(path, buffer);
68
68
  (0, perf_1.stopPerfMeasure)(saveMarker);
69
69
  return buffer;
70
70
  }
@@ -1,4 +1,4 @@
1
- import type { IncomingMessage, ServerResponse } from 'http';
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
2
  export declare const serveHandler: (request: IncomingMessage, response: ServerResponse, config: {
3
3
  public: string;
4
4
  }) => Promise<void>;
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.serveHandler = void 0;
7
- const fs_1 = require("fs");
8
- const path_1 = __importDefault(require("path"));
9
- const url_1 = __importDefault(require("url"));
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_url_1 = __importDefault(require("node:url"));
10
10
  const mime_types_1 = require("../mime-types");
11
11
  // Packages
12
12
  const is_path_inside_1 = require("./is-path-inside");
13
13
  const range_parser_1 = require("./range-parser");
14
14
  const getHeaders = (absolutePath, stats) => {
15
- const { base } = path_1.default.parse(absolutePath);
15
+ const { base } = node_path_1.default.parse(absolutePath);
16
16
  let defaultHeaders = {};
17
17
  if (stats) {
18
18
  defaultHeaders = {
@@ -28,19 +28,19 @@ const getHeaders = (absolutePath, stats) => {
28
28
  return defaultHeaders;
29
29
  };
30
30
  const getPossiblePaths = (relativePath, extension) => [
31
- path_1.default.join(relativePath, `index${extension}`),
31
+ node_path_1.default.join(relativePath, `index${extension}`),
32
32
  relativePath.endsWith('/')
33
33
  ? relativePath.replace(/\/$/g, extension)
34
34
  : relativePath + extension,
35
- ].filter((item) => path_1.default.basename(item) !== extension);
35
+ ].filter((item) => node_path_1.default.basename(item) !== extension);
36
36
  const findRelated = async (current, relativePath) => {
37
37
  const possible = getPossiblePaths(relativePath, '.html');
38
38
  let stats = null;
39
39
  for (let index = 0; index < possible.length; index++) {
40
40
  const related = possible[index];
41
- const absolutePath = path_1.default.join(current, related);
41
+ const absolutePath = node_path_1.default.join(current, related);
42
42
  try {
43
- stats = await fs_1.promises.lstat(absolutePath);
43
+ stats = await node_fs_1.promises.lstat(absolutePath);
44
44
  }
45
45
  catch (err) {
46
46
  if (err.code !== 'ENOENT' &&
@@ -75,10 +75,10 @@ const internalError = (absolutePath, response) => {
75
75
  };
76
76
  const serveHandler = async (request, response, config) => {
77
77
  const cwd = process.cwd();
78
- const current = path_1.default.resolve(cwd, config.public);
78
+ const current = node_path_1.default.resolve(cwd, config.public);
79
79
  let relativePath = null;
80
80
  try {
81
- relativePath = decodeURIComponent(url_1.default.parse(request.url).pathname);
81
+ relativePath = decodeURIComponent(node_url_1.default.parse(request.url).pathname);
82
82
  }
83
83
  catch (err) {
84
84
  return sendError('/', response, {
@@ -87,7 +87,7 @@ const serveHandler = async (request, response, config) => {
87
87
  message: 'Bad Request',
88
88
  });
89
89
  }
90
- let absolutePath = path_1.default.join(current, relativePath);
90
+ let absolutePath = node_path_1.default.join(current, relativePath);
91
91
  // Prevent path traversal vulnerabilities. We could do this
92
92
  // by ourselves, but using the package covers all the edge cases.
93
93
  if (!(0, is_path_inside_1.isPathInside)(absolutePath, current)) {
@@ -109,9 +109,9 @@ const serveHandler = async (request, response, config) => {
109
109
  // directory exists requires loading all the file paths and then checking if
110
110
  // one of them includes the path of the directory. As that's a very
111
111
  // performance-expensive thing to do, we need to ensure it's not happening if not really necessary.
112
- if (path_1.default.extname(relativePath) !== '') {
112
+ if (node_path_1.default.extname(relativePath) !== '') {
113
113
  try {
114
- stats = await fs_1.promises.lstat(absolutePath);
114
+ stats = await node_fs_1.promises.lstat(absolutePath);
115
115
  }
116
116
  catch (err) {
117
117
  if (err.code !== 'ENOENT' &&
@@ -135,7 +135,7 @@ const serveHandler = async (request, response, config) => {
135
135
  }
136
136
  }
137
137
  try {
138
- stats = await fs_1.promises.lstat(absolutePath);
138
+ stats = await node_fs_1.promises.lstat(absolutePath);
139
139
  }
140
140
  catch (err) {
141
141
  if (err.code !== 'ENOENT' &&
@@ -190,7 +190,7 @@ const serveHandler = async (request, response, config) => {
190
190
  }
191
191
  let stream = null;
192
192
  try {
193
- stream = (0, fs_1.createReadStream)(absolutePath, streamOpts !== null && streamOpts !== void 0 ? streamOpts : {});
193
+ stream = (0, node_fs_1.createReadStream)(absolutePath, streamOpts !== null && streamOpts !== void 0 ? streamOpts : {});
194
194
  }
195
195
  catch (err) {
196
196
  return internalError(absolutePath, response);
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isPathInside = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const isPathInside = function (thePath, potentialParent) {
9
9
  // For inside-directory checking, we want to allow trailing slashes, so normalize.
10
10
  thePath = stripTrailingSep(thePath);
@@ -15,12 +15,12 @@ const isPathInside = function (thePath, potentialParent) {
15
15
  potentialParent = potentialParent.toLowerCase();
16
16
  }
17
17
  return (thePath.lastIndexOf(potentialParent, 0) === 0 &&
18
- (thePath[potentialParent.length] === path_1.default.sep ||
18
+ (thePath[potentialParent.length] === node_path_1.default.sep ||
19
19
  thePath[potentialParent.length] === undefined));
20
20
  };
21
21
  exports.isPathInside = isPathInside;
22
22
  function stripTrailingSep(thePath) {
23
- if (thePath[thePath.length - 1] === path_1.default.sep) {
23
+ if (thePath[thePath.length - 1] === node_path_1.default.sep) {
24
24
  return thePath.slice(0, -1);
25
25
  }
26
26
  return thePath;