@remotion/renderer 3.3.87 → 3.3.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/assets/download-file.d.ts +3 -2
  2. package/dist/assets/download-file.js +16 -1
  3. package/dist/browser/BrowserFetcher.d.ts +15 -63
  4. package/dist/browser/BrowserFetcher.js +125 -213
  5. package/dist/browser/Launcher.js +2 -7
  6. package/dist/browser/PuppeteerNode.d.ts +0 -3
  7. package/dist/browser/PuppeteerNode.js +0 -5
  8. package/dist/browser/create-browser-fetcher.js +34 -48
  9. package/dist/browser/is-target-closed-err.d.ts +1 -0
  10. package/dist/browser/is-target-closed-err.js +9 -0
  11. package/dist/call-ffmpeg.d.ts +14 -0
  12. package/dist/call-ffmpeg.js +37 -0
  13. package/dist/compositor/compositor.d.ts +12 -0
  14. package/dist/compositor/compositor.js +202 -0
  15. package/dist/compositor/make-nonce.d.ts +1 -0
  16. package/dist/compositor/make-nonce.js +8 -0
  17. package/dist/get-local-browser-executable.js +3 -12
  18. package/dist/index.d.ts +2 -2
  19. package/dist/jpeg-quality.d.ts +1 -0
  20. package/dist/jpeg-quality.js +21 -0
  21. package/dist/options/audio-bitrate.d.ts +2 -0
  22. package/dist/options/audio-bitrate.js +11 -0
  23. package/dist/options/crf.d.ts +2 -0
  24. package/dist/options/crf.js +11 -0
  25. package/dist/options/enforce-audio.d.ts +2 -0
  26. package/dist/options/enforce-audio.js +11 -0
  27. package/dist/options/jpeg-quality.d.ts +2 -0
  28. package/dist/options/jpeg-quality.js +11 -0
  29. package/dist/options/mute.d.ts +2 -0
  30. package/dist/options/mute.js +11 -0
  31. package/dist/options/option.d.ts +8 -0
  32. package/dist/options/option.js +2 -0
  33. package/dist/options/scale.d.ts +2 -0
  34. package/dist/options/scale.js +11 -0
  35. package/dist/options/video-bitrate.d.ts +2 -0
  36. package/dist/options/video-bitrate.js +11 -0
  37. package/dist/options/video-codec.d.ts +2 -0
  38. package/dist/options/video-codec.js +11 -0
  39. package/package.json +9 -9
@@ -2,7 +2,7 @@ declare type Response = {
2
2
  sizeInBytes: number;
3
3
  to: string;
4
4
  };
5
- export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
5
+ declare type Options = {
6
6
  url: string;
7
7
  to: (contentDisposition: string | null, contentType: string | null) => string;
8
8
  onProgress: ((progress: {
@@ -10,5 +10,6 @@ export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
10
10
  downloaded: number;
11
11
  totalSize: number | null;
12
12
  }) => void) | undefined;
13
- }) => Promise<Response>;
13
+ };
14
+ export declare const downloadFile: (options: Options, retries?: number) => Promise<Response>;
14
15
  export {};
@@ -4,7 +4,7 @@ exports.downloadFile = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const ensure_output_directory_1 = require("../ensure-output-directory");
6
6
  const read_file_1 = require("./read-file");
