@remotion/renderer 4.0.0-alpha4 → 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 (143) hide show
  1. package/README.md +5 -43
  2. package/dist/assets/download-and-map-assets-to-file.js +6 -6
  3. package/dist/assets/download-file.d.ts +3 -2
  4. package/dist/assets/download-file.js +18 -3
  5. package/dist/assets/download-map.d.ts +0 -26
  6. package/dist/assets/download-map.js +7 -12
  7. package/dist/assets/get-audio-channels.d.ts +1 -2
  8. package/dist/assets/get-audio-channels.js +5 -9
  9. package/dist/assets/read-file.d.ts +1 -1
  10. package/dist/assets/read-file.js +2 -2
  11. package/dist/assets/sanitize-filepath.js +2 -2
  12. package/dist/audio-codec.d.ts +4 -3
  13. package/dist/audio-codec.js +3 -9
  14. package/dist/browser/BrowserFetcher.d.ts +0 -1
  15. package/dist/browser/BrowserFetcher.js +14 -15
  16. package/dist/browser/BrowserRunner.d.ts +1 -1
  17. package/dist/browser/BrowserRunner.js +10 -4
  18. package/dist/browser/FrameManager.js +2 -3
  19. package/dist/browser/LaunchOptions.d.ts +1 -0
  20. package/dist/browser/Launcher.js +6 -5
  21. package/dist/browser/NodeWebSocketTransport.js +4 -4
  22. package/dist/browser/devtools-commands.d.ts +5 -1
  23. package/dist/browser/devtools-types.d.ts +78 -0
  24. package/dist/browser/get-download-destination.js +8 -8
  25. package/dist/browser/is-target-closed-err.d.ts +1 -0
  26. package/dist/browser/is-target-closed-err.js +9 -0
  27. package/dist/call-ffmpeg.d.ts +14 -0
  28. package/dist/call-ffmpeg.js +40 -0
  29. package/dist/check-apple-silicon.js +2 -45
  30. package/dist/client.d.ts +79 -42
  31. package/dist/client.js +27 -1
  32. package/dist/codec-supports-media.d.ts +2 -1
  33. package/dist/codec-supports-media.js +20 -5
  34. package/dist/combine-videos.d.ts +0 -3
  35. package/dist/combine-videos.js +9 -13
  36. package/dist/compositor/compose.d.ts +3 -1
  37. package/dist/compositor/compose.js +41 -18
  38. package/dist/compositor/compositor.d.ts +12 -0
  39. package/dist/compositor/compositor.js +204 -0
  40. package/dist/compositor/get-executable-path.d.ts +1 -1
  41. package/dist/compositor/get-executable-path.js +27 -8
  42. package/dist/compositor/make-nonce.d.ts +1 -0
  43. package/dist/compositor/make-nonce.js +8 -0
  44. package/dist/compositor/payloads.d.ts +34 -7
  45. package/dist/create-ffmpeg-complex-filter.d.ts +5 -5
  46. package/dist/create-ffmpeg-complex-filter.js +2 -4
  47. package/dist/create-ffmpeg-merge-filter.d.ts +2 -5
  48. package/dist/create-ffmpeg-merge-filter.js +2 -10
  49. package/dist/create-silent-audio.d.ts +1 -4
  50. package/dist/create-silent-audio.js +3 -7
  51. package/dist/crf.js +8 -2
  52. package/dist/delete-directory.js +18 -18
  53. package/dist/does-have-m2-bug.js +2 -2
  54. package/dist/ensure-output-directory.js +5 -5
  55. package/dist/ffmpeg-filter-file.js +7 -7
  56. package/dist/file-extensions.d.ts +1 -12
  57. package/dist/file-extensions.js +8 -14
  58. package/dist/find-closest-package-json.js +6 -6
  59. package/dist/get-compositions.d.ts +3 -5
  60. package/dist/get-compositions.js +8 -11
  61. package/dist/get-concurrency.js +3 -3
  62. package/dist/get-extension-from-codec.d.ts +2 -2
  63. package/dist/get-extension-of-filename.js +2 -2
  64. package/dist/get-frame-padded-index.d.ts +2 -1
  65. package/dist/get-local-browser-executable.js +4 -4
  66. package/dist/get-video-threads-flag.js +3 -3
  67. package/dist/guess-extension-for-media.d.ts +1 -3
  68. package/dist/guess-extension-for-media.js +4 -8
  69. package/dist/image-format.d.ts +12 -6
  70. package/dist/image-format.js +16 -13
  71. package/dist/index.d.ts +80 -61
  72. package/dist/index.js +15 -17
  73. package/dist/jpeg-quality.d.ts +1 -0
  74. package/dist/jpeg-quality.js +21 -0
  75. package/dist/merge-audio-track.d.ts +0 -2
  76. package/dist/merge-audio-track.js +5 -12
  77. package/dist/mime-types.js +2 -2
  78. package/dist/offthread-video-server.d.ts +9 -9
  79. package/dist/offthread-video-server.js +65 -58
  80. package/dist/open-browser.d.ts +1 -0
  81. package/dist/open-browser.js +7 -6
  82. package/dist/options/audio-bitrate.d.ts +2 -0
  83. package/dist/options/audio-bitrate.js +11 -0
  84. package/dist/options/crf.d.ts +2 -0
  85. package/dist/options/crf.js +11 -0
  86. package/dist/options/enforce-audio.d.ts +2 -0
  87. package/dist/options/enforce-audio.js +11 -0
  88. package/dist/options/jpeg-quality.d.ts +2 -0
  89. package/dist/options/jpeg-quality.js +11 -0
  90. package/dist/options/mute.d.ts +2 -0
  91. package/dist/options/mute.js +11 -0
  92. package/dist/options/option.d.ts +8 -0
  93. package/dist/options/option.js +2 -0
  94. package/dist/options/scale.d.ts +2 -0
  95. package/dist/options/scale.js +11 -0
  96. package/dist/options/video-bitrate.d.ts +2 -0
  97. package/dist/options/video-bitrate.js +11 -0
  98. package/dist/options/video-codec.d.ts +2 -0
  99. package/dist/options/video-codec.js +11 -0
  100. package/dist/perf.d.ts +1 -1
  101. package/dist/perf.js +9 -7
  102. package/dist/prepare-server.d.ts +3 -4
  103. package/dist/prepare-server.js +9 -9
  104. package/dist/preprocess-audio-track.d.ts +0 -4
  105. package/dist/preprocess-audio-track.js +4 -8
  106. package/dist/prespawn-ffmpeg.d.ts +6 -9
  107. package/dist/prespawn-ffmpeg.js +7 -12
  108. package/dist/prestitcher-memory-usage.d.ts +0 -4
  109. package/dist/prestitcher-memory-usage.js +4 -5
  110. package/dist/prores-profile.d.ts +1 -2
  111. package/dist/prores-profile.js +4 -4
  112. package/dist/provide-screenshot.d.ts +4 -5
  113. package/dist/provide-screenshot.js +2 -2
  114. package/dist/puppeteer-screenshot.d.ts +3 -3
  115. package/dist/puppeteer-screenshot.js +10 -33
  116. package/dist/render-frames.d.ts +13 -25
  117. package/dist/render-frames.js +34 -45
  118. package/dist/render-media.d.ts +16 -18
  119. package/dist/render-media.js +42 -52
  120. package/dist/render-still.d.ts +12 -8
  121. package/dist/render-still.js +30 -18
  122. package/dist/resolve-asset-src.js +2 -2
  123. package/dist/screenshot-dom-element.d.ts +4 -5
  124. package/dist/screenshot-dom-element.js +6 -3
  125. package/dist/screenshot-task.d.ts +2 -3
  126. package/dist/screenshot-task.js +40 -25
  127. package/dist/serve-handler/index.d.ts +1 -1
  128. package/dist/serve-handler/index.js +21 -19
  129. package/dist/serve-handler/is-path-inside.js +3 -3
  130. package/dist/serve-static.d.ts +2 -3
  131. package/dist/serve-static.js +26 -22
  132. package/dist/stitch-frames-to-video.d.ts +2 -12
  133. package/dist/stitch-frames-to-video.js +37 -46
  134. package/dist/take-frame-and-compose.d.ts +4 -5
  135. package/dist/take-frame-and-compose.js +15 -9
  136. package/dist/tmp-dir.js +7 -8
  137. package/dist/validate-concurrency.d.ts +2 -0
  138. package/dist/validate-concurrency.js +11 -5
  139. package/dist/validate-output-filename.d.ts +1 -1
  140. package/dist/validate-puppeteer-timeout.js +1 -0
  141. package/install-toolchain.mjs +36 -0
  142. package/package.json +11 -10
  143. package/types/ws/index.d.ts +5 -5
