@remotion/renderer 4.0.136 → 4.0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/BrowserFetcher.d.ts +4 -1
- package/dist/browser/BrowserFetcher.js +34 -103
- package/dist/browser/browser-download-progress-bar.d.ts +7 -0
- package/dist/browser/browser-download-progress-bar.js +21 -0
- package/dist/client.d.ts +87 -0
- package/dist/ensure-browser.d.ts +25 -0
- package/dist/ensure-browser.js +53 -0
- package/dist/get-browser-instance.d.ts +3 -1
- package/dist/get-browser-instance.js +2 -1
- package/dist/get-compositions.js +16 -7
- package/dist/get-local-browser-executable.d.ts +0 -6
- package/dist/get-local-browser-executable.js +4 -56
- package/dist/get-local-browser.d.ts +1 -0
- package/dist/get-local-browser.js +51 -0
- package/dist/index.d.ts +71 -12
- package/dist/index.js +7 -3
- package/dist/open-browser.d.ts +3 -1
- package/dist/open-browser.js +18 -7
- package/dist/options/enable-multiprocess-on-linux.js +2 -2
- package/dist/options/index.d.ts +10 -0
- package/dist/options/index.js +2 -0
- package/dist/options/log-level.js +1 -1
- package/dist/options/on-browser-download.d.ts +19 -0
- package/dist/options/on-browser-download.js +19 -0
- package/dist/options/options-map.d.ts +77 -0
- package/dist/options/options-map.js +10 -0
- package/dist/render-frames.js +10 -4
- package/dist/render-media.d.ts +1 -1
- package/dist/render-media.js +9 -4
- package/dist/render-still.js +9 -4
- package/dist/select-composition.js +14 -4
- package/dist/test-gpu.d.ts +3 -1
- package/dist/test-gpu.js +2 -1
- package/dist/to-megabytes.d.ts +1 -0
- package/dist/to-megabytes.js +8 -0
- package/package.json +9 -9
|
@@ -14,15 +14,18 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { LogLevel } from '../log-level';
|
|
17
|
+
import type { DownloadBrowserProgressFn } from '../options/on-browser-download';
|
|
17
18
|
interface BrowserFetcherRevisionInfo {
|
|
18
19
|
folderPath: string;
|
|
19
20
|
executablePath: string;
|
|
20
21
|
url: string;
|
|
21
22
|
local: boolean;
|
|
22
23
|
}
|
|
23
|
-
export declare const downloadBrowser: (
|
|
24
|
+
export declare const downloadBrowser: ({ logLevel, indent, onProgress, version, }: {
|
|
24
25
|
logLevel: LogLevel;
|
|
25
26
|
indent: boolean;
|
|
27
|
+
onProgress: DownloadBrowserProgressFn;
|
|
28
|
+
version: string | null;
|
|
26
29
|
}) => Promise<BrowserFetcherRevisionInfo | undefined>;
|
|
27
30
|
export declare const getRevisionInfo: () => BrowserFetcherRevisionInfo;
|
|
28
31
|
export {};
|
|
@@ -42,29 +42,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
44
|
exports.getRevisionInfo = exports.downloadBrowser = void 0;
|
|
45
|
-
const childProcess = __importStar(require("node:child_process"));
|
|
46
45
|
const fs = __importStar(require("node:fs"));
|
|
47
46
|
const os = __importStar(require("node:os"));
|
|
48
47
|
const path = __importStar(require("node:path"));
|
|
49
48
|
const extract_zip_1 = __importDefault(require("extract-zip"));
|
|
50
49
|
const node_util_1 = require("node:util");
|
|
51
|
-
const assert_1 = require("./assert");
|
|
52
50
|
const download_file_1 = require("../assets/download-file");
|
|
51
|
+
const make_file_executable_1 = require("../compositor/make-file-executable");
|
|
53
52
|
const logger_1 = require("../logger");
|
|
54
53
|
const get_download_destination_1 = require("./get-download-destination");
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'mac-arm64': 'https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.86/mac-arm64/chrome-headless-shell-mac-arm64.zip',
|
|
59
|
-
win64: 'https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.86/win64/chrome-headless-shell-win64.zip',
|
|
60
|
-
};
|
|
61
|
-
function getChromeDownloadUrl(platform) {
|
|
62
|
-
return downloadURLs[platform];
|
|
54
|
+
const TESTED_VERSION = '123.0.6312.86';
|
|
55
|
+
function getChromeDownloadUrl({ platform, version, }) {
|
|
56
|
+
return `https://storage.googleapis.com/chrome-for-testing-public/${version !== null && version !== void 0 ? version : TESTED_VERSION}/${platform}/chrome-headless-shell-${platform}.zip`;
|
|
63
57
|
}
|
|
64
|
-
const readdirAsync = fs.promises.readdir;
|
|
65
58
|
const mkdirAsync = fs.promises.mkdir;
|
|
66
59
|
const unlinkAsync = (0, node_util_1.promisify)(fs.unlink.bind(fs));
|
|
67
|
-
const chmodAsync = (0, node_util_1.promisify)(fs.chmod.bind(fs));
|
|
68
60
|
function existsAsync(filePath) {
|
|
69
61
|
return new Promise((resolve) => {
|
|
70
62
|
fs.access(filePath, (err) => {
|
|
@@ -78,22 +70,24 @@ const getPlatform = () => {
|
|
|
78
70
|
case 'darwin':
|
|
79
71
|
return os.arch() === 'arm64' ? 'mac-arm64' : 'mac-x64';
|
|
80
72
|
case 'linux':
|
|
81
|
-
return '
|
|
73
|
+
return 'linux64';
|
|
82
74
|
case 'win32':
|
|
83
75
|
return 'win64';
|
|
84
76
|
default:
|
|
85
|
-
|
|
77
|
+
throw new Error('Unsupported platform: ' + platform);
|
|
86
78
|
}
|
|
87
79
|
};
|
|
88
|
-
const destination = '
|
|
80
|
+
const destination = 'chrome-headless-shell';
|
|
89
81
|
const getDownloadsFolder = () => {
|
|
90
82
|
return path.join((0, get_download_destination_1.getDownloadsCacheDir)(), destination);
|
|
91
83
|
};
|
|
92
|
-
const downloadBrowser = async (
|
|
84
|
+
const downloadBrowser = async ({ logLevel, indent, onProgress, version, }) => {
|
|
93
85
|
const platform = getPlatform();
|
|
94
|
-
const downloadURL = getChromeDownloadUrl(platform);
|
|
86
|
+
const downloadURL = getChromeDownloadUrl({ platform, version });
|
|
95
87
|
const fileName = downloadURL.split('/').pop();
|
|
96
|
-
|
|
88
|
+
if (!fileName) {
|
|
89
|
+
throw new Error(`A malformed download URL was found: ${downloadURL}.`);
|
|
90
|
+
}
|
|
97
91
|
const downloadsFolder = getDownloadsFolder();
|
|
98
92
|
const archivePath = path.join(downloadsFolder, fileName);
|
|
99
93
|
const outputPath = getFolderPath(downloadsFolder, platform);
|
|
@@ -107,26 +101,32 @@ const downloadBrowser = async (options) => {
|
|
|
107
101
|
}
|
|
108
102
|
// Use system Chromium builds on Linux ARM devices
|
|
109
103
|
if (os.platform() !== 'darwin' && os.arch() === 'arm64') {
|
|
110
|
-
throw new Error(
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'
|
|
104
|
+
throw new Error([
|
|
105
|
+
'Chrome Headless Shell is not available for Linux for arm64 architecture.',
|
|
106
|
+
'If you are on Ubuntu, you can install with:',
|
|
107
|
+
'sudo apt install chromium',
|
|
108
|
+
'sudo apt install chromium-browser',
|
|
109
|
+
].join('\n'));
|
|
114
110
|
}
|
|
115
111
|
try {
|
|
116
|
-
let lastProgress = 0;
|
|
117
112
|
await (0, download_file_1.downloadFile)({
|
|
118
113
|
url: downloadURL,
|
|
119
114
|
to: () => archivePath,
|
|
120
115
|
onProgress: (progress) => {
|
|
121
|
-
if (progress.
|
|
122
|
-
|
|
123
|
-
logger_1.Log.info({ indent: options.indent, logLevel: options.logLevel }, `Downloading Chrome Headless Shell - ${toMegabytes(progress.downloaded)}/${toMegabytes(progress.totalSize)}`);
|
|
116
|
+
if (progress.totalSize === null || progress.percent === null) {
|
|
117
|
+
throw new Error('Expected totalSize and percent to be defined');
|
|
124
118
|
}
|
|
119
|
+
onProgress({
|
|
120
|
+
downloadedBytes: progress.downloaded,
|
|
121
|
+
totalSizeInBytes: progress.totalSize,
|
|
122
|
+
percent: progress.percent,
|
|
123
|
+
});
|
|
125
124
|
},
|
|
126
|
-
indent
|
|
127
|
-
logLevel
|
|
125
|
+
indent,
|
|
126
|
+
logLevel,
|
|
128
127
|
});
|
|
129
|
-
|
|
128
|
+
logger_1.Log.info({ indent, logLevel });
|
|
129
|
+
await (0, extract_zip_1.default)(archivePath, { dir: outputPath });
|
|
130
130
|
}
|
|
131
131
|
finally {
|
|
132
132
|
if (await existsAsync(archivePath)) {
|
|
@@ -134,7 +134,7 @@ const downloadBrowser = async (options) => {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
const revisionInfo = (0, exports.getRevisionInfo)();
|
|
137
|
-
|
|
137
|
+
(0, make_file_executable_1.makeFileExecutableIfItIsNot)(revisionInfo.executablePath);
|
|
138
138
|
return revisionInfo;
|
|
139
139
|
};
|
|
140
140
|
exports.downloadBrowser = downloadBrowser;
|
|
@@ -145,22 +145,16 @@ const getExecutablePath = () => {
|
|
|
145
145
|
const downloadsFolder = getDownloadsFolder();
|
|
146
146
|
const platform = getPlatform();
|
|
147
147
|
const folderPath = getFolderPath(downloadsFolder, platform);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return path.join(folderPath, `chrome-headless-shell-${platform}`, 'chrome-headless-shell');
|
|
152
|
-
}
|
|
153
|
-
if (platform === 'win64') {
|
|
154
|
-
return path.join(folderPath, `chrome-headless-shell-${platform}`, 'chrome-headless-shell.exe');
|
|
155
|
-
}
|
|
156
|
-
throw new Error('Can not download browser for platform: ' + platform);
|
|
148
|
+
return path.join(folderPath, `chrome-headless-shell-${platform}`, platform === 'win64'
|
|
149
|
+
? 'chrome-headless-shell.exe'
|
|
150
|
+
: 'chrome-headless-shell');
|
|
157
151
|
};
|
|
158
152
|
const getRevisionInfo = () => {
|
|
159
153
|
const executablePath = getExecutablePath();
|
|
160
154
|
const downloadsFolder = getDownloadsFolder();
|
|
161
155
|
const platform = getPlatform();
|
|
162
156
|
const folderPath = getFolderPath(downloadsFolder, platform);
|
|
163
|
-
const url = getChromeDownloadUrl(platform);
|
|
157
|
+
const url = getChromeDownloadUrl({ platform, version: null });
|
|
164
158
|
const local = fs.existsSync(folderPath);
|
|
165
159
|
return {
|
|
166
160
|
executablePath,
|
|
@@ -170,66 +164,3 @@ const getRevisionInfo = () => {
|
|
|
170
164
|
};
|
|
171
165
|
};
|
|
172
166
|
exports.getRevisionInfo = getRevisionInfo;
|
|
173
|
-
async function install({ archivePath, folderPath, }) {
|
|
174
|
-
if (archivePath.endsWith('.zip')) {
|
|
175
|
-
return (0, extract_zip_1.default)(archivePath, { dir: folderPath });
|
|
176
|
-
}
|
|
177
|
-
if (archivePath.endsWith('.dmg')) {
|
|
178
|
-
await mkdirAsync(folderPath);
|
|
179
|
-
return _installDMG(archivePath, folderPath);
|
|
180
|
-
}
|
|
181
|
-
throw new Error(`Unsupported archive format: ${archivePath}`);
|
|
182
|
-
}
|
|
183
|
-
function _installDMG(dmgPath, folderPath) {
|
|
184
|
-
let mountPath;
|
|
185
|
-
return new Promise((fulfill, reject) => {
|
|
186
|
-
const mountCommand = `hdiutil attach -nobrowse -noautoopen "${dmgPath}"`;
|
|
187
|
-
childProcess.exec(mountCommand, (err, stdout) => {
|
|
188
|
-
if (err) {
|
|
189
|
-
return reject(err);
|
|
190
|
-
}
|
|
191
|
-
const volumes = stdout.match(/\/Volumes\/(.*)/m);
|
|
192
|
-
if (!volumes) {
|
|
193
|
-
return reject(new Error(`Could not find volume path in ${stdout}`));
|
|
194
|
-
}
|
|
195
|
-
mountPath = volumes[0];
|
|
196
|
-
readdirAsync(mountPath)
|
|
197
|
-
.then((fileNames) => {
|
|
198
|
-
const appName = fileNames.find((item) => {
|
|
199
|
-
return typeof item === 'string' && item.endsWith('.app');
|
|
200
|
-
});
|
|
201
|
-
if (!appName) {
|
|
202
|
-
return reject(new Error(`Cannot find app in ${mountPath}`));
|
|
203
|
-
}
|
|
204
|
-
const copyPath = path.join(mountPath, appName);
|
|
205
|
-
childProcess.exec(`cp -R "${copyPath}" "${folderPath}"`, (_err) => {
|
|
206
|
-
if (_err) {
|
|
207
|
-
reject(_err);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
fulfill();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
})
|
|
214
|
-
.catch(reject);
|
|
215
|
-
});
|
|
216
|
-
})
|
|
217
|
-
.catch((error) => {
|
|
218
|
-
console.error(error);
|
|
219
|
-
})
|
|
220
|
-
.finally(() => {
|
|
221
|
-
if (!mountPath) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
const unmountCommand = `hdiutil detach "${mountPath}" -quiet`;
|
|
225
|
-
childProcess.exec(unmountCommand, (err) => {
|
|
226
|
-
if (err) {
|
|
227
|
-
console.error(`Error unmounting dmg: ${err}`);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
function toMegabytes(bytes) {
|
|
233
|
-
const mb = bytes / 1024 / 1024;
|
|
234
|
-
return `${Math.round(mb * 10) / 10} Mb`;
|
|
235
|
-
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LogLevel } from '../log-level';
|
|
2
|
+
import type { OnBrowserDownload } from '../options/on-browser-download';
|
|
3
|
+
export declare const defaultBrowserDownloadProgress: ({ indent, logLevel, api, }: {
|
|
4
|
+
indent: boolean;
|
|
5
|
+
logLevel: LogLevel;
|
|
6
|
+
api: string;
|
|
7
|
+
}) => OnBrowserDownload;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultBrowserDownloadProgress = void 0;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
|
+
const to_megabytes_1 = require("../to-megabytes");
|
|
6
|
+
const defaultBrowserDownloadProgress = ({ indent, logLevel, api, }) => () => {
|
|
7
|
+
logger_1.Log.info({ indent, logLevel }, 'No local browser could be found.');
|
|
8
|
+
logger_1.Log.info({ indent, logLevel }, 'Downloading Chrome Headless Shell https://www.remotion.dev/docs/miscellaneous/chrome-headless-shell');
|
|
9
|
+
logger_1.Log.info({ indent, logLevel }, `Customize this behavior by adding a onBrowserDownload function to ${api}.`);
|
|
10
|
+
return {
|
|
11
|
+
onProgress: (progress) => {
|
|
12
|
+
let lastProgress = 0;
|
|
13
|
+
if (progress.downloadedBytes > lastProgress + 10000000) {
|
|
14
|
+
lastProgress = progress.downloadedBytes;
|
|
15
|
+
logger_1.Log.info({ indent, logLevel }, `Downloading Chrome Headless Shell - ${(0, to_megabytes_1.toMegabytes)(progress.downloadedBytes)}/${(0, to_megabytes_1.toMegabytes)(progress.totalSizeInBytes)}`);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
version: null,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.defaultBrowserDownloadProgress = defaultBrowserDownloadProgress;
|
package/dist/client.d.ts
CHANGED
|
@@ -760,6 +760,16 @@ export declare const BrowserSafeApis: {
|
|
|
760
760
|
setConfig: (value: string | null) => void;
|
|
761
761
|
type: string | null;
|
|
762
762
|
};
|
|
763
|
+
onBrowserDownloadOption: {
|
|
764
|
+
name: string;
|
|
765
|
+
cliFlag: "on-browser-download";
|
|
766
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
767
|
+
ssrName: "onBrowserDownload";
|
|
768
|
+
docLink: string;
|
|
769
|
+
type: import(".").OnBrowserDownload;
|
|
770
|
+
getValue: () => never;
|
|
771
|
+
setConfig: () => never;
|
|
772
|
+
};
|
|
763
773
|
};
|
|
764
774
|
validColorSpaces: readonly ["default", "bt709", "bt2020-ncl"];
|
|
765
775
|
optionsMap: {
|
|
@@ -1067,6 +1077,16 @@ export declare const BrowserSafeApis: {
|
|
|
1067
1077
|
ssrName: "audioCodec";
|
|
1068
1078
|
type: "mp3" | "aac" | "pcm-16" | "opus";
|
|
1069
1079
|
};
|
|
1080
|
+
readonly onBrowserDownload: {
|
|
1081
|
+
name: string;
|
|
1082
|
+
cliFlag: "on-browser-download";
|
|
1083
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
1084
|
+
ssrName: "onBrowserDownload";
|
|
1085
|
+
docLink: string;
|
|
1086
|
+
type: import(".").OnBrowserDownload;
|
|
1087
|
+
getValue: () => never;
|
|
1088
|
+
setConfig: () => never;
|
|
1089
|
+
};
|
|
1070
1090
|
};
|
|
1071
1091
|
readonly stitchFramesToVideo: {
|
|
1072
1092
|
readonly separateAudioTo: {
|
|
@@ -1167,6 +1187,16 @@ export declare const BrowserSafeApis: {
|
|
|
1167
1187
|
};
|
|
1168
1188
|
setConfig: (value: string | null) => void;
|
|
1169
1189
|
};
|
|
1190
|
+
readonly onBrowserDownload: {
|
|
1191
|
+
name: string;
|
|
1192
|
+
cliFlag: "on-browser-download";
|
|
1193
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
1194
|
+
ssrName: "onBrowserDownload";
|
|
1195
|
+
docLink: string;
|
|
1196
|
+
type: import(".").OnBrowserDownload;
|
|
1197
|
+
getValue: () => never;
|
|
1198
|
+
setConfig: () => never;
|
|
1199
|
+
};
|
|
1170
1200
|
};
|
|
1171
1201
|
readonly getCompositions: {
|
|
1172
1202
|
readonly offthreadVideoCacheSizeInBytes: {
|
|
@@ -1232,6 +1262,16 @@ export declare const BrowserSafeApis: {
|
|
|
1232
1262
|
};
|
|
1233
1263
|
setConfig: (value: string | null) => void;
|
|
1234
1264
|
};
|
|
1265
|
+
readonly onBrowserDownload: {
|
|
1266
|
+
name: string;
|
|
1267
|
+
cliFlag: "on-browser-download";
|
|
1268
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
1269
|
+
ssrName: "onBrowserDownload";
|
|
1270
|
+
docLink: string;
|
|
1271
|
+
type: import(".").OnBrowserDownload;
|
|
1272
|
+
getValue: () => never;
|
|
1273
|
+
setConfig: () => never;
|
|
1274
|
+
};
|
|
1235
1275
|
};
|
|
1236
1276
|
readonly selectComposition: {
|
|
1237
1277
|
readonly offthreadVideoCacheSizeInBytes: {
|
|
@@ -1297,6 +1337,16 @@ export declare const BrowserSafeApis: {
|
|
|
1297
1337
|
};
|
|
1298
1338
|
setConfig: (value: string | null) => void;
|
|
1299
1339
|
};
|
|
1340
|
+
readonly onBrowserDownload: {
|
|
1341
|
+
name: string;
|
|
1342
|
+
cliFlag: "on-browser-download";
|
|
1343
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
1344
|
+
ssrName: "onBrowserDownload";
|
|
1345
|
+
docLink: string;
|
|
1346
|
+
type: import(".").OnBrowserDownload;
|
|
1347
|
+
getValue: () => never;
|
|
1348
|
+
setConfig: () => never;
|
|
1349
|
+
};
|
|
1300
1350
|
};
|
|
1301
1351
|
readonly renderFrames: {
|
|
1302
1352
|
readonly forSeamlessAacConcatenation: {
|
|
@@ -1395,6 +1445,16 @@ export declare const BrowserSafeApis: {
|
|
|
1395
1445
|
};
|
|
1396
1446
|
setConfig: (value: string | null) => void;
|
|
1397
1447
|
};
|
|
1448
|
+
readonly onBrowserDownload: {
|
|
1449
|
+
name: string;
|
|
1450
|
+
cliFlag: "on-browser-download";
|
|
1451
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
1452
|
+
ssrName: "onBrowserDownload";
|
|
1453
|
+
docLink: string;
|
|
1454
|
+
type: import(".").OnBrowserDownload;
|
|
1455
|
+
getValue: () => never;
|
|
1456
|
+
setConfig: () => never;
|
|
1457
|
+
};
|
|
1398
1458
|
};
|
|
1399
1459
|
readonly renderMediaOnLambda: {
|
|
1400
1460
|
readonly offthreadVideoCacheSizeInBytes: {
|
|
@@ -2111,6 +2171,33 @@ export declare const BrowserSafeApis: {
|
|
|
2111
2171
|
setConfig: (value: number) => void;
|
|
2112
2172
|
};
|
|
2113
2173
|
};
|
|
2174
|
+
readonly ensureBrowser: {
|
|
2175
|
+
readonly logLevel: {
|
|
2176
|
+
cliFlag: "log";
|
|
2177
|
+
name: string;
|
|
2178
|
+
ssrName: string;
|
|
2179
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
2180
|
+
docLink: string;
|
|
2181
|
+
getValue: ({ commandLine }: {
|
|
2182
|
+
commandLine: Record<string, unknown>;
|
|
2183
|
+
}) => {
|
|
2184
|
+
value: "verbose" | "info" | "warn" | "error";
|
|
2185
|
+
source: string;
|
|
2186
|
+
};
|
|
2187
|
+
setConfig: (newLogLevel: "verbose" | "info" | "warn" | "error") => void;
|
|
2188
|
+
type: "verbose" | "info" | "warn" | "error";
|
|
2189
|
+
};
|
|
2190
|
+
readonly onBrowserDownload: {
|
|
2191
|
+
name: string;
|
|
2192
|
+
cliFlag: "on-browser-download";
|
|
2193
|
+
description: () => import("react/jsx-runtime").JSX.Element;
|
|
2194
|
+
ssrName: "onBrowserDownload";
|
|
2195
|
+
docLink: string;
|
|
2196
|
+
type: import(".").OnBrowserDownload;
|
|
2197
|
+
getValue: () => never;
|
|
2198
|
+
setConfig: () => never;
|
|
2199
|
+
};
|
|
2200
|
+
};
|
|
2114
2201
|
};
|
|
2115
2202
|
codecSupportsCrf: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "h264-ts" | "gif") => boolean;
|
|
2116
2203
|
codecSupportsVideoBitrate: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "h264-ts" | "gif") => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BrowserExecutable } from './browser-executable';
|
|
2
|
+
import type { BrowserSafeApis } from './client';
|
|
3
|
+
import type { ToOptions } from './options/option';
|
|
4
|
+
export type BrowserStatus = {
|
|
5
|
+
type: 'user-defined-path';
|
|
6
|
+
path: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'local-browser';
|
|
9
|
+
path: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'local-puppeteer-browser';
|
|
12
|
+
path: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'no-browser';
|
|
15
|
+
};
|
|
16
|
+
type InternalEnsureBrowserOptions = {
|
|
17
|
+
browserExecutable: BrowserExecutable;
|
|
18
|
+
indent: boolean;
|
|
19
|
+
} & ToOptions<typeof BrowserSafeApis.optionsMap.ensureBrowser>;
|
|
20
|
+
export type EnsureBrowserOptions = Partial<{
|
|
21
|
+
browserExecutable: BrowserExecutable;
|
|
22
|
+
} & ToOptions<typeof BrowserSafeApis.optionsMap.ensureBrowser>>;
|
|
23
|
+
export declare const internalEnsureBrowser: ({ indent, logLevel, browserExecutable, onBrowserDownload, }: InternalEnsureBrowserOptions) => Promise<BrowserStatus>;
|
|
24
|
+
export declare const ensureBrowser: (options?: EnsureBrowserOptions) => Promise<BrowserStatus>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ensureBrowser = exports.internalEnsureBrowser = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const browser_download_progress_bar_1 = require("./browser/browser-download-progress-bar");
|
|
9
|
+
const BrowserFetcher_1 = require("./browser/BrowserFetcher");
|
|
10
|
+
const get_local_browser_1 = require("./get-local-browser");
|
|
11
|
+
const internalEnsureBrowser = async ({ indent, logLevel, browserExecutable, onBrowserDownload, }) => {
|
|
12
|
+
const status = getBrowserStatus(browserExecutable);
|
|
13
|
+
if (status.type === 'no-browser') {
|
|
14
|
+
const { onProgress, version } = onBrowserDownload();
|
|
15
|
+
await (0, BrowserFetcher_1.downloadBrowser)({ indent, logLevel, onProgress, version });
|
|
16
|
+
}
|
|
17
|
+
const newStatus = getBrowserStatus(browserExecutable);
|
|
18
|
+
return newStatus;
|
|
19
|
+
};
|
|
20
|
+
exports.internalEnsureBrowser = internalEnsureBrowser;
|
|
21
|
+
const getBrowserStatus = (browserExecutable) => {
|
|
22
|
+
if (browserExecutable) {
|
|
23
|
+
if (!fs_1.default.existsSync(browserExecutable)) {
|
|
24
|
+
throw new Error(`"browserExecutable" was specified as '${browserExecutable}' but the path doesn't exist. Pass "null" for "browserExecutable" to download a browser automatically.`);
|
|
25
|
+
}
|
|
26
|
+
return { path: browserExecutable, type: 'user-defined-path' };
|
|
27
|
+
}
|
|
28
|
+
const localBrowser = (0, get_local_browser_1.getLocalBrowser)();
|
|
29
|
+
if (localBrowser !== null) {
|
|
30
|
+
return { path: localBrowser, type: 'local-browser' };
|
|
31
|
+
}
|
|
32
|
+
const revision = (0, BrowserFetcher_1.getRevisionInfo)();
|
|
33
|
+
if (revision.local && fs_1.default.existsSync(revision.executablePath)) {
|
|
34
|
+
return { path: revision.executablePath, type: 'local-puppeteer-browser' };
|
|
35
|
+
}
|
|
36
|
+
return { type: 'no-browser' };
|
|
37
|
+
};
|
|
38
|
+
const ensureBrowser = (options) => {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
const indent = false;
|
|
41
|
+
const logLevel = (_a = options === null || options === void 0 ? void 0 : options.logLevel) !== null && _a !== void 0 ? _a : 'info';
|
|
42
|
+
return (0, exports.internalEnsureBrowser)({
|
|
43
|
+
browserExecutable: (_b = options === null || options === void 0 ? void 0 : options.browserExecutable) !== null && _b !== void 0 ? _b : null,
|
|
44
|
+
indent,
|
|
45
|
+
logLevel: (_c = options === null || options === void 0 ? void 0 : options.logLevel) !== null && _c !== void 0 ? _c : 'info',
|
|
46
|
+
onBrowserDownload: (_d = options === null || options === void 0 ? void 0 : options.onBrowserDownload) !== null && _d !== void 0 ? _d : (0, browser_download_progress_bar_1.defaultBrowserDownloadProgress)({
|
|
47
|
+
api: 'ensureBrowser()',
|
|
48
|
+
indent: false,
|
|
49
|
+
logLevel,
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.ensureBrowser = ensureBrowser;
|
|
@@ -3,13 +3,15 @@ import type { HeadlessBrowser } from './browser/Browser';
|
|
|
3
3
|
import type { Page } from './browser/BrowserPage';
|
|
4
4
|
import type { LogLevel } from './log-level';
|
|
5
5
|
import type { ChromiumOptions } from './open-browser';
|
|
6
|
-
|
|
6
|
+
import type { OnBrowserDownload } from './options/on-browser-download';
|
|
7
|
+
export declare const getPageAndCleanupFn: ({ passedInInstance, browserExecutable, chromiumOptions, forceDeviceScaleFactor, indent, logLevel, onBrowserDownload, }: {
|
|
7
8
|
passedInInstance: HeadlessBrowser | undefined;
|
|
8
9
|
browserExecutable: BrowserExecutable | null;
|
|
9
10
|
chromiumOptions: ChromiumOptions;
|
|
10
11
|
indent: boolean;
|
|
11
12
|
forceDeviceScaleFactor: number | undefined;
|
|
12
13
|
logLevel: LogLevel;
|
|
14
|
+
onBrowserDownload: OnBrowserDownload;
|
|
13
15
|
}) => Promise<{
|
|
14
16
|
cleanup: () => Promise<void>;
|
|
15
17
|
page: Page;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPageAndCleanupFn = void 0;
|
|
4
4
|
const browser_1 = require("./browser");
|
|
5
5
|
const open_browser_1 = require("./open-browser");
|
|
6
|
-
const getPageAndCleanupFn = async ({ passedInInstance, browserExecutable, chromiumOptions, forceDeviceScaleFactor, indent, logLevel, }) => {
|
|
6
|
+
const getPageAndCleanupFn = async ({ passedInInstance, browserExecutable, chromiumOptions, forceDeviceScaleFactor, indent, logLevel, onBrowserDownload, }) => {
|
|
7
7
|
if (passedInInstance) {
|
|
8
8
|
const page = await passedInInstance.newPage(() => null, logLevel, indent);
|
|
9
9
|
return {
|
|
@@ -26,6 +26,7 @@ const getPageAndCleanupFn = async ({ passedInInstance, browserExecutable, chromi
|
|
|
26
26
|
indent,
|
|
27
27
|
viewport: null,
|
|
28
28
|
logLevel,
|
|
29
|
+
onBrowserDownload,
|
|
29
30
|
});
|
|
30
31
|
const browserPage = await browserInstance.newPage(() => null, logLevel, indent);
|
|
31
32
|
return {
|
package/dist/get-compositions.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCompositions = exports.internalGetCompositions = void 0;
|
|
4
4
|
const no_react_1 = require("remotion/no-react");
|
|
5
|
+
const browser_download_progress_bar_1 = require("./browser/browser-download-progress-bar");
|
|
5
6
|
const TimeoutSettings_1 = require("./browser/TimeoutSettings");
|
|
6
7
|
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
7
8
|
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
@@ -79,7 +80,7 @@ const innerGetCompositions = async ({ envVariables, serializedInputPropsWithCust
|
|
|
79
80
|
};
|
|
80
81
|
});
|
|
81
82
|
};
|
|
82
|
-
const internalGetCompositionsRaw = async ({ browserExecutable, chromiumOptions, envVariables, indent, serializedInputPropsWithCustomSchema, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds, logLevel, offthreadVideoCacheSizeInBytes, binariesDirectory, }) => {
|
|
83
|
+
const internalGetCompositionsRaw = async ({ browserExecutable, chromiumOptions, envVariables, indent, serializedInputPropsWithCustomSchema, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds, logLevel, offthreadVideoCacheSizeInBytes, binariesDirectory, onBrowserDownload, }) => {
|
|
83
84
|
const { page, cleanup: cleanupPage } = await (0, get_browser_instance_1.getPageAndCleanupFn)({
|
|
84
85
|
passedInInstance: puppeteerInstance,
|
|
85
86
|
browserExecutable,
|
|
@@ -87,6 +88,7 @@ const internalGetCompositionsRaw = async ({ browserExecutable, chromiumOptions,
|
|
|
87
88
|
forceDeviceScaleFactor: undefined,
|
|
88
89
|
indent,
|
|
89
90
|
logLevel,
|
|
91
|
+
onBrowserDownload,
|
|
90
92
|
});
|
|
91
93
|
const cleanup = [cleanupPage];
|
|
92
94
|
return new Promise((resolve, reject) => {
|
|
@@ -127,6 +129,7 @@ const internalGetCompositionsRaw = async ({ browserExecutable, chromiumOptions,
|
|
|
127
129
|
logLevel,
|
|
128
130
|
offthreadVideoCacheSizeInBytes,
|
|
129
131
|
binariesDirectory,
|
|
132
|
+
onBrowserDownload,
|
|
130
133
|
});
|
|
131
134
|
})
|
|
132
135
|
.then((comp) => {
|
|
@@ -148,11 +151,12 @@ exports.internalGetCompositions = (0, wrap_with_error_handling_1.wrapWithErrorHa
|
|
|
148
151
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/get-compositions)
|
|
149
152
|
*/
|
|
150
153
|
const getCompositions = (serveUrlOrWebpackUrl, config) => {
|
|
151
|
-
var _a, _b;
|
|
152
154
|
if (!serveUrlOrWebpackUrl) {
|
|
153
155
|
throw new Error('No serve URL or webpack bundle directory was passed to getCompositions().');
|
|
154
156
|
}
|
|
155
|
-
const { browserExecutable, chromiumOptions, envVariables, inputProps, onBrowserLog, port, puppeteerInstance, timeoutInMilliseconds, logLevel, } = config !== null && config !== void 0 ? config : {};
|
|
157
|
+
const { browserExecutable, chromiumOptions, envVariables, inputProps, onBrowserLog, port, puppeteerInstance, timeoutInMilliseconds, logLevel: passedLogLevel, onBrowserDownload, binariesDirectory, offthreadVideoCacheSizeInBytes, } = config !== null && config !== void 0 ? config : {};
|
|
158
|
+
const indent = false;
|
|
159
|
+
const logLevel = passedLogLevel !== null && passedLogLevel !== void 0 ? passedLogLevel : 'info';
|
|
156
160
|
return (0, exports.internalGetCompositions)({
|
|
157
161
|
browserExecutable: browserExecutable !== null && browserExecutable !== void 0 ? browserExecutable : null,
|
|
158
162
|
chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
|
|
@@ -162,16 +166,21 @@ const getCompositions = (serveUrlOrWebpackUrl, config) => {
|
|
|
162
166
|
indent: undefined,
|
|
163
167
|
staticBase: null,
|
|
164
168
|
}).serializedString,
|
|
165
|
-
indent
|
|
169
|
+
indent,
|
|
166
170
|
onBrowserLog: onBrowserLog !== null && onBrowserLog !== void 0 ? onBrowserLog : null,
|
|
167
171
|
port: port !== null && port !== void 0 ? port : null,
|
|
168
172
|
puppeteerInstance: puppeteerInstance !== null && puppeteerInstance !== void 0 ? puppeteerInstance : undefined,
|
|
169
173
|
serveUrlOrWebpackUrl,
|
|
170
174
|
server: undefined,
|
|
171
175
|
timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : TimeoutSettings_1.DEFAULT_TIMEOUT,
|
|
172
|
-
logLevel
|
|
173
|
-
offthreadVideoCacheSizeInBytes:
|
|
174
|
-
binariesDirectory:
|
|
176
|
+
logLevel,
|
|
177
|
+
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
|
|
178
|
+
binariesDirectory: binariesDirectory !== null && binariesDirectory !== void 0 ? binariesDirectory : null,
|
|
179
|
+
onBrowserDownload: onBrowserDownload !== null && onBrowserDownload !== void 0 ? onBrowserDownload : (0, browser_download_progress_bar_1.defaultBrowserDownloadProgress)({
|
|
180
|
+
indent,
|
|
181
|
+
logLevel,
|
|
182
|
+
api: 'getCompositions()',
|
|
183
|
+
}),
|
|
175
184
|
});
|
|
176
185
|
};
|
|
177
186
|
exports.getCompositions = getCompositions;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import type { BrowserExecutable } from './browser-executable';
|
|
2
|
-
import type { LogLevel } from './log-level';
|
|
3
|
-
export declare const ensureLocalBrowser: ({ indent, logLevel, preferredBrowserExecutable, }: {
|
|
4
|
-
preferredBrowserExecutable: BrowserExecutable;
|
|
5
|
-
logLevel: LogLevel;
|
|
6
|
-
indent: boolean;
|
|
7
|
-
}) => Promise<void>;
|
|
8
2
|
export declare const getLocalBrowserExecutable: (preferredBrowserExecutable: BrowserExecutable) => string;
|