7
- const downloadFile = ({ onProgress, url, to: toFn, }) => {
7
+ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
8
8
  return new Promise((resolve, reject) => {
9
9
  let rejected = false;
10
10
  let resolved = false;
@@ -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;
@@ -15,11 +15,6 @@
15
15
  */
16
16
  import type { Product } from './Product';
17
17
  declare type Platform = 'linux' | 'mac' | 'mac_arm' | 'win32' | 'win64';
18
- export interface BrowserFetcherOptions {
19
- platform: Platform | null;
20
- product: Product;
21
- path: string | null;
22
- }
23
18
  interface BrowserFetcherRevisionInfo {
24
19
  folderPath: string;
25
20
  executablePath: string;
@@ -28,63 +23,20 @@ interface BrowserFetcherRevisionInfo {
28
23
  revision: string;
29
24
  product: string;
30
25
  }
31
- export declare class BrowserFetcher {
32
- #private;
33
- constructor(options: BrowserFetcherOptions);
34
- /**
35
- * @returns Returns the current `Platform`, which is one of `mac`, `linux`,
36
- * `win32` or `win64`.
37
- */
38
- platform(): Platform;
39
- /**
40
- * @returns Returns the current `Product`, which is one of `chrome` or
41
- * `firefox`.
42
- */
43
- product(): Product;
44
- /**
45
- * @returns The download host being used.
46
- */
47
- host(): string;
48
- /**
49
- * Initiates a HEAD request to check if the revision is available.
50
- * @remarks
51
- * This method is affected by the current `product`.
52
- * @param revision - The revision to check availability for.
53
- * @returns A promise that resolves to `true` if the revision could be downloaded
54
- * from the host.
55
- */
56
- canDownload(revision: string): Promise<boolean>;
57
- /**
58
- * Initiates a GET request to download the revision from the host.
59
- * @remarks
60
- * This method is affected by the current `product`.
61
- * @param revision - The revision to download.
62
- * @param progressCallback - A function that will be called with two arguments:
63
- * How many bytes have been downloaded and the total number of bytes of the download.
64
- * @returns A promise with revision information when the revision is downloaded
65
- * and extracted.
66
- */
67
- download(revision: string, progressCallback?: (x: number, y: number) => void): Promise<BrowserFetcherRevisionInfo | undefined>;
68
- /**
69
- * @remarks
70
- * This method is affected by the current `product`.
71
- * @returns A promise with a list of all revision strings (for the current `product`)
72
- * available locally on disk.
73
- */
74
- localRevisions(): Promise<string[]>;
75
- /**
76
- * @remarks
77
- * This method is affected by the current `product`.
78
- * @param revision - A revision to remove for the current `product`.
79
- * @returns A promise that resolves when the revision has been removes or
80
- * throws if the revision has not been downloaded.
81
- */
82
- remove(revision: string): Promise<void>;
83
- /**
84
- * @param revision - The revision to get info for.
85
- * @returns The revision info for the given revision.
86
- */
87
- revisionInfo(revision: string): BrowserFetcherRevisionInfo;
88
- }
26
+ export declare const getPlatform: (product: Product) => Platform;
27
+ export declare const getDownloadsFolder: (product: Product) => string;
28
+ export declare const getDownloadHost: (product: Product) => "https://storage.googleapis.com" | "https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central";
29
+ export declare const download: ({ revision, progressCallback, product, platform, downloadHost, downloadsFolder, }: {
30
+ revision: string;
31
+ progressCallback: (x: number, y: number) => void;
32
+ product: Product;
33
+ platform: Platform;
34
+ downloadHost: string;
35
+ downloadsFolder: string;
36
+ }) => Promise<BrowserFetcherRevisionInfo | undefined>;
37
+ export declare const localRevisions: (downloadsFolder: string, product: Product, platform: Platform) => Promise<string[]>;
38
+ export declare const removeBrowser: (revision: string, folderPath: string) => Promise<void>;
39
+ export declare const getFolderPath: (revision: string, downloadsFolder: string, platform: Platform) => string;
40
+ export declare const getRevisionInfo: (revision: string, product: Product) => BrowserFetcherRevisionInfo;
89
41
  export declare function _downloadFile(url: string, destinationPath: string, progressCallback: (x: number, y: number) => void): Promise<number>;
90
42
  export {};
@@ -37,23 +37,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  __setModuleDefault(result, mod);
38
38
  return result;
39
39
  };
40
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
41
- if (kind === "m") throw new TypeError("Private method is not writable");
42
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
43
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
44
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
45
- };
46
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
47
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
50
- };
51
40
  var __importDefault = (this && this.__importDefault) || function (mod) {
52
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
53
42
  };
54
- var _BrowserFetcher_instances, _BrowserFetcher_product, _BrowserFetcher_downloadsFolder, _BrowserFetcher_downloadHost, _BrowserFetcher_platform, _BrowserFetcher_getFolderPath;
55
43
  Object.defineProperty(exports, "__esModule", { value: true });
56
- exports._downloadFile = exports.BrowserFetcher = void 0;
44
+ exports._downloadFile = exports.getRevisionInfo = exports.getFolderPath = exports.removeBrowser = exports.localRevisions = exports.download = exports.getDownloadHost = exports.getDownloadsFolder = exports.getPlatform = void 0;
57
45
  const childProcess = __importStar(require("child_process"));
58
46
  const fs = __importStar(require("fs"));
59
47
  const http = __importStar(require("http"));
@@ -149,223 +137,147 @@ function existsAsync(filePath) {
149
137
  });