package/README.md CHANGED
@@ -1,47 +1,9 @@
1
- # Rust development
1
+ # Renderer
2
2
 
3
- To participate in the development of the Rust parts of Remotion, you need to do additional steps. If you don't want to change the Rust code, you don't have to set anything up.
3
+ Contains TypeScript + Rust code for rendering a Remotion video.
4
4
 
5
- ## Setup
5
+ See the public APIs here: https://remotion.dev/docs/renderer
6
6
 
7
- These are instructions for macOS. Contributions for other platforms are appreciated.
7
+ ## Development
8
8
 
9
- First, install Cargo, if you don't have it, or upgrade to a version that supports `edition-2021`:
10
-
11
- ```
12
- curl https://sh.rustup.rs -sSf | sh
13
- ```
14
-
15
- Second, install components that allow for cross-compilation:
16
-
17
- ```sh
18
- sh install_platforms.sh
19
- ```
20
-
21
- Third, install linkers for cross compilation:
22
-
23
- ```sh
24
- brew install MaterializeInc/crosstools/x86_64-unknown-linux-gnu
25
- brew install MaterializeInc/crosstools/aarch64-unknown-linux-gnu
26
- brew install messense/macos-cross-toolchains/x86_64-unknown-linux-musl
27
- brew install messense/macos-cross-toolchains/aarch64-unknown-linux-musl
28
- brew install mingw-w64
29
- ```
30
-
31
- > This will take a few minutes.
32
-
33
- ## Building
34
-
35
- To build the Rust parts for your operating system, run:
36
-
37
- ```
38
- node build.mjs
39
- ```
40
-
41
- To build the Rust binaries for all supported platforms, run:
42
-
43
- ```
44
- node build.mjs --all
45
- ```
46
-
47
- The resulting artifacts should be checked into Git.
9
+ For developing the Rust parts, see https://remotion.dev/docs/contributing/rust.
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = exports.downloadAsset = void 0;
30
- const fs_1 = __importDefault(require("fs"));
31
- const path_1 = __importStar(require("path"));
30
+ const node_fs_1 = __importDefault(require("node:fs"));
31
+ const node_path_1 = __importStar(require("node:path"));
32
32
  const remotion_1 = require("remotion");
