@remotion/renderer 3.2.25 → 3.2.27
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/BrowserRunner.d.ts +1 -4
- package/dist/browser/BrowserRunner.js +28 -71
- package/dist/browser/LaunchOptions.d.ts +0 -4
- package/dist/browser/Launcher.d.ts +1 -1
- package/dist/browser/Launcher.js +5 -363
- package/dist/browser/PuppeteerNode.js +1 -4
- package/dist/browser/create-browser-fetcher.js +2 -44
- package/dist/browser/revisions.d.ts +0 -1
- package/dist/browser/revisions.js +0 -1
- package/dist/convert-to-positive-frame-index.d.ts +4 -0
- package/dist/convert-to-positive-frame-index.js +8 -0
- package/dist/get-local-browser-executable.js +1 -3
- package/dist/index.d.ts +11 -6
- package/dist/index.js +2 -0
- package/dist/open-browser.js +1 -11
- package/dist/render-media.js +4 -0
- package/dist/render-still.js +8 -3
- package/dist/set-props-and-env.js +1 -1
- package/dist/validate-frame.js +3 -3
- package/package.json +3 -3
|
@@ -17,17 +17,14 @@
|
|
|
17
17
|
import * as childProcess from 'child_process';
|
|
18
18
|
import { Connection } from './Connection';
|
|
19
19
|
import type { LaunchOptions } from './LaunchOptions';
|
|
20
|
-
import type { Product } from './Product';
|
|
21
20
|
export declare class BrowserRunner {
|
|
22
21
|
#private;
|
|
23
22
|
proc?: childProcess.ChildProcess;
|
|
24
23
|
connection?: Connection;
|
|
25
|
-
constructor({
|
|
26
|
-
product: Product;
|
|
24
|
+
constructor({ executablePath, processArguments, userDataDir, }: {
|
|
27
25
|
executablePath: string;
|
|
28
26
|
processArguments: string[];
|
|
29
27
|
userDataDir: string;
|
|
30
|
-
isTempUserDataDir?: boolean;
|
|
31
28
|
});
|
|
32
29
|
start(options: LaunchOptions): void;
|
|
33
30
|
close(): Promise<void>;
|
|
@@ -48,45 +48,37 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
48
48
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
49
49
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
50
50
|
};
|
|
51
|
-
var
|
|
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
54
|
const childProcess = __importStar(require("child_process"));
|
|
55
55
|
const fs = __importStar(require("fs"));
|
|
56
|
-
const path = __importStar(require("path"));
|
|
57
56
|
const readline = __importStar(require("readline"));
|
|
58
|
-
const util_1 = require("util");
|
|
59
57
|
const delete_directory_1 = require("../delete-directory");
|
|
60
58
|
const assert_1 = require("./assert");
|
|
61
59
|
const Connection_1 = require("./Connection");
|
|
62
60
|
const Errors_1 = require("./Errors");
|
|
63
61
|
const NodeWebSocketTransport_1 = require("./NodeWebSocketTransport");
|
|
64
|
-
const
|
|
65
|
-
const renameAsync = (0, util_1.promisify)(fs.rename);
|
|
66
|
-
const unlinkAsync = (0, util_1.promisify)(fs.unlink);
|
|
62
|
+
const util_1 = require("./util");
|
|
67
63
|
const PROCESS_ERROR_EXPLANATION = `Puppeteer was unable to kill the process which ran the browser binary.
|
|
68
64
|
This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.
|
|
69
65
|
Please check your open processes and ensure that the browser processes that Puppeteer launched have been killed.
|
|
70
66
|
If you think this is a bug, please report it on the Puppeteer issue tracker.`;
|
|
71
67
|
class BrowserRunner {
|
|
72
|
-
constructor({
|
|
73
|
-
_BrowserRunner_product.set(this, void 0);
|
|
68
|
+
constructor({ executablePath, processArguments, userDataDir, }) {
|
|
74
69
|
_BrowserRunner_executablePath.set(this, void 0);
|
|
75
70
|
_BrowserRunner_processArguments.set(this, void 0);
|
|
76
71
|
_BrowserRunner_userDataDir.set(this, void 0);
|
|
77
|
-
_BrowserRunner_isTempUserDataDir.set(this, void 0);
|
|
78
72
|
_BrowserRunner_closed.set(this, true);
|
|
79
73
|
_BrowserRunner_listeners.set(this, []);
|
|
80
74
|
_BrowserRunner_processClosing.set(this, void 0);
|
|
81
|
-
__classPrivateFieldSet(this, _BrowserRunner_product, product, "f");
|
|
82
75
|
__classPrivateFieldSet(this, _BrowserRunner_executablePath, executablePath, "f");
|
|
83
76
|
__classPrivateFieldSet(this, _BrowserRunner_processArguments, processArguments, "f");
|
|
84
77
|
__classPrivateFieldSet(this, _BrowserRunner_userDataDir, userDataDir, "f");
|
|
85
|
-
__classPrivateFieldSet(this, _BrowserRunner_isTempUserDataDir, isTempUserDataDir, "f");
|
|
86
78
|
}
|
|
87
79
|
start(options) {
|
|
88
80
|
var _a, _b;
|
|
89
|
-
const {
|
|
81
|
+
const { dumpio, env, pipe } = options;
|
|
90
82
|
let stdio;
|
|
91
83
|
if (pipe) {
|
|
92
84
|
if (dumpio) {
|
|
@@ -121,66 +113,33 @@ class BrowserRunner {
|
|
|
121
113
|
this.proc.once('exit', async () => {
|
|
122
114
|
__classPrivateFieldSet(this, _BrowserRunner_closed, true, "f");
|
|
123
115
|
// Cleanup as processes exit.
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
try {
|
|
117
|
+
if (fs.existsSync(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"))) {
|
|
126
118
|
await (0, delete_directory_1.deleteDirectory)(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"));
|
|
127
|
-
fulfill();
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
reject(error);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
if (__classPrivateFieldGet(this, _BrowserRunner_product, "f") === 'firefox') {
|
|
135
|
-
try {
|
|
136
|
-
// When an existing user profile has been used remove the user
|
|
137
|
-
// preferences file and restore possibly backuped preferences.
|
|
138
|
-
await unlinkAsync(path.join(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"), 'user.js'));
|
|
139
|
-
const prefsBackupPath = path.join(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"), 'prefs.js.puppeteer');
|
|
140
|
-
if (fs.existsSync(prefsBackupPath)) {
|
|
141
|
-
const prefsPath = path.join(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"), 'prefs.js');
|
|
142
|
-
await unlinkAsync(prefsPath);
|
|
143
|
-
await renameAsync(prefsBackupPath, prefsPath);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
reject(error);
|
|
148
|
-
}
|
|
149
119
|
}
|
|
150
120
|
fulfill();
|
|
151
121
|
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
reject(error);
|
|
124
|
+
}
|
|
152
125
|
});
|
|
153
126
|
}), "f");
|
|
154
|
-
__classPrivateFieldSet(this, _BrowserRunner_listeners, [(0,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (handleSIGTERM) {
|
|
162
|
-
__classPrivateFieldGet(this, _BrowserRunner_listeners, "f").push((0, util_2.addEventListener)(process, 'SIGTERM', this.close.bind(this)));
|
|
163
|
-
}
|
|
164
|
-
if (handleSIGHUP) {
|
|
165
|
-
__classPrivateFieldGet(this, _BrowserRunner_listeners, "f").push((0, util_2.addEventListener)(process, 'SIGHUP', this.close.bind(this)));
|
|
166
|
-
}
|
|
127
|
+
__classPrivateFieldSet(this, _BrowserRunner_listeners, [(0, util_1.addEventListener)(process, 'exit', this.kill.bind(this))], "f");
|
|
128
|
+
__classPrivateFieldGet(this, _BrowserRunner_listeners, "f").push((0, util_1.addEventListener)(process, 'SIGINT', () => {
|
|
129
|
+
this.kill();
|
|
130
|
+
process.exit(130);
|
|
131
|
+
}));
|
|
132
|
+
__classPrivateFieldGet(this, _BrowserRunner_listeners, "f").push((0, util_1.addEventListener)(process, 'SIGTERM', this.close.bind(this)));
|
|
133
|
+
__classPrivateFieldGet(this, _BrowserRunner_listeners, "f").push((0, util_1.addEventListener)(process, 'SIGHUP', this.close.bind(this)));
|
|
167
134
|
}
|
|
168
135
|
close() {
|
|
169
136
|
if (__classPrivateFieldGet(this, _BrowserRunner_closed, "f")) {
|
|
170
137
|
return Promise.resolve();
|
|
171
138
|
}
|
|
172
|
-
|
|
173
|
-
this.kill();
|
|
174
|
-
}
|
|
175
|
-
else if (this.connection) {
|
|
176
|
-
// Attempt to close the browser gracefully
|
|
177
|
-
this.connection.send('Browser.close').catch(() => {
|
|
178
|
-
this.kill();
|
|
179
|
-
});
|
|
180
|
-
}
|
|
139
|
+
this.kill();
|
|
181
140
|
// Cleanup this listener last, as that makes sure the full callback runs. If we
|
|
182
141
|
// perform this earlier, then the previous function calls would not happen.
|
|
183
|
-
(0,
|
|
142
|
+
(0, util_1.removeEventListeners)(__classPrivateFieldGet(this, _BrowserRunner_listeners, "f"));
|
|
184
143
|
return __classPrivateFieldGet(this, _BrowserRunner_processClosing, "f");
|
|
185
144
|
}
|
|
186
145
|
kill() {
|
|
@@ -217,19 +176,17 @@ class BrowserRunner {
|
|
|
217
176
|
}
|
|
218
177
|
}
|
|
219
178
|
catch (error) {
|
|
220
|
-
throw new Error(`${PROCESS_ERROR_EXPLANATION}\nError cause: ${(0,
|
|
179
|
+
throw new Error(`${PROCESS_ERROR_EXPLANATION}\nError cause: ${(0, util_1.isErrorLike)(error) ? error.stack : error}`);
|
|
221
180
|
}
|
|
222
181
|
}
|
|
223
182
|
// Attempt to remove temporary profile directory to avoid littering.
|
|
224
183
|
try {
|
|
225
|
-
|
|
226
|
-
fs.rmSync(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"), { recursive: true, force: true });
|
|
227
|
-
}
|
|
184
|
+
fs.rmSync(__classPrivateFieldGet(this, _BrowserRunner_userDataDir, "f"), { recursive: true, force: true });
|
|
228
185
|
}
|
|
229
186
|
catch (error) { }
|
|
230
187
|
// Cleanup this listener last, as that makes sure the full callback runs. If we
|
|
231
188
|
// perform this earlier, then the previous function calls would not happen.
|
|
232
|
-
(0,
|
|
189
|
+
(0, util_1.removeEventListeners)(__classPrivateFieldGet(this, _BrowserRunner_listeners, "f"));
|
|
233
190
|
}
|
|
234
191
|
async setupConnection(options) {
|
|
235
192
|
(0, assert_1.assert)(this.proc, 'BrowserRunner not started.');
|
|
@@ -241,21 +198,21 @@ class BrowserRunner {
|
|
|
241
198
|
}
|
|
242
199
|
}
|
|
243
200
|
exports.BrowserRunner = BrowserRunner;
|
|
244
|
-
|
|
201
|
+
_BrowserRunner_executablePath = new WeakMap(), _BrowserRunner_processArguments = new WeakMap(), _BrowserRunner_userDataDir = new WeakMap(), _BrowserRunner_closed = new WeakMap(), _BrowserRunner_listeners = new WeakMap(), _BrowserRunner_processClosing = new WeakMap();
|
|
245
202
|
function waitForWSEndpoint(browserProcess, timeout, preferredRevision) {
|
|
246
203
|
(0, assert_1.assert)(browserProcess.stderr, '`browserProcess` does not have stderr.');
|
|
247
204
|
const rl = readline.createInterface(browserProcess.stderr);
|
|
248
205
|
let stderr = '';
|
|
249
206
|
return new Promise((resolve, reject) => {
|
|
250
207
|
const listeners = [
|
|
251
|
-
(0,
|
|
252
|
-
(0,
|
|
208
|
+
(0, util_1.addEventListener)(rl, 'line', onLine),
|
|
209
|
+
(0, util_1.addEventListener)(rl, 'close', () => {
|
|
253
210
|
return onClose();
|
|
254
211
|
}),
|
|
255
|
-
(0,
|
|
212
|
+
(0, util_1.addEventListener)(browserProcess, 'exit', () => {
|
|
256
213
|
return onClose();
|
|
257
214
|
}),
|
|
258
|
-
(0,
|
|
215
|
+
(0, util_1.addEventListener)(browserProcess, 'error', (error) => {
|
|
259
216
|
return onClose(error);
|
|
260
217
|
}),
|
|
261
218
|
];
|
|
@@ -289,7 +246,7 @@ function waitForWSEndpoint(browserProcess, timeout, preferredRevision) {
|
|
|
289
246
|
if (timeoutId) {
|
|
290
247
|
clearTimeout(timeoutId);
|
|
291
248
|
}
|
|
292
|
-
(0,
|
|
249
|
+
(0, util_1.removeEventListeners)(listeners);
|
|
293
250
|
}
|
|
294
251
|
});
|
|
295
252
|
}
|
|
@@ -298,7 +255,7 @@ function pidExists(pid) {
|
|
|
298
255
|
return process.kill(pid, 0);
|
|
299
256
|
}
|
|
300
257
|
catch (error) {
|
|
301
|
-
if ((0,
|
|
258
|
+
if ((0, util_1.isErrnoException)(error)) {
|
|
302
259
|
if (error.code && error.code === 'ESRCH') {
|
|
303
260
|
return false;
|
|
304
261
|
}
|
|
@@ -24,14 +24,10 @@ export interface BrowserLaunchArgumentOptions {
|
|
|
24
24
|
}
|
|
25
25
|
export interface LaunchOptions {
|
|
26
26
|
executablePath?: string;
|
|
27
|
-
handleSIGINT?: boolean;
|
|
28
|
-
handleSIGTERM?: boolean;
|
|
29
|
-
handleSIGHUP?: boolean;
|
|
30
27
|
timeout?: number;
|
|
31
28
|
dumpio?: boolean;
|
|
32
29
|
env?: Record<string, string | undefined>;
|
|
33
30
|
pipe?: boolean;
|
|
34
31
|
product?: Product;
|
|
35
|
-
extraPrefsFirefox?: Record<string, unknown>;
|
|
36
32
|
}
|
|
37
33
|
export declare type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions & LaunchOptions & BrowserConnectOptions;
|
|
@@ -6,4 +6,4 @@ export interface ProductLauncher {
|
|
|
6
6
|
executablePath: (path?: any) => string;
|
|
7
7
|
product: Product;
|
|
8
8
|
}
|
|
9
|
-
export default function Launcher(preferredRevision: string
|
|
9
|
+
export default function Launcher(preferredRevision: string): ProductLauncher;
|
package/dist/browser/Launcher.js
CHANGED
|
@@ -45,9 +45,7 @@ const assert_1 = require("./assert");
|
|
|
45
45
|
const Browser_1 = require("./Browser");
|
|
46
46
|
const BrowserFetcher_1 = require("./BrowserFetcher");
|
|
47
47
|
const BrowserRunner_1 = require("./BrowserRunner");
|
|
48
|
-
const copyFileAsync = fs.promises.copyFile;
|
|
49
48
|
const mkdtempAsync = fs.promises.mkdtemp;
|
|
50
|
-
const writeFileAsync = fs.promises.writeFile;
|
|
51
49
|
const tmpDir = () => {
|
|
52
50
|
return process.env.PUPPETEER_TMP_DIR || os.tmpdir();
|
|
53
51
|
};
|
|
@@ -56,7 +54,7 @@ class ChromeLauncher {
|
|
|
56
54
|
this._preferredRevision = preferredRevision;
|
|
57
55
|
}
|
|
58
56
|
async launch(options) {
|
|
59
|
-
const { args = [], dumpio = false, executablePath, pipe = false, env = process.env,
|
|
57
|
+
const { args = [], dumpio = false, executablePath, pipe = false, env = process.env, defaultViewport, timeout = 60000, debuggingPort, } = options;
|
|
60
58
|
const chromeArguments = args;
|
|
61
59
|
if (!chromeArguments.some((argument) => {
|
|
62
60
|
return argument.startsWith('--remote-debugging-');
|
|
@@ -69,19 +67,10 @@ class ChromeLauncher {
|
|
|
69
67
|
chromeArguments.push(`--remote-debugging-port=${debuggingPort || 0}`);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
let isTempUserDataDir = true;
|
|
73
70
|
// Check for the user data dir argument, which will always be set even
|
|
74
71
|
// with a custom directory specified via the userDataDir option.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
if (userDataDirIndex < 0) {
|
|
79
|
-
chromeArguments.push(`--user-data-dir=${await mkdtempAsync(path.join(tmpDir(), 'puppeteer_dev_chrome_profile-'))}`);
|
|
80
|
-
userDataDirIndex = chromeArguments.length - 1;
|
|
81
|
-
}
|
|
82
|
-
const userDataDir = chromeArguments[userDataDirIndex].split('=', 2)[1];
|
|
83
|
-
(0, assert_1.assert)(typeof userDataDir === 'string', '`--user-data-dir` is malformed');
|
|
84
|
-
isTempUserDataDir = false;
|
|
72
|
+
const userDataDir = await mkdtempAsync(path.join(tmpDir(), 'puppeteer_dev_chrome_profile-'));
|
|
73
|
+
chromeArguments.push(`--user-data-dir=${userDataDir}`);
|
|
85
74
|
let chromeExecutable = executablePath;
|
|
86
75
|
if (!chromeExecutable) {
|
|
87
76
|
const { missingText, executablePath: exPath } = resolveExecutablePath(this);
|
|
@@ -91,16 +80,11 @@ class ChromeLauncher {
|
|
|
91
80
|
chromeExecutable = exPath;
|
|
92
81
|
}
|
|
93
82
|
const runner = new BrowserRunner_1.BrowserRunner({
|
|
94
|
-
product: this.product,
|
|
95
83
|
executablePath: chromeExecutable,
|
|
96
84
|
processArguments: chromeArguments,
|
|
97
85
|
userDataDir,
|
|
98
|
-
isTempUserDataDir,
|
|
99
86
|
});
|
|
100
87
|
runner.start({
|
|
101
|
-
handleSIGHUP,
|
|
102
|
-
handleSIGTERM,
|
|
103
|
-
handleSIGINT,
|
|
104
88
|
dumpio,
|
|
105
89
|
env,
|
|
106
90
|
pipe: false,
|
|
@@ -141,335 +125,6 @@ class ChromeLauncher {
|
|
|
141
125
|
return 'chrome';
|
|
142
126
|
}
|
|
143
127
|
}
|
|
144
|
-
class FirefoxLauncher {
|
|
145
|
-
constructor(preferredRevision) {
|
|
146
|
-
this._preferredRevision = preferredRevision;
|
|
147
|
-
}
|
|
148
|
-
async launch(options) {
|
|
149
|
-
const { dumpio = false, executablePath = null, env = process.env, handleSIGINT = true, handleSIGTERM = true, handleSIGHUP = true, defaultViewport, timeout = 30000, extraPrefsFirefox = {}, debuggingPort = null, } = options;
|
|
150
|
-
const firefoxArguments = [];
|
|
151
|
-
firefoxArguments.push(...this.defaultArgs(options));
|
|
152
|
-
if (!firefoxArguments.some((argument) => {
|
|
153
|
-
return argument.startsWith('--remote-debugging-');
|
|
154
|
-
})) {
|
|
155
|
-
firefoxArguments.push(`--remote-debugging-port=${debuggingPort || 0}`);
|
|
156
|
-
}
|
|
157
|
-
let userDataDir;
|
|
158
|
-
let isTempUserDataDir = true;
|
|
159
|
-
// Check for the profile argument, which will always be set even
|
|
160
|
-
// with a custom directory specified via the userDataDir option.
|
|
161
|
-
const profileArgIndex = firefoxArguments.findIndex((arg) => {
|
|
162
|
-
return ['-profile', '--profile'].includes(arg);
|
|
163
|
-
});
|
|
164
|
-
if (profileArgIndex === -1) {
|
|
165
|
-
userDataDir = await this._createProfile(extraPrefsFirefox);
|
|
166
|
-
firefoxArguments.push('--profile');
|
|
167
|
-
firefoxArguments.push(userDataDir);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
userDataDir = firefoxArguments[profileArgIndex + 1];
|
|
171
|
-
if (!userDataDir || !fs.existsSync(userDataDir)) {
|
|
172
|
-
throw new Error(`Firefox profile not found at '${userDataDir}'`);
|
|
173
|
-
}
|
|
174
|
-
// When using a custom Firefox profile it needs to be populated
|
|
175
|
-
// with required preferences.
|
|
176
|
-
isTempUserDataDir = false;
|
|
177
|
-
const prefs = this.defaultPreferences(extraPrefsFirefox);
|
|
178
|
-
this.writePreferences(prefs, userDataDir);
|
|
179
|
-
}
|
|
180
|
-
await this._updateRevision();
|
|
181
|
-
let firefoxExecutable = executablePath;
|
|
182
|
-
if (!executablePath) {
|
|
183
|
-
const { missingText, executablePath: exPath } = resolveExecutablePath(this);
|
|
184
|
-
if (missingText) {
|
|
185
|
-
throw new Error(missingText);
|
|
186
|
-
}
|
|
187
|
-
firefoxExecutable = exPath;
|
|
188
|
-
}
|
|
189
|
-
if (!firefoxExecutable) {
|
|
190
|
-
throw new Error('firefoxExecutable is not found.');
|
|
191
|
-
}
|
|
192
|
-
const runner = new BrowserRunner_1.BrowserRunner({
|
|
193
|
-
product: this.product,
|
|
194
|
-
executablePath: firefoxExecutable,
|
|
195
|
-
processArguments: firefoxArguments,
|
|
196
|
-
userDataDir,
|
|
197
|
-
isTempUserDataDir,
|
|
198
|
-
});
|
|
199
|
-
runner.start({
|
|
200
|
-
handleSIGHUP,
|
|
201
|
-
handleSIGTERM,
|
|
202
|
-
handleSIGINT,
|
|
203
|
-
dumpio,
|
|
204
|
-
env,
|
|
205
|
-
});
|
|
206
|
-
let browser;
|
|
207
|
-
try {
|
|
208
|
-
const connection = await runner.setupConnection({
|
|
209
|
-
timeout,
|
|
210
|
-
preferredRevision: this._preferredRevision,
|
|
211
|
-
});
|
|
212
|
-
browser = await Browser_1.Browser._create({
|
|
213
|
-
connection,
|
|
214
|
-
contextIds: [],
|
|
215
|
-
defaultViewport,
|
|
216
|
-
closeCallback: runner.close.bind(runner),
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
runner.kill();
|
|
221
|
-
throw error;
|
|
222
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
await browser.waitForTarget((t) => {
|
|
225
|
-
return t.type() === 'page';
|
|
226
|
-
}, { timeout });
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
await browser.close();
|
|
230
|
-
throw error;
|
|
231
|
-
}
|
|
232
|
-
return browser;
|
|
233
|
-
}
|
|
234
|
-
executablePath() {
|
|
235
|
-
return resolveExecutablePath(this).executablePath;
|
|
236
|
-
}
|
|
237
|
-
async _updateRevision() {
|
|
238
|
-
// replace 'latest' placeholder with actual downloaded revision
|
|
239
|
-
if (this._preferredRevision === 'latest') {
|
|
240
|
-
const browserFetcher = new BrowserFetcher_1.BrowserFetcher({
|
|
241
|
-
product: this.product,
|
|
242
|
-
path: null,
|
|
243
|
-
platform: null,
|
|
244
|
-
});
|
|
245
|
-
const localRevisions = await browserFetcher.localRevisions();
|
|
246
|
-
if (localRevisions[0]) {
|
|
247
|
-
this._preferredRevision = localRevisions[0];
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
get product() {
|
|
252
|
-
return 'firefox';
|
|
253
|
-
}
|
|
254
|
-
defaultArgs(options) {
|
|
255
|
-
const { devtools = false, headless = !devtools, args = [], userDataDir = null, } = options;
|
|
256
|
-
const firefoxArguments = ['--no-remote'];
|
|
257
|
-
if (os.platform() === 'darwin') {
|
|
258
|
-
firefoxArguments.push('--foreground');
|
|
259
|
-
}
|
|
260
|
-
else if (os.platform().startsWith('win')) {
|
|
261
|
-
firefoxArguments.push('--wait-for-browser');
|
|
262
|
-
}
|
|
263
|
-
if (userDataDir) {
|
|
264
|
-
firefoxArguments.push('--profile');
|
|
265
|
-
firefoxArguments.push(userDataDir);
|
|
266
|
-
}
|
|
267
|
-
if (headless) {
|
|
268
|
-
firefoxArguments.push('--headless');
|
|
269
|
-
}
|
|
270
|
-
if (devtools) {
|
|
271
|
-
firefoxArguments.push('--devtools');
|
|
272
|
-
}
|
|
273
|
-
if (args.every((arg) => {
|
|
274
|
-
return arg.startsWith('-');
|
|
275
|
-
})) {
|
|
276
|
-
firefoxArguments.push('about:blank');
|
|
277
|
-
}
|
|
278
|
-
firefoxArguments.push(...args);
|
|
279
|
-
return firefoxArguments;
|
|
280
|
-
}
|
|
281
|
-
defaultPreferences(extraPrefs) {
|
|
282
|
-
const server = 'dummy.test';
|
|
283
|
-
const defaultPrefs = {
|
|
284
|
-
// Make sure Shield doesn't hit the network.
|
|
285
|
-
'app.normandy.api_url': '',
|
|
286
|
-
// Disable Firefox old build background check
|
|
287
|
-
'app.update.checkInstallTime': false,
|
|
288
|
-
// Disable automatically upgrading Firefox
|
|
289
|
-
'app.update.disabledForTesting': true,
|
|
290
|
-
// Increase the APZ content response timeout to 1 minute
|
|
291
|
-
'apz.content_response_timeout': 60000,
|
|
292
|
-
// Prevent various error message on the console
|
|
293
|
-
// jest-puppeteer asserts that no error message is emitted by the console
|
|
294
|
-
'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',
|
|
295
|
-
// Enable the dump function: which sends messages to the system
|
|
296
|
-
// console
|
|
297
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
|
|
298
|
-
'browser.dom.window.dump.enabled': true,
|
|
299
|
-
// Disable topstories
|
|
300
|
-
'browser.newtabpage.activity-stream.feeds.system.topstories': false,
|
|
301
|
-
// Always display a blank page
|
|
302
|
-
'browser.newtabpage.enabled': false,
|
|
303
|
-
// Background thumbnails in particular cause grief: and disabling
|
|
304
|
-
// thumbnails in general cannot hurt
|
|
305
|
-
'browser.pagethumbnails.capturing_disabled': true,
|
|
306
|
-
// Disable safebrowsing components.
|
|
307
|
-
'browser.safebrowsing.blockedURIs.enabled': false,
|
|
308
|
-
'browser.safebrowsing.downloads.enabled': false,
|
|
309
|
-
'browser.safebrowsing.malware.enabled': false,
|
|
310
|
-
'browser.safebrowsing.passwords.enabled': false,
|
|
311
|
-
'browser.safebrowsing.phishing.enabled': false,
|
|
312
|
-
// Disable updates to search engines.
|
|
313
|
-
'browser.search.update': false,
|
|
314
|
-
// Do not restore the last open set of tabs if the browser has crashed
|
|
315
|
-
'browser.sessionstore.resume_from_crash': false,
|
|
316
|
-
// Skip check for default browser on startup
|
|
317
|
-
'browser.shell.checkDefaultBrowser': false,
|
|
318
|
-
// Disable newtabpage
|
|
319
|
-
'browser.startup.homepage': 'about:blank',
|
|
320
|
-
// Do not redirect user when a milstone upgrade of Firefox is detected
|
|
321
|
-
'browser.startup.homepage_override.mstone': 'ignore',
|
|
322
|
-
// Start with a blank page about:blank
|
|
323
|
-
'browser.startup.page': 0,
|
|
324
|
-
// Do not allow background tabs to be zombified on Android: otherwise for
|
|
325
|
-
// tests that open additional tabs: the test harness tab itself might get
|
|
326
|
-
// unloaded
|
|
327
|
-
'browser.tabs.disableBackgroundZombification': false,
|
|
328
|
-
// Do not warn when closing all other open tabs
|
|
329
|
-
'browser.tabs.warnOnCloseOtherTabs': false,
|
|
330
|
-
// Do not warn when multiple tabs will be opened
|
|
331
|
-
'browser.tabs.warnOnOpen': false,
|
|
332
|
-
// Disable the UI tour.
|
|
333
|
-
'browser.uitour.enabled': false,
|
|
334
|
-
// Turn off search suggestions in the location bar so as not to trigger
|
|
335
|
-
// network connections.
|
|
336
|
-
'browser.urlbar.suggest.searches': false,
|
|
337
|
-
// Disable first run splash page on Windows 10
|
|
338
|
-
'browser.usedOnWindows10.introURL': '',
|
|
339
|
-
// Do not warn on quitting Firefox
|
|
340
|
-
'browser.warnOnQuit': false,
|
|
341
|
-
// Defensively disable data reporting systems
|
|
342
|
-
'datareporting.healthreport.documentServerURI': `http://${server}/dummy/healthreport/`,
|
|
343
|
-
'datareporting.healthreport.logging.consoleEnabled': false,
|
|
344
|
-
'datareporting.healthreport.service.enabled': false,
|
|
345
|
-
'datareporting.healthreport.service.firstRun': false,
|
|
346
|
-
'datareporting.healthreport.uploadEnabled': false,
|
|
347
|
-
// Do not show datareporting policy notifications which can interfere with tests
|
|
348
|
-
'datareporting.policy.dataSubmissionEnabled': false,
|
|
349
|
-
'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
|
|
350
|
-
// DevTools JSONViewer sometimes fails to load dependencies with its require.js.
|
|
351
|
-
// This doesn't affect Puppeteer but spams console (Bug 1424372)
|
|
352
|
-
'devtools.jsonview.enabled': false,
|
|
353
|
-
// Disable popup-blocker
|
|
354
|
-
'dom.disable_open_during_load': false,
|
|
355
|
-
// Enable the support for File object creation in the content process
|
|
356
|
-
// Required for |Page.setFileInputFiles| protocol method.
|
|
357
|
-
'dom.file.createInChild': true,
|
|
358
|
-
// Disable the ProcessHangMonitor
|
|
359
|
-
'dom.ipc.reportProcessHangs': false,
|
|
360
|
-
// Disable slow script dialogues
|
|
361
|
-
'dom.max_chrome_script_run_time': 0,
|
|
362
|
-
'dom.max_script_run_time': 0,
|
|
363
|
-
// Only load extensions from the application and user profile
|
|
364
|
-
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
|
|
365
|
-
'extensions.autoDisableScopes': 0,
|
|
366
|
-
'extensions.enabledScopes': 5,
|
|
367
|
-
// Disable metadata caching for installed add-ons by default
|
|
368
|
-
'extensions.getAddons.cache.enabled': false,
|
|
369
|
-
// Disable installing any distribution extensions or add-ons.
|
|
370
|
-
'extensions.installDistroAddons': false,
|
|
371
|
-
// Disabled screenshots extension
|
|
372
|
-
'extensions.screenshots.disabled': true,
|
|
373
|
-
// Turn off extension updates so they do not bother tests
|
|
374
|
-
'extensions.update.enabled': false,
|
|
375
|
-
// Turn off extension updates so they do not bother tests
|
|
376
|
-
'extensions.update.notifyUser': false,
|
|
377
|
-
// Make sure opening about:addons will not hit the network
|
|
378
|
-
'extensions.webservice.discoverURL': `http://${server}/dummy/discoveryURL`,
|
|
379
|
-
// Temporarily force disable BFCache in parent (https://bit.ly/bug-1732263)
|
|
380
|
-
'fission.bfcacheInParent': false,
|
|
381
|
-
// Force all web content to use a single content process
|
|
382
|
-
'fission.webContentIsolationStrategy': 0,
|
|
383
|
-
// Allow the application to have focus even it runs in the background
|
|
384
|
-
'focusmanager.testmode': true,
|
|
385
|
-
// Disable useragent updates
|
|
386
|
-
'general.useragent.updates.enabled': false,
|
|
387
|
-
// Always use network provider for geolocation tests so we bypass the
|
|
388
|
-
// macOS dialog raised by the corelocation provider
|
|
389
|
-
'geo.provider.testing': true,
|
|
390
|
-
// Do not scan Wifi
|
|
391
|
-
'geo.wifi.scan': false,
|
|
392
|
-
// No hang monitor
|
|
393
|
-
'hangmonitor.timeout': 0,
|
|
394
|
-
// Show chrome errors and warnings in the error console
|
|
395
|
-
'javascript.options.showInConsole': true,
|
|
396
|
-
// Disable download and usage of OpenH264: and Widevine plugins
|
|
397
|
-
'media.gmp-manager.updateEnabled': false,
|
|
398
|
-
// Prevent various error message on the console
|
|
399
|
-
// jest-puppeteer asserts that no error message is emitted by the console
|
|
400
|
-
'network.cookie.cookieBehavior': 0,
|
|
401
|
-
// Disable experimental feature that is only available in Nightly
|
|
402
|
-
'network.cookie.sameSite.laxByDefault': false,
|
|
403
|
-
// Do not prompt for temporary redirects
|
|
404
|
-
'network.http.prompt-temp-redirect': false,
|
|
405
|
-
// Disable speculative connections so they are not reported as leaking
|
|
406
|
-
// when they are hanging around
|
|
407
|
-
'network.http.speculative-parallel-limit': 0,
|
|
408
|
-
// Do not automatically switch between offline and online
|
|
409
|
-
'network.manage-offline-status': false,
|
|
410
|
-
// Make sure SNTP requests do not hit the network
|
|
411
|
-
'network.sntp.pools': server,
|
|
412
|
-
// Disable Flash.
|
|
413
|
-
'plugin.state.flash': 0,
|
|
414
|
-
'privacy.trackingprotection.enabled': false,
|
|
415
|
-
// Can be removed once Firefox 89 is no longer supported
|
|
416
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1710839
|
|
417
|
-
'remote.enabled': true,
|
|
418
|
-
// Don't do network connections for mitm priming
|
|
419
|
-
'security.certerrors.mitm.priming.enabled': false,
|
|
420
|
-
// Local documents have access to all other local documents,
|
|
421
|
-
// including directory listings
|
|
422
|
-
'security.fileuri.strict_origin_policy': false,
|
|
423
|
-
// Do not wait for the notification button security delay
|
|
424
|
-
'security.notification_enable_delay': 0,
|
|
425
|
-
// Ensure blocklist updates do not hit the network
|
|
426
|
-
'services.settings.server': `http://${server}/dummy/blocklist/`,
|
|
427
|
-
// Do not automatically fill sign-in forms with known usernames and
|
|
428
|
-
// passwords
|
|
429
|
-
'signon.autofillForms': false,
|
|
430
|
-
// Disable password capture, so that tests that include forms are not
|
|
431
|
-
// influenced by the presence of the persistent doorhanger notification
|
|
432
|
-
'signon.rememberSignons': false,
|
|
433
|
-
// Disable first-run welcome page
|
|
434
|
-
'startup.homepage_welcome_url': 'about:blank',
|
|
435
|
-
// Disable first-run welcome page
|
|
436
|
-
'startup.homepage_welcome_url.additional': '',
|
|
437
|
-
// Disable browser animations (tabs, fullscreen, sliding alerts)
|
|
438
|
-
'toolkit.cosmeticAnimations.enabled': false,
|
|
439
|
-
// Prevent starting into safe mode after application crashes
|
|
440
|
-
'toolkit.startup.max_resumed_crashes': -1,
|
|
441
|
-
};
|
|
442
|
-
return Object.assign(defaultPrefs, extraPrefs);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Populates the user.js file with custom preferences as needed to allow
|
|
446
|
-
* Firefox's CDP support to properly function. These preferences will be
|
|
447
|
-
* automatically copied over to prefs.js during startup of Firefox. To be
|
|
448
|
-
* able to restore the original values of preferences a backup of prefs.js
|
|
449
|
-
* will be created.
|
|
450
|
-
*
|
|
451
|
-
* @param prefs - List of preferences to add.
|
|
452
|
-
* @param profilePath - Firefox profile to write the preferences to.
|
|
453
|
-
*/
|
|
454
|
-
async writePreferences(prefs, profilePath) {
|
|
455
|
-
const lines = Object.entries(prefs).map(([key, value]) => {
|
|
456
|
-
return `user_pref(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
|
|
457
|
-
});
|
|
458
|
-
await writeFileAsync(path.join(profilePath, 'user.js'), lines.join('\n'));
|
|
459
|
-
// Create a backup of the preferences file if it already exitsts.
|
|
460
|
-
const prefsPath = path.join(profilePath, 'prefs.js');
|
|
461
|
-
if (fs.existsSync(prefsPath)) {
|
|
462
|
-
const prefsBackupPath = path.join(profilePath, 'prefs.js.puppeteer');
|
|
463
|
-
await copyFileAsync(prefsPath, prefsBackupPath);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
async _createProfile(extraPrefs) {
|
|
467
|
-
const temporaryProfilePath = await mkdtempAsync(path.join(tmpDir(), 'puppeteer_dev_firefox_profile-'));
|
|
468
|
-
const prefs = this.defaultPreferences(extraPrefs);
|
|
469
|
-
await this.writePreferences(prefs, temporaryProfilePath);
|
|
470
|
-
return temporaryProfilePath;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
128
|
function resolveExecutablePath(launcher) {
|
|
474
129
|
const { product, _preferredRevision } = launcher;
|
|
475
130
|
const browserFetcher = new BrowserFetcher_1.BrowserFetcher({
|
|
@@ -485,20 +140,7 @@ function resolveExecutablePath(launcher) {
|
|
|
485
140
|
: `Could not find expected browser (${product}) locally. ${product === 'chrome' ? chromeHelp : firefoxHelp}`;
|
|
486
141
|
return { executablePath: revisionInfo.executablePath, missingText };
|
|
487
142
|
}
|
|
488
|
-
function Launcher(preferredRevision
|
|
489
|
-
|
|
490
|
-
case 'firefox':
|
|
491
|
-
return new FirefoxLauncher(preferredRevision);
|
|
492
|
-
case 'chrome':
|
|
493
|
-
default:
|
|
494
|
-
if (typeof product !== 'undefined' && product !== 'chrome') {
|
|
495
|
-
/* The user gave us an incorrect product name
|
|
496
|
-
* we'll default to launching Chrome, but log to the console
|
|
497
|
-
* to let the user know (they've probably typoed).
|
|
498
|
-
*/
|
|
499
|
-
console.warn(`Warning: unknown product name ${product}. Falling back to chrome.`);
|
|
500
|
-
}
|
|
501
|
-
return new ChromeLauncher(preferredRevision);
|
|
502
|
-
}
|
|
143
|
+
function Launcher(preferredRevision) {
|
|
144
|
+
return new ChromeLauncher(preferredRevision);
|
|
503
145
|
}
|
|
504
146
|
exports.default = Launcher;
|
|
@@ -58,15 +58,12 @@ class PuppeteerNode {
|
|
|
58
58
|
if (!__classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f") ||
|
|
59
59
|
__classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f").product !== __classPrivateFieldGet(this, _PuppeteerNode_productName, "f")) {
|
|
60
60
|
switch (__classPrivateFieldGet(this, _PuppeteerNode_productName, "f")) {
|
|
61
|
-
case 'firefox':
|
|
62
|
-
this._preferredRevision = revisions_1.PUPPETEER_REVISIONS.firefox;
|
|
63
|
-
break;
|
|
64
61
|
case 'chrome':
|
|
65
62
|
default:
|
|
66
63
|
this._preferredRevision = revisions_1.PUPPETEER_REVISIONS.chromium;
|
|
67
64
|
}
|
|
68
65
|
// eslint-disable-next-line new-cap
|
|
69
|
-
__classPrivateFieldSet(this, _PuppeteerNode_lazyLauncher, (0, Launcher_1.default)(this._preferredRevision
|
|
66
|
+
__classPrivateFieldSet(this, _PuppeteerNode_lazyLauncher, (0, Launcher_1.default)(this._preferredRevision), "f");
|
|
70
67
|
}
|
|
71
68
|
return __classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f");
|
|
72
69
|
}
|
|
@@ -14,12 +14,8 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
18
|
exports.downloadBrowser = void 0;
|
|
22
|
-
const https_1 = __importDefault(require("https"));
|
|
23
19
|
const node_1 = require("./node");
|
|
24
20
|
const revisions_1 = require("./revisions");
|
|
25
21
|
const supportedProducts = {
|
|
@@ -34,19 +30,9 @@ async function downloadBrowser(product) {
|
|
|
34
30
|
});
|
|
35
31
|
const revision = await getRevision();
|
|
36
32
|
await fetchBinary(revision);
|
|
37
|
-
|
|
33
|
+
function getRevision() {
|
|
38
34
|
if (product === 'chrome') {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
if (product === 'firefox') {
|
|
42
|
-
node_1.puppeteer._preferredRevision = revisions_1.PUPPETEER_REVISIONS.firefox;
|
|
43
|
-
try {
|
|
44
|
-
return await getFirefoxNightlyVersion();
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error(error);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
35
|
+
return revisions_1.PUPPETEER_REVISIONS.chromium;
|
|
50
36
|
}
|
|
51
37
|
throw new Error(`Unsupported product ${product}`);
|
|
52
38
|
}
|
|
@@ -87,33 +73,5 @@ async function downloadBrowser(product) {
|
|
|
87
73
|
const mb = bytes / 1024 / 1024;
|
|
88
74
|
return `${Math.round(mb * 10) / 10} Mb`;
|
|
89
75
|
}
|
|
90
|
-
function getFirefoxNightlyVersion() {
|
|
91
|
-
const firefoxVersionsUrl = 'https://product-details.mozilla.org/1.0/firefox_versions.json';
|
|
92
|
-
const requestOptions = {};
|
|
93
|
-
const promise = new Promise((resolve, reject) => {
|
|
94
|
-
let data = '';
|
|
95
|
-
console.log(`Requesting latest Firefox Nightly version from ${firefoxVersionsUrl}`);
|
|
96
|
-
https_1.default
|
|
97
|
-
.get(firefoxVersionsUrl, requestOptions, (r) => {
|
|
98
|
-
if (r.statusCode && r.statusCode >= 400) {
|
|
99
|
-
return reject(new Error(`Got status code ${r.statusCode}`));
|
|
100
|
-
}
|
|
101
|
-
r.on('data', (chunk) => {
|
|
102
|
-
data += chunk;
|
|
103
|
-
});
|
|
104
|
-
r.on('end', () => {
|
|
105
|
-
try {
|
|
106
|
-
const versions = JSON.parse(data);
|
|
107
|
-
return resolve(versions.FIREFOX_NIGHTLY);
|
|
108
|
-
}
|
|
109
|
-
catch (_a) {
|
|
110
|
-
return reject(new Error('Firefox version not found'));
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
})
|
|
114
|
-
.on('error', reject);
|
|
115
|
-
});
|
|
116
|
-
return promise;
|
|
117
|
-
}
|
|
118
76
|
}
|
|
119
77
|
exports.downloadBrowser = downloadBrowser;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToPositiveFrameIndex = void 0;
|
|
4
|
+
// Handle negative indices (e.g. -1 being the last frame)
|
|
5
|
+
const convertToPositiveFrameIndex = ({ frame, durationInFrames, }) => {
|
|
6
|
+
return frame < 0 ? durationInFrames - frame : frame;
|
|
7
|
+
};
|
|
8
|
+
exports.convertToPositiveFrameIndex = convertToPositiveFrameIndex;
|
|
@@ -49,9 +49,7 @@ const getBrowserRevision = (product) => {
|
|
|
49
49
|
path: null,
|
|
50
50
|
platform: null,
|
|
51
51
|
});
|
|
52
|
-
const revisionInfo = browserFetcher.revisionInfo(
|
|
53
|
-
? revisions_1.PUPPETEER_REVISIONS.firefox
|
|
54
|
-
: revisions_1.PUPPETEER_REVISIONS.chromium);
|
|
52
|
+
const revisionInfo = browserFetcher.revisionInfo(revisions_1.PUPPETEER_REVISIONS.chromium);
|
|
55
53
|
return revisionInfo;
|
|
56
54
|
};
|
|
57
55
|
const getBrowserStatus = (product, browserExecutablePath) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import execa from 'execa';
|
|
2
3
|
import { SymbolicateableError } from './error-handling/symbolicateable-error';
|
|
3
4
|
import { mimeContentType, mimeLookup } from './mime-types';
|
|
@@ -68,7 +69,7 @@ export declare const RenderInternals: {
|
|
|
68
69
|
task: Promise<Buffer | null>;
|
|
69
70
|
getLogs: () => string;
|
|
70
71
|
}>;
|
|
71
|
-
getFileExtensionFromCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", type: "chunk" | "final") => "mp3" | "aac" | "wav" | "gif" | "
|
|
72
|
+
getFileExtensionFromCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", type: "chunk" | "final") => "mp3" | "aac" | "wav" | "gif" | "webm" | "mp4" | "mov" | "mkv";
|
|
72
73
|
tmpDir: (str: string) => string;
|
|
73
74
|
deleteDirectory: (directory: string) => Promise<void>;
|
|
74
75
|
isServeUrl: (potentialUrl: string) => boolean;
|
|
@@ -123,8 +124,8 @@ export declare const RenderInternals: {
|
|
|
123
124
|
validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
|
|
124
125
|
DEFAULT_BROWSER: import("./browser").Browser;
|
|
125
126
|
validateFrameRange: (frameRange: import("./frame-range").FrameRange | null) => void;
|
|
126
|
-
DEFAULT_OPENGL_RENDERER: "
|
|
127
|
-
validateOpenGlRenderer: (option: "
|
|
127
|
+
DEFAULT_OPENGL_RENDERER: "angle" | "swangle" | "egl" | "swiftshader" | null;
|
|
128
|
+
validateOpenGlRenderer: (option: "angle" | "swangle" | "egl" | "swiftshader" | null) => "angle" | "swangle" | "egl" | "swiftshader" | null;
|
|
128
129
|
getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => number;
|
|
129
130
|
validateSelectedCrfAndCodecCombination: (crf: unknown, codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => void;
|
|
130
131
|
validImageFormats: readonly ["png", "jpeg", "none"];
|
|
@@ -135,15 +136,19 @@ export declare const RenderInternals: {
|
|
|
135
136
|
DEFAULT_TIMEOUT: number;
|
|
136
137
|
getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => [number, number];
|
|
137
138
|
validateSelectedPixelFormatAndCodecCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => void;
|
|
138
|
-
validateSelectedCodecAndProResCombination: (actualCodec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", actualProResProfile: "4444-xq" | "4444" | "hq" | "standard" | "light" |
|
|
139
|
-
validateSelectedPixelFormatAndImageFormatCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", imageFormat: "
|
|
139
|
+
validateSelectedCodecAndProResCombination: (actualCodec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", actualProResProfile: "proxy" | "4444-xq" | "4444" | "hq" | "standard" | "light" | undefined) => void;
|
|
140
|
+
validateSelectedPixelFormatAndImageFormatCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", imageFormat: "jpeg" | "png" | "none") => "none" | "valid";
|
|
140
141
|
DEFAULT_CODEC: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
|
|
141
142
|
isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
|
|
142
143
|
logLevels: readonly ["verbose", "info", "warn", "error"];
|
|
143
|
-
isEqualOrBelowLogLevel: (currentLevel: "
|
|
144
|
+
isEqualOrBelowLogLevel: (currentLevel: "error" | "verbose" | "info" | "warn", level: "error" | "verbose" | "info" | "warn") => boolean;
|
|
144
145
|
isValidLogLevel: (level: string) => boolean;
|
|
145
146
|
validateEveryNthFrame: (everyNthFrame: unknown) => void;
|
|
146
147
|
perf: typeof perf;
|
|
147
148
|
makeDownloadMap: () => import("./assets/download-map").DownloadMap;
|
|
148
149
|
cleanDownloadMap: (downloadMap: import("./assets/download-map").DownloadMap) => Promise<void>;
|
|
150
|
+
convertToPositiveFrameIndex: ({ frame, durationInFrames, }: {
|
|
151
|
+
frame: number;
|
|
152
|
+
durationInFrames: number;
|
|
153
|
+
}) => number;
|
|
149
154
|
};
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ const browser_1 = require("./browser");
|
|
|
34
34
|
const TimeoutSettings_1 = require("./browser/TimeoutSettings");
|
|
35
35
|
const can_use_parallel_encoding_1 = require("./can-use-parallel-encoding");
|
|
36
36
|
const codec_1 = require("./codec");
|
|
37
|
+
const convert_to_positive_frame_index_1 = require("./convert-to-positive-frame-index");
|
|
37
38
|
const crf_1 = require("./crf");
|
|
38
39
|
const delete_directory_1 = require("./delete-directory");
|
|
39
40
|
const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
@@ -156,4 +157,5 @@ exports.RenderInternals = {
|
|
|
156
157
|
perf,
|
|
157
158
|
makeDownloadMap: download_map_1.makeDownloadMap,
|
|
158
159
|
cleanDownloadMap: download_map_1.cleanDownloadMap,
|
|
160
|
+
convertToPositiveFrameIndex: convert_to_positive_frame_index_1.convertToPositiveFrameIndex,
|
|
159
161
|
};
|
package/dist/open-browser.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
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.openBrowser = exports.killAllBrowsers = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const os_1 = __importDefault(require("os"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
4
|
const node_1 = require("./browser/node");
|
|
11
5
|
const get_local_browser_executable_1 = require("./get-local-browser-executable");
|
|
12
6
|
const get_video_threads_flag_1 = require("./get-video-threads-flag");
|
|
@@ -102,11 +96,7 @@ const openBrowser = async (browser, options) => {
|
|
|
102
96
|
? '--ignore-certificate-errors'
|
|
103
97
|
: null,
|
|
104
98
|
...(((_j = options === null || options === void 0 ? void 0 : options.chromiumOptions) === null || _j === void 0 ? void 0 : _j.disableWebSecurity)
|
|
105
|
-
? [
|
|
106
|
-
'--disable-web-security',
|
|
107
|
-
'--user-data-dir=' +
|
|
108
|
-
(await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'chrome-user-dir'))),
|
|
109
|
-
]
|
|
99
|
+
? ['--disable-web-security']
|
|
110
100
|
: []),
|
|
111
101
|
].filter(Boolean),
|
|
112
102
|
defaultViewport: (_k = options === null || options === void 0 ? void 0 : options.viewport) !== null && _k !== void 0 ? _k : {
|
package/dist/render-media.js
CHANGED
|
@@ -303,6 +303,10 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
303
303
|
if (!(options === null || options === void 0 ? void 0 : options.downloadMap)) {
|
|
304
304
|
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
|
305
305
|
}
|
|
306
|
+
// Clean temporary image frames when rendering ends or fails
|
|
307
|
+
if (outputDir && fs_1.default.existsSync(outputDir)) {
|
|
308
|
+
(0, delete_directory_1.deleteDirectory)(outputDir);
|
|
309
|
+
}
|
|
306
310
|
});
|
|
307
311
|
return Promise.race([
|
|
308
312
|
happyPath,
|
package/dist/render-still.js
CHANGED
|
@@ -32,6 +32,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
32
32
|
const remotion_1 = require("remotion");
|
|
33
33
|
const download_map_1 = require("./assets/download-map");
|
|
34
34
|
const browser_1 = require("./browser");
|
|
35
|
+
const convert_to_positive_frame_index_1 = require("./convert-to-positive-frame-index");
|
|
35
36
|
const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
36
37
|
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
37
38
|
const image_format_1 = require("./image-format");
|
|
@@ -53,6 +54,10 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
53
54
|
remotion_1.Internals.validateDurationInFrames(composition.durationInFrames, 'in the `config` object passed to `renderStill()`');
|
|
54
55
|
(0, image_format_1.validateNonNullImageFormat)(imageFormat);
|
|
55
56
|
(0, validate_frame_1.validateFrame)(frame, composition.durationInFrames);
|
|
57
|
+
const stillFrame = (0, convert_to_positive_frame_index_1.convertToPositiveFrameIndex)({
|
|
58
|
+
durationInFrames: composition.durationInFrames,
|
|
59
|
+
frame,
|
|
60
|
+
});
|
|
56
61
|
(0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
|
|
57
62
|
(0, validate_scale_1.validateScale)(scale);
|
|
58
63
|
if (typeof output !== 'string') {
|
|
@@ -113,7 +118,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
113
118
|
envVariables,
|
|
114
119
|
page,
|
|
115
120
|
serveUrl,
|
|
116
|
-
initialFrame:
|
|
121
|
+
initialFrame: stillFrame,
|
|
117
122
|
timeoutInMilliseconds,
|
|
118
123
|
proxyPort,
|
|
119
124
|
retriesRemaining: 2,
|
|
@@ -144,13 +149,13 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
144
149
|
frame: null,
|
|
145
150
|
page,
|
|
146
151
|
});
|
|
147
|
-
await (0, seek_to_frame_1.seekToFrame)({ frame, page });
|
|
152
|
+
await (0, seek_to_frame_1.seekToFrame)({ frame: stillFrame, page });
|
|
148
153
|
await (0, provide_screenshot_1.provideScreenshot)({
|
|
149
154
|
page,
|
|
150
155
|
imageFormat,
|
|
151
156
|
quality,
|
|
152
157
|
options: {
|
|
153
|
-
frame,
|
|
158
|
+
frame: stillFrame,
|
|
154
159
|
output,
|
|
155
160
|
},
|
|
156
161
|
});
|
|
@@ -103,7 +103,7 @@ const setPropsAndEnv = async ({ inputProps, envVariables, page, serveUrl, initia
|
|
|
103
103
|
if (siteVersion !== requiredVersion) {
|
|
104
104
|
throw new Error(`Incompatible site: When visiting ${urlToVisit}, a bundle was found, but one that is not compatible with this version of Remotion. Found version: ${siteVersion} - Required version: ${requiredVersion}. To resolve this error, please bundle and deploy again.`);
|
|
105
105
|
}
|
|
106
|
-
if (remotionVersion !== version_1.VERSION) {
|
|
106
|
+
if (remotionVersion !== version_1.VERSION && process.env.NODE_ENV !== 'test') {
|
|
107
107
|
if (remotionVersion) {
|
|
108
108
|
console.warn(`The site was bundled with version ${remotionVersion} of @remotion/bundler, while @remotion/renderer is on version ${version_1.VERSION}. You may not have the newest bugfixes and features. Re-bundle the site to fix this issue.`);
|
|
109
109
|
}
|
package/dist/validate-frame.js
CHANGED
|
@@ -8,15 +8,15 @@ const validateFrame = (frame, durationInFrames) => {
|
|
|
8
8
|
if (typeof frame !== 'number') {
|
|
9
9
|
throw new TypeError(`Argument passed for "frame" is not a number: ${frame}`);
|
|
10
10
|
}
|
|
11
|
-
if (frame < 0) {
|
|
12
|
-
throw new RangeError(`Frame ${frame} cannot be negative`);
|
|
13
|
-
}
|
|
14
11
|
if (!Number.isFinite(frame)) {
|
|
15
12
|
throw new RangeError(`Frame ${frame} is not finite`);
|
|
16
13
|
}
|
|
17
14
|
if (frame % 1 !== 0) {
|
|
18
15
|
throw new RangeError(`Argument for frame must be an integer, but got ${frame}`);
|
|
19
16
|
}
|
|
17
|
+
if (frame < 0 && frame < -durationInFrames) {
|
|
18
|
+
throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the lowest frame that can be rendered is ${-durationInFrames}`);
|
|
19
|
+
}
|
|
20
20
|
if (frame > durationInFrames - 1) {
|
|
21
21
|
throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the highest frame that can be rendered is ${durationInFrames - 1}`);
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/renderer",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.27",
|
|
4
4
|
"description": "Renderer for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"execa": "5.1.1",
|
|
24
24
|
"extract-zip": "2.0.1",
|
|
25
|
-
"remotion": "3.2.
|
|
25
|
+
"remotion": "3.2.27",
|
|
26
26
|
"source-map": "^0.8.0-beta.0",
|
|
27
27
|
"ws": "8.7.0"
|
|
28
28
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "662c69bcb2fee4d51553b2f8e61635fb4d6688b1"
|
|
61
61
|
}
|