@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.
- package/dist/assets/download-file.d.ts +3 -2
- package/dist/assets/download-file.js +16 -1
- package/dist/browser/BrowserFetcher.d.ts +15 -63
- package/dist/browser/BrowserFetcher.js +125 -213
- package/dist/browser/Launcher.js +2 -7
- package/dist/browser/PuppeteerNode.d.ts +0 -3
- package/dist/browser/PuppeteerNode.js +0 -5
- package/dist/browser/create-browser-fetcher.js +34 -48
- package/dist/browser/is-target-closed-err.d.ts +1 -0
- package/dist/browser/is-target-closed-err.js +9 -0
- package/dist/call-ffmpeg.d.ts +14 -0
- package/dist/call-ffmpeg.js +37 -0
- package/dist/compositor/compositor.d.ts +12 -0
- package/dist/compositor/compositor.js +202 -0
- package/dist/compositor/make-nonce.d.ts +1 -0
- package/dist/compositor/make-nonce.js +8 -0
- package/dist/get-local-browser-executable.js +3 -12
- package/dist/index.d.ts +2 -2
- package/dist/jpeg-quality.d.ts +1 -0
- package/dist/jpeg-quality.js +21 -0
- package/dist/options/audio-bitrate.d.ts +2 -0
- package/dist/options/audio-bitrate.js +11 -0
- package/dist/options/crf.d.ts +2 -0
- package/dist/options/crf.js +11 -0
- package/dist/options/enforce-audio.d.ts +2 -0
- package/dist/options/enforce-audio.js +11 -0
- package/dist/options/jpeg-quality.d.ts +2 -0
- package/dist/options/jpeg-quality.js +11 -0
- package/dist/options/mute.d.ts +2 -0
- package/dist/options/mute.js +11 -0
- package/dist/options/option.d.ts +8 -0
- package/dist/options/option.js +2 -0
- package/dist/options/scale.d.ts +2 -0
- package/dist/options/scale.js +11 -0
- package/dist/options/video-bitrate.d.ts +2 -0
- package/dist/options/video-bitrate.js +11 -0
- package/dist/options/video-codec.d.ts +2 -0
- package/dist/options/video-codec.js +11 -0
- package/package.json +9 -9
|
@@ -2,7 +2,7 @@ declare type Response = {
|
|
|
2
2
|
sizeInBytes: number;
|
|
3
3
|
to: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
declare type Options = {
|
|
6
6
|
url: string;
|
|
7
7
|
to: (contentDisposition: string | null, contentType: string | null) => string;
|
|
8
8
|
onProgress: ((progress: {
|
|
@@ -10,5 +10,6 @@ export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
|
|
|
10
10
|
downloaded: number;
|
|
11
11
|
totalSize: number | null;
|
|
12
12
|
}) => void) | undefined;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare const downloadFile: (options: Options, retries?: number) => Promise<Response>;
|
|
14
15
|
export {};
|
|
@@ -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
|
|
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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
platform
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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.
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
153
|
+
throw new Error('unknown browser');
|
|
192
154
|
}
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
205
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
218
|
-
|
|
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
|
-
|
|
238
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
await chmodAsync(revisionInfo.executablePath, 0o755);
|
|
242
|
+
if (platform === 'linux') {
|
|
243
|
+
return path.join(folderPath, archiveName(product, platform, revision), 'chrome');
|
|
277
244
|
}
|
|
278
|
-
|
|
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
|
-
|
|
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
|
-
|
|
317
|
-
|
|
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
|
-
|
|
337
|
-
|
|
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
|
-
|
|
351
|
-
|
|
257
|
+
if (platform === 'win32' || platform === 'win64') {
|
|
258
|
+
return path.join(folderPath, 'firefox', 'firefox.exe');
|
|
352
259
|
}
|
|
353
|
-
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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('-');
|
package/dist/browser/Launcher.js
CHANGED
|
@@ -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
|
|
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();
|