150
138
  });
151
139
  }
152
- class BrowserFetcher {
153
- constructor(options) {
154
- _BrowserFetcher_instances.add(this);
155
- _BrowserFetcher_product.set(this, void 0);
156
- _BrowserFetcher_downloadsFolder.set(this, void 0);
157
- _BrowserFetcher_downloadHost.set(this, void 0);
158
- _BrowserFetcher_platform.set(this, void 0);
159
- __classPrivateFieldSet(this, _BrowserFetcher_product, options.product.toLowerCase(), "f");
160
- (0, assert_1.assert)(__classPrivateFieldGet(this, _BrowserFetcher_product, "f") === 'chrome' || __classPrivateFieldGet(this, _BrowserFetcher_product, "f") === 'firefox', `Unknown product: "${options.product}"`);
161
- __classPrivateFieldSet(this, _BrowserFetcher_downloadsFolder, options.path ||
162
- path.join((0, get_download_destination_1.getDownloadsCacheDir)(), browserConfig[__classPrivateFieldGet(this, _BrowserFetcher_product, "f")].destination), "f");
163
- __classPrivateFieldSet(this, _BrowserFetcher_downloadHost, browserConfig[__classPrivateFieldGet(this, _BrowserFetcher_product, "f")].host, "f");
164
- if (options.platform) {
165
- __classPrivateFieldSet(this, _BrowserFetcher_platform, options.platform, "f");
166
- }
167
- else {
168
- const platform = os.platform();
169
- switch (platform) {
170
- case 'darwin':
171
- switch (__classPrivateFieldGet(this, _BrowserFetcher_product, "f")) {
172
- case 'chrome':
173
- __classPrivateFieldSet(this, _BrowserFetcher_platform, os.arch() === 'arm64' && PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM
174
- ? 'mac_arm'
175
- : 'mac', "f");
176
- break;
177
- case 'firefox':
178
- __classPrivateFieldSet(this, _BrowserFetcher_platform, 'mac', "f");
179
- break;
180
- default:
181
- throw new Error('unknown browser');
182
- }
183
- break;
184
- case 'linux':
185
- __classPrivateFieldSet(this, _BrowserFetcher_platform, 'linux', "f");
186
- break;
187
- case 'win32':
188
- __classPrivateFieldSet(this, _BrowserFetcher_platform, os.arch() === 'x64' ? 'win64' : 'win32', "f");
189
- return;
140
+ const getPlatform = (product) => {
141
+ const platform = os.platform();
142
+ switch (platform) {
143
+ case 'darwin':
144
+ switch (product) {
145
+ case 'chrome':
146
+ return os.arch() === 'arm64' &&
147
+ PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM
148
+ ? 'mac_arm'
149
+ : 'mac';
150
+ case 'firefox':
151
+ return 'mac';
190
152
  default:
191
- (0, assert_1.assert)(false, 'Unsupported platform: ' + platform);
153
+ throw new Error('unknown browser');
192
154
  }
193
- }
194
- (0, assert_1.assert)(downloadURLs[__classPrivateFieldGet(this, _BrowserFetcher_product, "f")][__classPrivateFieldGet(this, _BrowserFetcher_platform, "f")], 'Unsupported platform: ' + __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"));
155
+ case 'linux':
156
+ return 'linux';
157
+ case 'win32':
158
+ return os.arch() === 'x64' ? 'win64' : 'win32';
159
+ default:
160
+ (0, assert_1.assert)(false, 'Unsupported platform: ' + platform);
195
161
  }
196
- /**
197
- * @returns Returns the current `Platform`, which is one of `mac`, `linux`,
198
- * `win32` or `win64`.
199
- */
200
- platform() {
201
- return __classPrivateFieldGet(this, _BrowserFetcher_platform, "f");
162
+ };
163
+ exports.getPlatform = getPlatform;
164
+ const getDownloadsFolder = (product) => {
165
+ return path.join((0, get_download_destination_1.getDownloadsCacheDir)(), browserConfig[product].destination);
166
+ };
167
+ exports.getDownloadsFolder = getDownloadsFolder;
168
+ const getDownloadHost = (product) => {
169
+ return browserConfig[product].host;
170
+ };
171
+ exports.getDownloadHost = getDownloadHost;
172
+ const download = async ({ revision, progressCallback, product, platform, downloadHost, downloadsFolder, }) => {
173
+ const url = _downloadURL(product, platform, downloadHost, revision);
174
+ const fileName = url.split('/').pop();
175
+ (0, assert_1.assert)(fileName, `A malformed download URL was found: ${url}.`);
176
+ const archivePath = path.join(downloadsFolder, fileName);
177
+ const outputPath = (0, exports.getFolderPath)(revision, downloadsFolder, platform);
178
+ if (await existsAsync(outputPath)) {
179
+ return (0, exports.getRevisionInfo)(revision, product);
202
180
  }
203
- /**
204
- * @returns Returns the current `Product`, which is one of `chrome` or
205
- * `firefox`.
206
- */
207
- product() {
208
- return __classPrivateFieldGet(this, _BrowserFetcher_product, "f");
181
+ if (!(await existsAsync(downloadsFolder))) {
182
+ await mkdirAsync(downloadsFolder, {
183
+ recursive: true,
184
+ });
209
185
  }
210
- /**
211
- * @returns The download host being used.
212
- */
213
- host() {
214
- return __classPrivateFieldGet(this, _BrowserFetcher_downloadHost, "f");
186
+ // Use system Chromium builds on Linux ARM devices
187
+ if (os.platform() !== 'darwin' && os.arch() === 'arm64') {
188
+ handleArm64();
189
+ return;
215
190
  }
216
- /**
217
- * Initiates a HEAD request to check if the revision is available.
218
- * @remarks
219
- * This method is affected by the current `product`.
220
- * @param revision - The revision to check availability for.
221
- * @returns A promise that resolves to `true` if the revision could be downloaded
222
- * from the host.
223
- */
224
- canDownload(revision) {
225
- const url = _downloadURL(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"), __classPrivateFieldGet(this, _BrowserFetcher_downloadHost, "f"), revision);
226
- return new Promise((resolve) => {
227
- const request = httpRequest(url, 'HEAD', (response) => {
228
- resolve(response.statusCode === 200);
229
- }, false);
230
- request.on('error', (error) => {
231
- console.error(error);
232
- resolve(false);
233
- });
234
- });
191
+ try {
192
+ await _downloadFile(url, archivePath, progressCallback);
193
+ await install(archivePath, outputPath);
235
194
  }
236
- /**
237
- * Initiates a GET request to download the revision from the host.
238
- * @remarks
239
- * This method is affected by the current `product`.
240
- * @param revision - The revision to download.
241
- * @param progressCallback - A function that will be called with two arguments:
242
- * How many bytes have been downloaded and the total number of bytes of the download.
243
- * @returns A promise with revision information when the revision is downloaded
244
- * and extracted.
245
- */
246
- async download(revision, progressCallback = () => undefined) {
247
- const url = _downloadURL(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"), __classPrivateFieldGet(this, _BrowserFetcher_downloadHost, "f"), revision);
248
- const fileName = url.split('/').pop();
249
- (0, assert_1.assert)(fileName, `A malformed download URL was found: ${url}.`);
250
- const archivePath = path.join(__classPrivateFieldGet(this, _BrowserFetcher_downloadsFolder, "f"), fileName);
251
- const outputPath = __classPrivateFieldGet(this, _BrowserFetcher_instances, "m", _BrowserFetcher_getFolderPath).call(this, revision);
252
- if (await existsAsync(outputPath)) {
253
- return this.revisionInfo(revision);
254
- }
255
- if (!(await existsAsync(__classPrivateFieldGet(this, _BrowserFetcher_downloadsFolder, "f")))) {
256
- await mkdirAsync(__classPrivateFieldGet(this, _BrowserFetcher_downloadsFolder, "f"), {
257
- recursive: true,
258
- });
195
+ finally {
196
+ if (await existsAsync(archivePath)) {
197
+ await unlinkAsync(archivePath);
259
198
  }
260
- // Use system Chromium builds on Linux ARM devices
261
- if (os.platform() !== 'darwin' && os.arch() === 'arm64') {
262
- handleArm64();
263
- return;
264
- }
265
- try {
266
- await _downloadFile(url, archivePath, progressCallback);
267
- await install(archivePath, outputPath);
268
- }
269
- finally {
270
- if (await existsAsync(archivePath)) {
271
- await unlinkAsync(archivePath);
272
- }
199
+ }
200
+ const revisionInfo = (0, exports.getRevisionInfo)(revision, product);
201
+ if (revisionInfo) {
202
+ await chmodAsync(revisionInfo.executablePath, 0o755);
203
+ }
204
+ return revisionInfo;
205
+ };
206
+ exports.download = download;
207
+ const localRevisions = async (downloadsFolder, product, platform) => {
208
+ if (!(await existsAsync(downloadsFolder))) {
209
+ return [];
210
+ }
211
+ const fileNames = await readdirAsync(downloadsFolder);
212
+ return fileNames
213
+ .map((fileName) => {
214
+ return parseFolderPath(product, fileName);
215
+ })
216
+ .filter((entry) => {
217
+ var _a;
218
+ return (_a = (entry && entry.platform === platform)) !== null && _a !== void 0 ? _a : false;
219
+ })
220
+ .map((entry) => {
221
+ return entry.revision;
222
+ });
223
+ };
224
+ exports.localRevisions = localRevisions;
225
+ const removeBrowser = async (revision, folderPath) => {
226
+ (0, assert_1.assert)(await existsAsync(folderPath), `Failed to remove: revision ${revision} is not downloaded`);
227
+ (0, delete_directory_1.deleteDirectory)(folderPath);
228
+ };
229
+ exports.removeBrowser = removeBrowser;
230
+ const getFolderPath = (revision, downloadsFolder, platform) => {
231
+ return path.resolve(downloadsFolder, `${platform}-${revision}`);
232
+ };
233
+ exports.getFolderPath = getFolderPath;
234
+ const getExecutablePath = (product, revision) => {
235
+ const downloadsFolder = (0, exports.getDownloadsFolder)(product);
236
+ const platform = (0, exports.getPlatform)(product);
237
+ const folderPath = (0, exports.getFolderPath)(revision, downloadsFolder, platform);
238
+ if (product === 'chrome') {
239
+ if (platform === 'mac' || platform === 'mac_arm') {
240
+ return path.join(folderPath, archiveName(product, platform, revision), 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
273
241
  }
274
- const revisionInfo = this.revisionInfo(revision);
275
- if (revisionInfo) {
276
- await chmodAsync(revisionInfo.executablePath, 0o755);
242
+ if (platform === 'linux') {
243
+ return path.join(folderPath, archiveName(product, platform, revision), 'chrome');
277
244
  }
278
- return revisionInfo;
279
- }
280
- /**
281
- * @remarks
282
- * This method is affected by the current `product`.
283
- * @returns A promise with a list of all revision strings (for the current `product`)
284
- * available locally on disk.
285
- */
286
- async localRevisions() {
287
- if (!(await existsAsync(__classPrivateFieldGet(this, _BrowserFetcher_downloadsFolder, "f")))) {
288
- return [];
245
+ if (platform === 'win32' || platform === 'win64') {
246
+ return path.join(folderPath, archiveName(product, platform, revision), 'thorium.exe');
289
247
  }
290
- const fileNames = await readdirAsync(__classPrivateFieldGet(this, _BrowserFetcher_downloadsFolder, "f"));
291
- return fileNames
292
- .map((fileName) => {
293
- return parseFolderPath(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), fileName);
294
- })
295
- .filter((entry) => {
296
- var _a;
297
- return (_a = (entry && entry.platform === __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"))) !== null && _a !== void 0 ? _a : false;
298
- })
299
- .map((entry) => {
300
- return entry.revision;
301
- });
302
- }
303
- /**
304
- * @remarks
305
- * This method is affected by the current `product`.
306
- * @param revision - A revision to remove for the current `product`.
307
- * @returns A promise that resolves when the revision has been removes or
308
- * throws if the revision has not been downloaded.
309
- */
310
- async remove(revision) {
311
- const folderPath = __classPrivateFieldGet(this, _BrowserFetcher_instances, "m", _BrowserFetcher_getFolderPath).call(this, revision);
312
- (0, assert_1.assert)(await existsAsync(folderPath), `Failed to remove: revision ${revision} is not downloaded`);
313
- (0, delete_directory_1.deleteDirectory)(folderPath);
248
+ throw new Error('Unsupported platform: ' + platform);
314
249
  }
315
- /**
316
- * @param revision - The revision to get info for.
317
- * @returns The revision info for the given revision.
318
- */
319
- revisionInfo(revision) {
320
- const folderPath = __classPrivateFieldGet(this, _BrowserFetcher_instances, "m", _BrowserFetcher_getFolderPath).call(this, revision);
321
- let executablePath = '';
322
- if (__classPrivateFieldGet(this, _BrowserFetcher_product, "f") === 'chrome') {
323
- if (__classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'mac' || __classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'mac_arm') {
324
- executablePath = path.join(folderPath, archiveName(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"), revision), 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
325
- }
326
- else if (__classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'linux') {
327
- executablePath = path.join(folderPath, archiveName(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"), revision), 'chrome');
328
- }
329
- else if (__classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'win32' || __classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'win64') {
330
- executablePath = path.join(folderPath, archiveName(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"), revision), 'thorium.exe');
331
- }
332
- else {
333
- throw new Error('Unsupported platform: ' + __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"));
334
- }
250
+ if (product === 'firefox') {
251
+ if (platform === 'mac' || platform === 'mac_arm') {
252
+ return path.join(folderPath, 'Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
335
253
  }
336
- else if (__classPrivateFieldGet(this, _BrowserFetcher_product, "f") === 'firefox') {
337
- if (__classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'mac' || __classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'mac_arm') {
338
- executablePath = path.join(folderPath, 'Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
339
- }
340
- else if (__classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'linux') {
341
- executablePath = path.join(folderPath, 'firefox', 'firefox');
342
- }
343
- else if (__classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'win32' || __classPrivateFieldGet(this, _BrowserFetcher_platform, "f") === 'win64') {
344
- executablePath = path.join(folderPath, 'firefox', 'firefox.exe');
345
- }
346
- else {
347
- throw new Error('Unsupported platform: ' + __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"));
348
- }
254
+ if (platform === 'linux') {
255
+ return path.join(folderPath, 'firefox', 'firefox');
349
256
  }
350
- else {
351
- throw new Error('Unsupported product: ' + __classPrivateFieldGet(this, _BrowserFetcher_product, "f"));
257
+ if (platform === 'win32' || platform === 'win64') {
258
+ return path.join(folderPath, 'firefox', 'firefox.exe');
352
259
  }
353
- const url = _downloadURL(__classPrivateFieldGet(this, _BrowserFetcher_product, "f"), __classPrivateFieldGet(this, _BrowserFetcher_platform, "f"), __classPrivateFieldGet(this, _BrowserFetcher_downloadHost, "f"), revision);
354
- const local = fs.existsSync(folderPath);
355
- return {
356
- revision,
357
- executablePath,
358
- folderPath,
359
- local,
360
- url,
361
- product: __classPrivateFieldGet(this, _BrowserFetcher_product, "f"),
362
- };
260
+ throw new Error('Unsupported platform: ' + platform);
363
261
  }
364
- }
365
- exports.BrowserFetcher = BrowserFetcher;
366
- _BrowserFetcher_product = new WeakMap(), _BrowserFetcher_downloadsFolder = new WeakMap(), _BrowserFetcher_downloadHost = new WeakMap(), _BrowserFetcher_platform = new WeakMap(), _BrowserFetcher_instances = new WeakSet(), _BrowserFetcher_getFolderPath = function _BrowserFetcher_getFolderPath(revision) {
367
- return path.resolve(__classPrivateFieldGet(this, _BrowserFetcher_downloadsFolder, "f"), `${__classPrivateFieldGet(this, _BrowserFetcher_platform, "f")}-${revision}`);
262
+ throw new Error('Unsupported product: ' + product);
263
+ };
264
+ const getRevisionInfo = (revision, product) => {
265
+ const executablePath = getExecutablePath(product, revision);
266
+ const downloadsFolder = (0, exports.getDownloadsFolder)(product);
267
+ const platform = (0, exports.getPlatform)(product);
268
+ const folderPath = (0, exports.getFolderPath)(revision, downloadsFolder, platform);
269
+ const url = _downloadURL(product, platform, (0, exports.getDownloadHost)(product), revision);
270
+ const local = fs.existsSync(folderPath);
271
+ return {
272
+ revision,
273
+ executablePath,
274
+ folderPath,
275
+ local,
276
+ url,
277
+ product,
278
+ };
368
279
  };
280
+ exports.getRevisionInfo = getRevisionInfo;
369
281
  function parseFolderPath(product, folderPath) {
370
282
  const name = path.basename(folderPath);
371
283
  const splits = name.split('-');
@@ -47,8 +47,8 @@ const os = __importStar(require("os"));
47
47
  const path = __importStar(require("path"));
48
48
  const assert_1 = require("./assert");
49
49
  const Browser_1 = require("./Browser");
50
- const BrowserFetcher_1 = require("./BrowserFetcher");
51
50
  const BrowserRunner_1 = require("./BrowserRunner");
51
+ const BrowserFetcher_1 = require("./BrowserFetcher");
52
52
  const tmpDir = () => {
53
53
  return process.env.PUPPETEER_TMP_DIR || os.tmpdir();
54
54
  };
@@ -131,12 +131,7 @@ class ChromeLauncher {
131
131
  exports.ChromeLauncher = ChromeLauncher;
132
132
  function resolveExecutablePath(launcher) {
133
133
  const { product, _preferredRevision } = launcher;
134
- const browserFetcher = new BrowserFetcher_1.BrowserFetcher({
135
- product,
136
- path: null,
137
- platform: null,
138
- });
139
- const revisionInfo = browserFetcher.revisionInfo(_preferredRevision);
134
+ const revisionInfo = (0, BrowserFetcher_1.getRevisionInfo)(_preferredRevision, 'chrome');
140
135
  const firefoxHelp = `Run \`PUPPETEER_PRODUCT=firefox npm install\` to download a supported Firefox browser binary.`;
141
136
  const chromeHelp = `Run \`npm install\` to download the correct Chromium revision (${launcher._preferredRevision}).`;
142
137
  const missingText = revisionInfo.local
@@ -15,8 +15,6 @@
15
15
  */
16
16
  import type { Browser } from './Browser';
17
17
  import type { BrowserConnectOptions } from './BrowserConnector';
18
- import type { BrowserFetcherOptions } from './BrowserFetcher';
19
- import { BrowserFetcher } from './BrowserFetcher';
20
18
  import type { ProductLauncher } from './Launcher';
21
19
  import type { BrowserLaunchArgumentOptions, LaunchOptions } from './LaunchOptions';
22
20
  import type { Product } from './Product';
@@ -35,6 +33,5 @@ export declare class PuppeteerNode {
35
33
  executablePath(channel?: string): string;
36
34
  get _launcher(): ProductLauncher;
37
35
  get product(): string;
38
- createBrowserFetcher(options: BrowserFetcherOptions): BrowserFetcher;
39
36
  }
40
37
  export {};
@@ -28,7 +28,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
28
28
  var _PuppeteerNode_lazyLauncher, _PuppeteerNode_productName;
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.PuppeteerNode = void 0;
31
- const BrowserFetcher_1 = require("./BrowserFetcher");
32
31
  const Launcher_1 = require("./Launcher");
33
32
  const revisions_1 = require("./revisions");
34
33
  class PuppeteerNode {
@@ -40,7 +39,6 @@ class PuppeteerNode {
40
39
  this._preferredRevision = preferredRevision;
41
40
  this.launch = this.launch.bind(this);
42
41
  this.executablePath = this.executablePath.bind(this);
43
- this.createBrowserFetcher = this.createBrowserFetcher.bind(this);
44
42
  }
45
43
  launch(options) {
46
44
  if (options.product) {
@@ -66,9 +64,6 @@ class PuppeteerNode {
66
64
  get product() {
67
65
  return this._launcher.product;
68
66
  }
69
- createBrowserFetcher(options) {
70
- return new BrowserFetcher_1.BrowserFetcher(options);
71
- }
72
67
  }
73
68
  exports.PuppeteerNode = PuppeteerNode;
74
69
  _PuppeteerNode_lazyLauncher = new WeakMap(), _PuppeteerNode_productName = new WeakMap();