33
33
  const compress_assets_1 = require("../compress-assets");
34
34
  const ensure_output_directory_1 = require("../ensure-output-directory");
@@ -124,7 +124,7 @@ const downloadAsset = async ({ src, onDownload, downloadMap, }) => {
124
124
  if ((_a = downloadMap.hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
125
125
  const claimedDownloadLocation = (_b = downloadMap.hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir];
126
126
  // The OS might have deleted the file since even though we marked it as downloaded. In that case we reset the state and download it again
127
- if (fs_1.default.existsSync(claimedDownloadLocation)) {
127
+ if (node_fs_1.default.existsSync(claimedDownloadLocation)) {
128
128
  return claimedDownloadLocation;
129
129
  }
130
130
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -168,7 +168,7 @@ const downloadAsset = async ({ src, onDownload, downloadMap, }) => {
168
168
  });
169
169
  (0, ensure_output_directory_1.ensureOutputDirectory)(output);
170
170
  const buff = Buffer.from(assetData, encoding);
171
- await fs_1.default.promises.writeFile(output, buff);
171
+ await node_fs_1.default.promises.writeFile(output, buff);
172
172
  notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to: output });
173
173
  return output;
174
174
  }
@@ -212,7 +212,7 @@ const getFilename = ({ contentDisposition, src, contentType, }) => {
212
212
  };
213
213
  }
214
214
  const { pathname, search } = new URL(src);
215
- const ext = (0, path_1.extname)(pathname);
215
+ const ext = (0, node_path_1.extname)(pathname);
216
216
  // Has no file extension, check if we can derive it from contentType
217
217
  if (!ext && contentType) {
218
218
  const matchedExt = (0, mime_types_1.getExt)(contentType);
@@ -238,7 +238,7 @@ const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, contentDisposition,
238
238
  : '';
239
239
  const hashedFileName = String((0, remotion_1.random)(`${pathname}${search}`)).replace('0.', '');
240
240
  const filename = hashedFileName + fileExtension;
241
- return path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(filename));
241
+ return node_path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(filename));
242
242
  };
243
243
  exports.getSanitizedFilenameForAssetUrl = getSanitizedFilenameForAssetUrl;
244
244
  const downloadAndMapAssetsToFileUrl = async ({ asset, onDownload, downloadMap, }) => {
@@ -2,7 +2,7 @@ declare type Response = {
2
2
  sizeInBytes: number;
3
3
  to: string;
4
4
  };
5
- export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
5
+ declare type Options = {
6
6
  url: string;
7
7
  to: (contentDisposition: string | null, contentType: string | null) => string;
8
8
  onProgress: ((progress: {
@@ -10,5 +10,6 @@ export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
10
10
  downloaded: number;
11
11
  totalSize: number | null;
12
12
  }) => void) | undefined;
13
- }) => Promise<Response>;
13
+ };
14
+ export declare const downloadFile: (options: Options, retries?: number) => Promise<Response>;
14
15
  export {};
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.downloadFile = void 0;
4
- const fs_1 = require("fs");
4
+ const node_fs_1 = require("node:fs");
5
5
  const ensure_output_directory_1 = require("../ensure-output-directory");
6
6
  const read_file_1 = require("./read-file");
7
- const downloadFile = ({ onProgress, url, to: toFn, }) => {
7
+ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
8
8
  return new Promise((resolve, reject) => {
9
9
  let rejected = false;
10
10
  let resolved = false;
@@ -44,7 +44,7 @@ const downloadFile = ({ onProgress, url, to: toFn, }) => {
44
44
  (0, ensure_output_directory_1.ensureOutputDirectory)(to);
45
45
  const sizeHeader = res.headers['content-length'];
46
46
  const totalSize = typeof sizeHeader === 'undefined' ? null : Number(sizeHeader);
47
- const writeStream = (0, fs_1.createWriteStream)(to);
47
+ const writeStream = (0, node_fs_1.createWriteStream)(to);
48
48
  let downloaded = 0;
49
49
  // Listen to 'close' event instead of more
50
50
  // concise method to avoid this problem
@@ -86,4 +86,19 @@ const downloadFile = ({ onProgress, url, to: toFn, }) => {
86
86
  });
87
87
  });
88
88
  };
