@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.
- package/README.md +5 -43
- package/dist/assets/download-and-map-assets-to-file.js +6 -6
- package/dist/assets/download-file.d.ts +3 -2
- package/dist/assets/download-file.js +18 -3
- package/dist/assets/download-map.d.ts +0 -26
- package/dist/assets/download-map.js +7 -12
- package/dist/assets/get-audio-channels.d.ts +1 -2
- package/dist/assets/get-audio-channels.js +5 -9
- package/dist/assets/read-file.d.ts +1 -1
- package/dist/assets/read-file.js +2 -2
- package/dist/assets/sanitize-filepath.js +2 -2
- package/dist/audio-codec.d.ts +4 -3
- package/dist/audio-codec.js +3 -9
- package/dist/browser/BrowserFetcher.d.ts +0 -1
- package/dist/browser/BrowserFetcher.js +14 -15
- package/dist/browser/BrowserRunner.d.ts +1 -1
- package/dist/browser/BrowserRunner.js +10 -4
- package/dist/browser/FrameManager.js +2 -3
- package/dist/browser/LaunchOptions.d.ts +1 -0
- package/dist/browser/Launcher.js +6 -5
- package/dist/browser/NodeWebSocketTransport.js +4 -4
- package/dist/browser/devtools-commands.d.ts +5 -1
- package/dist/browser/devtools-types.d.ts +78 -0
- package/dist/browser/get-download-destination.js +8 -8
- package/dist/browser/is-target-closed-err.d.ts +1 -0
- package/dist/browser/is-target-closed-err.js +9 -0
- package/dist/call-ffmpeg.d.ts +14 -0
- package/dist/call-ffmpeg.js +40 -0
- package/dist/check-apple-silicon.js +2 -45
- package/dist/client.d.ts +79 -42
- package/dist/client.js +27 -1
- package/dist/codec-supports-media.d.ts +2 -1
- package/dist/codec-supports-media.js +20 -5
- package/dist/combine-videos.d.ts +0 -3
- package/dist/combine-videos.js +9 -13
- package/dist/compositor/compose.d.ts +3 -1
- package/dist/compositor/compose.js +41 -18
- package/dist/compositor/compositor.d.ts +12 -0
- package/dist/compositor/compositor.js +204 -0
- package/dist/compositor/get-executable-path.d.ts +1 -1
- package/dist/compositor/get-executable-path.js +27 -8
- package/dist/compositor/make-nonce.d.ts +1 -0
- package/dist/compositor/make-nonce.js +8 -0
- package/dist/compositor/payloads.d.ts +34 -7
- package/dist/create-ffmpeg-complex-filter.d.ts +5 -5
- package/dist/create-ffmpeg-complex-filter.js +2 -4
- package/dist/create-ffmpeg-merge-filter.d.ts +2 -5
- package/dist/create-ffmpeg-merge-filter.js +2 -10
- package/dist/create-silent-audio.d.ts +1 -4
- package/dist/create-silent-audio.js +3 -7
- package/dist/crf.js +8 -2
- package/dist/delete-directory.js +18 -18
- package/dist/does-have-m2-bug.js +2 -2
- package/dist/ensure-output-directory.js +5 -5
- package/dist/ffmpeg-filter-file.js +7 -7
- package/dist/file-extensions.d.ts +1 -12
- package/dist/file-extensions.js +8 -14
- package/dist/find-closest-package-json.js +6 -6
- package/dist/get-compositions.d.ts +3 -5
- package/dist/get-compositions.js +8 -11
- package/dist/get-concurrency.js +3 -3
- package/dist/get-extension-from-codec.d.ts +2 -2
- package/dist/get-extension-of-filename.js +2 -2
- package/dist/get-frame-padded-index.d.ts +2 -1
- package/dist/get-local-browser-executable.js +4 -4
- package/dist/get-video-threads-flag.js +3 -3
- package/dist/guess-extension-for-media.d.ts +1 -3
- package/dist/guess-extension-for-media.js +4 -8
- package/dist/image-format.d.ts +12 -6
- package/dist/image-format.js +16 -13
- package/dist/index.d.ts +80 -61
- package/dist/index.js +15 -17
- package/dist/jpeg-quality.d.ts +1 -0
- package/dist/jpeg-quality.js +21 -0
- package/dist/merge-audio-track.d.ts +0 -2
- package/dist/merge-audio-track.js +5 -12
- package/dist/mime-types.js +2 -2
- package/dist/offthread-video-server.d.ts +9 -9
- package/dist/offthread-video-server.js +65 -58
- package/dist/open-browser.d.ts +1 -0
- package/dist/open-browser.js +7 -6
- package/dist/options/audio-bitrate.d.ts +2 -0
- package/dist/options/audio-bitrate.js +11 -0
- package/dist/options/crf.d.ts +2 -0
- package/dist/options/crf.js +11 -0
- package/dist/options/enforce-audio.d.ts +2 -0
- package/dist/options/enforce-audio.js +11 -0
- package/dist/options/jpeg-quality.d.ts +2 -0
- package/dist/options/jpeg-quality.js +11 -0
- package/dist/options/mute.d.ts +2 -0
- package/dist/options/mute.js +11 -0
- package/dist/options/option.d.ts +8 -0
- package/dist/options/option.js +2 -0
- package/dist/options/scale.d.ts +2 -0
- package/dist/options/scale.js +11 -0
- package/dist/options/video-bitrate.d.ts +2 -0
- package/dist/options/video-bitrate.js +11 -0
- package/dist/options/video-codec.d.ts +2 -0
- package/dist/options/video-codec.js +11 -0
- package/dist/perf.d.ts +1 -1
- package/dist/perf.js +9 -7
- package/dist/prepare-server.d.ts +3 -4
- package/dist/prepare-server.js +9 -9
- package/dist/preprocess-audio-track.d.ts +0 -4
- package/dist/preprocess-audio-track.js +4 -8
- package/dist/prespawn-ffmpeg.d.ts +6 -9
- package/dist/prespawn-ffmpeg.js +7 -12
- package/dist/prestitcher-memory-usage.d.ts +0 -4
- package/dist/prestitcher-memory-usage.js +4 -5
- package/dist/prores-profile.d.ts +1 -2
- package/dist/prores-profile.js +4 -4
- package/dist/provide-screenshot.d.ts +4 -5
- package/dist/provide-screenshot.js +2 -2
- package/dist/puppeteer-screenshot.d.ts +3 -3
- package/dist/puppeteer-screenshot.js +10 -33
- package/dist/render-frames.d.ts +13 -25
- package/dist/render-frames.js +34 -45
- package/dist/render-media.d.ts +16 -18
- package/dist/render-media.js +42 -52
- package/dist/render-still.d.ts +12 -8
- package/dist/render-still.js +30 -18
- package/dist/resolve-asset-src.js +2 -2
- package/dist/screenshot-dom-element.d.ts +4 -5
- package/dist/screenshot-dom-element.js +6 -3
- package/dist/screenshot-task.d.ts +2 -3
- package/dist/screenshot-task.js +40 -25
- package/dist/serve-handler/index.d.ts +1 -1
- package/dist/serve-handler/index.js +21 -19
- package/dist/serve-handler/is-path-inside.js +3 -3
- package/dist/serve-static.d.ts +2 -3
- package/dist/serve-static.js +26 -22
- package/dist/stitch-frames-to-video.d.ts +2 -12
- package/dist/stitch-frames-to-video.js +37 -46
- package/dist/take-frame-and-compose.d.ts +4 -5
- package/dist/take-frame-and-compose.js +15 -9
- package/dist/tmp-dir.js +7 -8
- package/dist/validate-concurrency.d.ts +2 -0
- package/dist/validate-concurrency.js +11 -5
- package/dist/validate-output-filename.d.ts +1 -1
- package/dist/validate-puppeteer-timeout.js +1 -0
- package/install-toolchain.mjs +36 -0
- package/package.json +11 -10
- package/types/ws/index.d.ts +5 -5
package/README.md
CHANGED
|
@@ -1,47 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Renderer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Contains TypeScript + Rust code for rendering a Remotion video.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
See the public APIs here: https://remotion.dev/docs/renderer
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Development
|
|
8
8
|
|
|
9
|
-
|
|
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
|
|
31
|
-
const
|
|
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 (
|
|
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
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
31
|
-
const
|
|
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 =
|
|
36
|
-
(0,
|
|
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 =
|
|
40
|
-
const packageJson =
|
|
41
|
-
? JSON.parse(
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
34
|
-
return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src
|
|
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>;
|
package/dist/assets/read-file.js
CHANGED
|
@@ -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
|
|
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
|
|
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(
|
|
14
|
+
.join(node_path_1.default.sep);
|
|
15
15
|
};
|
|
16
16
|
exports.sanitizeFilePath = sanitizeFilePath;
|
package/dist/audio-codec.d.ts
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
17
|
-
|
|
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 {};
|
package/dist/audio-codec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
50
|
-
const
|
|
51
|
-
const
|
|
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
|
|
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
|
|
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,
|
|
130
|
-
const mkdirAsync = (0,
|
|
131
|
-
const unlinkAsync = (0,
|
|
132
|
-
const chmodAsync = (0,
|
|
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.
|
|
109
|
-
|
|
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;
|
package/dist/browser/Launcher.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
32
|
-
const
|
|
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
|
|
59
|
+
const url = new node_url_1.URL(urlString);
|
|
60
60
|
if (url.hostname === 'localhost') {
|
|
61
|
-
const { address } = await
|
|
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;
|