89
+ const downloadFile = async (options, retries = 2) => {
90
+ try {
91
+ const res = await downloadFileWithoutRetries(options);
92
+ return res;
93
+ }
94
+ catch (err) {
95
+ if (err.message === 'aborted') {
96
+ if (retries === 0) {
97
+ throw err;
98
+ }
99
+ return (0, exports.downloadFile)(options, retries - 1);
100
+ }
101
+ throw err;
102
+ }
103
+ };
89
104
  exports.downloadFile = downloadFile;
@@ -1,21 +1,4 @@
1
- /// <reference types="node" />
2
1
  import type { TAsset } from 'remotion';
3
- declare type EncodingStatus = {
4
- type: 'encoding';
5
- } | {
6
- type: 'done';
7
- src: string;
8
- } | undefined;
9
- export declare type SpecialVCodecForTransparency = 'vp9' | 'vp8' | 'none';
10
- export declare type NeedsResize = [number, number] | null;
11
- export declare type Vp9Result = {
12
- specialVcodecForTransparency: SpecialVCodecForTransparency;
13
- needsResize: NeedsResize;
14
- };
15
- export declare type VideoDurationResult = {
16
- duration: number | null;
17
- fps: number | null;
18
- };
19
2
  export declare type AudioChannelsAndDurationResultCache = {
20
3
  channels: number;
21
4
  duration: number | null;
@@ -37,14 +20,6 @@ export declare type DownloadMap = {
37
20
  [downloadDir: string]: (() => void)[];
38
21
  };
39
22
  };
40
- lastFrameMap: Record<string, {
41
- lastAccessed: number;
42
- data: Buffer;
43
- }>;
44
- isBeyondLastFrameMap: Record<string, number>;
45
- isVp9VideoCache: Record<string, Vp9Result>;
46
- ensureFileHasPresentationTimestamp: Record<string, EncodingStatus>;
47
- videoDurationResultCache: Record<string, VideoDurationResult>;
48
23
  durationOfAssetCache: Record<string, AudioChannelsAndDurationResultCache>;
49
24
  downloadDir: string;
50
25
  preEncode: string;
@@ -66,4 +41,3 @@ export declare type RenderAssetInfo = {
66
41
  };
67
42
  export declare const makeDownloadMap: () => DownloadMap;
68
43
  export declare const cleanDownloadMap: (downloadMap: DownloadMap) => void;
69
- export {};
@@ -27,18 +27,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.cleanDownloadMap = exports.makeDownloadMap = 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 delete_directory_1 = require("../delete-directory");
33
33
  const tmp_dir_1 = require("../tmp-dir");
34
34
  const makeAndReturn = (dir, name) => {
35
- const p = path_1.default.join(dir, name);
36
- (0, fs_1.mkdirSync)(p);
35
+ const p = node_path_1.default.join(dir, name);
36
+ (0, node_fs_1.mkdirSync)(p);
37
37
  return p;
38
38
  };
39
- const packageJsonPath = path_1.default.join(__dirname, '..', '..', 'package.json');
40
- const packageJson = fs_1.default.existsSync(packageJsonPath)
41
- ? JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
39
+ const packageJsonPath = node_path_1.default.join(__dirname, '..', '..', 'package.json');
40
+ const packageJson = node_fs_1.default.existsSync(packageJsonPath)
41
+ ? JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
42
42
  : null;
43
43
  const makeDownloadMap = () => {
44
44
  const dir = (0, tmp_dir_1.tmpDir)(packageJson
@@ -48,11 +48,6 @@ const makeDownloadMap = () => {
48
48
  isDownloadingMap: {},
49
49
  hasBeenDownloadedMap: {},
50
50
  listeners: {},
51
- lastFrameMap: {},
52
- isBeyondLastFrameMap: {},
53
- ensureFileHasPresentationTimestamp: {},
54
- isVp9VideoCache: {},
55
- videoDurationResultCache: {},
56
51
  durationOfAssetCache: {},
57
52
  id: String(Math.random()),
58
53
  assetDir: dir,
@@ -1,3 +1,2 @@
1
- import type { FfmpegExecutable } from '../ffmpeg-executable';
2
1
  import type { AudioChannelsAndDurationResultCache, DownloadMap } from './download-map';
3
- export declare const getAudioChannelsAndDuration: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable, remotionRoot: string) => Promise<AudioChannelsAndDurationResultCache>;
2
+ export declare const getAudioChannelsAndDuration: (downloadMap: DownloadMap, src: string) => Promise<AudioChannelsAndDurationResultCache>;
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getAudioChannelsAndDuration = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const ffmpeg_flags_1 = require("../ffmpeg-flags");
4
+ const call_ffmpeg_1 = require("../call-ffmpeg");
9
5
  const p_limit_1 = require("../p-limit");
10
6
  const limit = (0, p_limit_1.pLimit)(1);
11
- async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot) {
7
+ async function getAudioChannelsAndDurationUnlimited(downloadMap, src) {
12
8
  if (downloadMap.durationOfAssetCache[src]) {
13
9
  return downloadMap.durationOfAssetCache[src];
14
10
  }
@@ -20,7 +16,7 @@ async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExe
20
16
  ]
21
17
  .reduce((acc, val) => acc.concat(val), [])
22
18
  .filter(Boolean);
23
- const task = await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffprobeExecutable, remotionRoot, 'ffprobe'), args);
19
+ const task = await (0, call_ffmpeg_1.callFf)('ffprobe', args);
24
20
  const channels = task.stdout.match(/channels=([0-9]+)/);
25
21
  const duration = task.stdout.match(/duration=([0-9.]+)/);
26
22
  const result = {
@@ -30,7 +26,7 @@ async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExe
30
26
  downloadMap.durationOfAssetCache[src] = result;
31
27
  return result;
32
28
  }
33
- const getAudioChannelsAndDuration = (downloadMap, src, ffprobeExecutable, remotionRoot) => {
34
- return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot));
29
+ const getAudioChannelsAndDuration = (downloadMap, src) => {
30
+ return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src));
35
31
  };
36
32
  exports.getAudioChannelsAndDuration = getAudioChannelsAndDuration;
@@ -1,2 +1,2 @@
1
- import http from 'http';
1
+ import http from 'node:http';
2
2
  export declare const readFile: (url: string, redirectsSoFar?: number) => Promise<http.IncomingMessage>;
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.readFile = void 0;
7
- const http_1 = __importDefault(require("http"));
8
7
  const https_1 = __importDefault(require("https"));
8
+ const node_http_1 = __importDefault(require("node:http"));
9
9
  const redirect_status_codes_1 = require("../redirect-status-codes");
10
10
  const getClient = (url) => {
11
11
  if (url.startsWith('https://')) {
12
12
  return https_1.default.get;
13
13
  }
14
14
  if (url.startsWith('http://')) {
15
- return http_1.default.get;
15
+ return node_http_1.default.get;
16
16
  }
17
17
  throw new Error('Can only download URLs starting with http:// or https://');
18
18
  };
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sanitizeFilePath = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const sanitize_filename_1 = require("./sanitize-filename");
9
9
  const pathSeparators = /[/\\]/;
10
10
  const sanitizeFilePath = (pathToSanitize) => {
11
11
  return pathToSanitize
12
12
  .split(pathSeparators)
13
13
  .map((s) => (0, sanitize_filename_1.sanitizeFilename)(s))
14
- .join(path_1.default.sep);
14
+ .join(node_path_1.default.sep);
15
15
  };
16
16
  exports.sanitizeFilePath = sanitizeFilePath;
@@ -5,7 +5,7 @@ export declare const supportedAudioCodecs: {
5
5
  readonly h264: readonly ["aac", "pcm-16"];
6
6
  readonly 'h264-mkv': readonly ["pcm-16"];
7
7
  readonly aac: readonly ["aac", "pcm-16"];
8
- readonly gif: readonly [];
8
+ readonly gif: ("pcm-16" | "aac" | "mp3" | "opus")[];
9
9
  readonly h265: readonly ["aac", "pcm-16"];
10
10
  readonly mp3: readonly ["mp3", "pcm-16"];
11
11
  readonly prores: readonly ["aac", "pcm-16"];
@@ -13,8 +13,8 @@ export declare const supportedAudioCodecs: {
13
13
  readonly vp9: readonly ["opus", "pcm-16"];
14
14
  readonly wav: readonly ["pcm-16"];
15
15
  };
16
- export declare const audioCodecNames: readonly ["pcm_s16le", "aac", "libmp3lame", "libopus"];
17
- export declare type FfmpegAudioCodecName = typeof audioCodecNames[number];
16
+ declare const audioCodecNames: readonly ["pcm_s16le", "aac", "libmp3lame", "libopus"];
17
+ declare type FfmpegAudioCodecName = typeof audioCodecNames[number];
18
18
  export declare const mapAudioCodecToFfmpegAudioCodecName: (audioCodec: AudioCodec) => FfmpegAudioCodecName;
19
19
  export declare const defaultAudioCodecs: {
20
20
  [key in Codec]: {
@@ -25,3 +25,4 @@ export declare const getDefaultAudioCodec: ({ codec, preferLossless, }: {
25
25
  codec: Codec;
26
26
  preferLossless: boolean;
27
27
  }) => AudioCodec | null;
28
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.audioCodecNames = exports.supportedAudioCodecs = exports.validAudioCodecs = void 0;
3
+ exports.getDefaultAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.supportedAudioCodecs = exports.validAudioCodecs = void 0;
4
4
  exports.validAudioCodecs = ['pcm-16', 'aac', 'mp3', 'opus'];
5
5
  exports.supportedAudioCodecs = {
6
6
  h264: ['aac', 'pcm-16'],
@@ -18,12 +18,7 @@ const _satisfies = exports.supportedAudioCodecs;
18
18
  if (_satisfies) {
19
19
  // Just for type checking
20
20
  }
21
- exports.audioCodecNames = [
22
- 'pcm_s16le',
23
- 'aac',
24
- 'libmp3lame',
25
- 'libopus',
26
- ];
21
+ const audioCodecNames = ['pcm_s16le', 'aac', 'libmp3lame', 'libopus'];
27
22
  const mapAudioCodecToFfmpegAudioCodecName = (audioCodec) => {
28
23
  if (audioCodec === 'aac') {
29
24
  return 'aac';
@@ -67,8 +62,7 @@ exports.defaultAudioCodecs = {
67
62
  },
68
63
  prores: {
69
64
  lossless: 'pcm-16',
70
- // V4.0: Make pcm the default
71
- compressed: 'aac',
65
+ compressed: 'pcm-16',
72
66
  },
73
67
  vp8: {
74
68
  lossless: 'pcm-16',
@@ -38,5 +38,4 @@ export declare const localRevisions: (downloadsFolder: string, product: Product,
38
38
  export declare const removeBrowser: (revision: string, folderPath: string) => Promise<void>;
39
39
  export declare const getFolderPath: (revision: string, downloadsFolder: string, platform: Platform) => string;
40
40
  export declare const getRevisionInfo: (revision: string, product: Product) => BrowserFetcherRevisionInfo;
41
- export declare function _downloadFile(url: string, destinationPath: string, progressCallback: (x: number, y: number) => void): Promise<number>;
42
41
  export {};
@@ -41,17 +41,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
42
42
  };
43
43
  Object.defineProperty(exports, "__esModule", { value: true });
44
- exports._downloadFile = exports.getRevisionInfo = exports.getFolderPath = exports.removeBrowser = exports.localRevisions = exports.download = exports.getDownloadHost = exports.getDownloadsFolder = exports.getPlatform = void 0;
45
- const childProcess = __importStar(require("child_process"));
46
- const fs = __importStar(require("fs"));
47
- const http = __importStar(require("http"));
44
+ exports.getRevisionInfo = exports.getFolderPath = exports.removeBrowser = exports.localRevisions = exports.download = exports.getDownloadHost = exports.getDownloadsFolder = exports.getPlatform = void 0;
48
45
  const https = __importStar(require("https"));
49
- const os = __importStar(require("os"));
50
- const path = __importStar(require("path"));
51
- const util_1 = __importDefault(require("util"));
46
+ const childProcess = __importStar(require("node:child_process"));
47
+ const fs = __importStar(require("node:fs"));
48
+ const http = __importStar(require("node:http"));
49
+ const os = __importStar(require("node:os"));
50
+ const path = __importStar(require("node:path"));
51
+ const node_util_1 = __importDefault(require("node:util"));
52
52
  const extract_zip_1 = __importDefault(require("extract-zip"));
53
- const URL = __importStar(require("url"));
54
- const util_2 = require("util");
53
+ const URL = __importStar(require("node:url"));
54
+ const node_util_2 = require("node:util");
55
55
  const assert_1 = require("./assert");
56
56
  const delete_directory_1 = require("../delete-directory");
57
57
  const get_download_destination_1 = require("./get-download-destination");
@@ -109,7 +109,7 @@ function _downloadURL(product, platform, host, revision) {
109
109
  if (platform === 'win64' || platform === 'win32') {
110
110
  return 'https://remotionchromium-binaries.s3.eu-central-1.amazonaws.com/thorium-107.zip';
111
111
  }
112
- return util_1.default.format(downloadURLs[product][platform], host, revision, archiveName(product, platform, revision));
112
+ return node_util_1.default.format(downloadURLs[product][platform], host, revision, archiveName(product, platform, revision));
113
113
  }
114
114
  function handleArm64() {
115
115
  let exists = fs.existsSync('/usr/bin/chromium-browser');
@@ -126,10 +126,10 @@ function handleArm64() {
126
126
  '\n\n sudo apt install chromium-browser\n');
127
127
  throw new Error();
128
128
  }
129
- const readdirAsync = (0, util_2.promisify)(fs.readdir.bind(fs));
130
- const mkdirAsync = (0, util_2.promisify)(fs.mkdir.bind(fs));
131
- const unlinkAsync = (0, util_2.promisify)(fs.unlink.bind(fs));
132
- const chmodAsync = (0, util_2.promisify)(fs.chmod.bind(fs));
129
+ const readdirAsync = (0, node_util_2.promisify)(fs.readdir.bind(fs));
130
+ const mkdirAsync = (0, node_util_2.promisify)(fs.mkdir.bind(fs));
131
+ const unlinkAsync = (0, node_util_2.promisify)(fs.unlink.bind(fs));
132
+ const chmodAsync = (0, node_util_2.promisify)(fs.chmod.bind(fs));
133
133
  function existsAsync(filePath) {
134
134
  return new Promise((resolve) => {
135
135
  fs.access(filePath, (err) => {
@@ -331,7 +331,6 @@ function _downloadFile(url, destinationPath, progressCallback) {
331
331
  });
332
332
  return promise;
333
333
  }
334
- exports._downloadFile = _downloadFile;
335
334
  function install(archivePath, folderPath) {
336
335
  if (archivePath.endsWith('.zip')) {
337
336
  return (0, extract_zip_1.default)(archivePath, { dir: folderPath });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  /// <reference types="node" />
17
- import * as childProcess from 'child_process';
17
+ import * as childProcess from 'node:child_process';
18
18
  import { Connection } from './Connection';
19
19
  import type { LaunchOptions } from './LaunchOptions';
20
20
  export declare class BrowserRunner {
@@ -51,8 +51,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
51
51
  var _BrowserRunner_executablePath, _BrowserRunner_processArguments, _BrowserRunner_userDataDir, _BrowserRunner_closed, _BrowserRunner_listeners, _BrowserRunner_processClosing;
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.BrowserRunner = void 0;
54
- const childProcess = __importStar(require("child_process"));
55
- const fs = __importStar(require("fs"));
54
+ const childProcess = __importStar(require("node:child_process"));
55
+ const fs = __importStar(require("node:fs"));
56
56
  const readline = __importStar(require("readline"));
57
57
  const delete_directory_1 = require("../delete-directory");
58
58
  const assert_1 = require("./assert");
@@ -105,8 +105,14 @@ class BrowserRunner {
105
105
  stdio,
106
106
  });
107
107
  if (dumpio) {
108
- (_a = this.proc.stderr) === null || _a === void 0 ? void 0 : _a.pipe(process.stderr);
109
- (_b = this.proc.stdout) === null || _b === void 0 ? void 0 : _b.pipe(process.stdout);
108
+ (_a = this.proc.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (d) => {
109
+ process.stdout.write(options.indentationString);
110
+ process.stdout.write(d.toString().trimStart());
111
+ });
112
+ (_b = this.proc.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (d) => {
113
+ process.stderr.write(options.indentationString);
114
+ process.stderr.write(d.toString().trimStart());
115
+ });
110
116
  }
111
117
  __classPrivateFieldSet(this, _BrowserRunner_closed, false, "f");
112
118
  __classPrivateFieldSet(this, _BrowserRunner_processClosing, new Promise((fulfill, reject) => {
@@ -33,6 +33,7 @@ const Connection_1 = require("./Connection");
33
33
  const DOMWorld_1 = require("./DOMWorld");
34
34
  const EventEmitter_1 = require("./EventEmitter");
35
35
  const ExecutionContext_1 = require("./ExecutionContext");
36
+ const is_target_closed_err_1 = require("./is-target-closed-err");
36
37
  const LifecycleWatcher_1 = require("./LifecycleWatcher");
37
38
  const NetworkManager_1 = require("./NetworkManager");
38
39
  const util_1 = require("./util");
@@ -135,9 +136,7 @@ class FrameManager extends EventEmitter_1.EventEmitter {
135
136
  }
136
137
  catch (error) {
137
138
  // The target might have been closed before the initialization finished.
138
- if ((0, util_1.isErrorLike)(error) &&
139
- (error.message.includes('Target closed') ||
140
- error.message.includes('Session closed'))) {
139
+ if ((0, util_1.isErrorLike)(error) && (0, is_target_closed_err_1.isTargetClosedErr)(error)) {
141
140
  return;
142
141
  }
143
142
  throw error;
@@ -29,5 +29,6 @@ export interface LaunchOptions {
29
29
  env?: Record<string, string | undefined>;
30
30
  pipe?: boolean;
31
31
  product?: Product;
32
+ indentationString: string;
32
33
  }
33
34
  export declare type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions & LaunchOptions & BrowserConnectOptions;
@@ -42,9 +42,9 @@ exports.ChromeLauncher = void 0;
42
42
  * See the License for the specific language governing permissions and
43
43
  * limitations under the License.
44
44
  */
45
- const fs_1 = __importDefault(require("fs"));
46
- const os = __importStar(require("os"));
47
- const path = __importStar(require("path"));
45
+ const node_fs_1 = __importDefault(require("node:fs"));
46
+ const os = __importStar(require("node:os"));
47
+ const path = __importStar(require("node:path"));
48
48
  const assert_1 = require("./assert");
49
49
  const Browser_1 = require("./Browser");
50
50
  const BrowserRunner_1 = require("./BrowserRunner");
@@ -57,7 +57,7 @@ class ChromeLauncher {
57
57
  this._preferredRevision = preferredRevision;
58
58
  }
59
59
  async launch(options) {
60
- const { args = [], dumpio = false, executablePath, pipe = false, env = process.env, defaultViewport, timeout = 60000, debuggingPort, } = options;
60
+ const { args = [], dumpio = false, executablePath, pipe = false, env = process.env, defaultViewport, timeout = 60000, debuggingPort, indentationString, } = options;
61
61
  const chromeArguments = args;
62
62
  if (!chromeArguments.some((argument) => {
63
63
  return argument.startsWith('--remote-debugging-');
@@ -72,7 +72,7 @@ class ChromeLauncher {
72
72
  }
73
73
  // Check for the user data dir argument, which will always be set even
74
74
  // with a custom directory specified via the userDataDir option.
75
- const userDataDir = await fs_1.default.promises.mkdtemp(path.join(tmpDir(), 'puppeteer_dev_chrome_profile-'));
75
+ const userDataDir = await node_fs_1.default.promises.mkdtemp(path.join(tmpDir(), 'puppeteer_dev_chrome_profile-'));
76
76
  chromeArguments.push(`--user-data-dir=${userDataDir}`);
77
77
  let chromeExecutable = executablePath;
78
78
  if (!chromeExecutable) {
@@ -91,6 +91,7 @@ class ChromeLauncher {
91
91
  dumpio,
92
92
  env,
93
93
  pipe: false,
94
+ indentationString,
94
95
  });
95
96
  let browser;
96
97
  try {
@@ -28,8 +28,8 @@ exports.NodeWebSocketTransport = void 0;
28
28
  * See the License for the specific language governing permissions and
29
29
  * limitations under the License.
30
30
  */
31
- const dns_1 = require("dns");
32
- const url_1 = require("url");
31
+ const node_dns_1 = require("node:dns");
32
+ const node_url_1 = require("node:url");
33
33
  const ws_types_1 = require("../ws/ws-types");
34
34
  class NodeWebSocketTransport {
35
35
  constructor(ws) {
@@ -56,9 +56,9 @@ class NodeWebSocketTransport {
56
56
  // manually with the previous behavior according to:
57
57
  // - https://nodejs.org/api/dns.html#dnslookuphostname-options-callback
58
58
  // because of https://bugzilla.mozilla.org/show_bug.cgi?id=1769994.
59
- const url = new url_1.URL(urlString);
59
+ const url = new node_url_1.URL(urlString);
60
60
  if (url.hostname === 'localhost') {
61
- const { address } = await dns_1.promises.lookup(url.hostname, { verbatim: false });
61
+ const { address } = await node_dns_1.promises.lookup(url.hostname, { verbatim: false });
62
62
  url.hostname = address;
63
63
  }
64
64
  return new Promise((resolve, reject) => {
@@ -1,4 +1,4 @@
1
- import type { ActivateTargetRequest, AddScriptToEvaluateOnNewDocumentRequest, AddScriptToEvaluateOnNewDocumentResponse, CallFunctionOnRequest, CallFunctionOnResponse, CaptureScreenshotRequest, CaptureScreenshotResponse, CloseTargetRequest, CloseTargetResponse, CreateIsolatedWorldRequest, CreateIsolatedWorldResponse, DetachFromTargetRequest, DevtoolsRemoteObject, EnableRequest, ExceptionDetails, GetFrameTreeResponse, NavigateRequest, NavigateResponse, ReleaseObjectRequest, SetAutoAttachRequest, SetDefaultBackgroundColorOverrideRequest, SetDeviceMetricsOverrideRequest, SetLifecycleEventsEnabledRequest } from './devtools-types';
1
+ import type { ActivateTargetRequest, AddScriptToEvaluateOnNewDocumentRequest, AddScriptToEvaluateOnNewDocumentResponse, CallFunctionOnRequest, CallFunctionOnResponse, CaptureScreenshotRequest, CaptureScreenshotResponse, CloseTargetRequest, CloseTargetResponse, CreateIsolatedWorldRequest, CreateIsolatedWorldResponse, DetachFromTargetRequest, DevtoolsRemoteObject, EnableRequest, ExceptionDetails, GetFrameTreeResponse, NavigateRequest, NavigateResponse, PrintPDFRequest, PrintPDFResponse, ReleaseObjectRequest, SetAutoAttachRequest, SetDefaultBackgroundColorOverrideRequest, SetDeviceMetricsOverrideRequest, SetLifecycleEventsEnabledRequest } from './devtools-types';
2
2
  export interface Commands {
3
3
  /**
4
4
  * Does nothing.
@@ -216,6 +216,10 @@ export interface Commands {
216
216
  paramsType: [CaptureScreenshotRequest?];
217
217
  returnType: CaptureScreenshotResponse;
218
218
  };
219
+ 'Page.printToPDF': {
220
+ paramsType: [PrintPDFRequest];
221
+ returnType: PrintPDFResponse;
222
+ };
219
223
  'Target.activateTarget': {
220
224
  paramsType: [ActivateTargetRequest];
221
225
  returnType: void;