@remotion/renderer 4.0.17 → 4.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/BrowserFetcher.d.ts +2 -19
- package/dist/browser/BrowserFetcher.js +73 -263
- package/dist/browser/LaunchOptions.d.ts +0 -2
- package/dist/browser/Launcher.d.ts +0 -5
- package/dist/browser/Launcher.js +5 -14
- package/dist/browser/PuppeteerNode.d.ts +1 -8
- package/dist/browser/PuppeteerNode.js +10 -27
- package/dist/browser/node.js +1 -5
- package/dist/browser.d.ts +1 -1
- package/dist/client.d.ts +48 -48
- package/dist/compositor/payloads.d.ts +18 -0
- package/dist/get-extension-from-codec.d.ts +2 -2
- package/dist/get-local-browser-executable.d.ts +2 -3
- package/dist/get-local-browser-executable.js +45 -53
- package/dist/get-silent-parts.d.ts +8 -0
- package/dist/get-silent-parts.js +56 -0
- package/dist/index.d.ts +45 -42
- package/dist/index.js +4 -1
- package/dist/open-browser.js +3 -3
- package/dist/render-media.js +5 -2
- package/dist/set-props-and-env.js +6 -3
- package/dist/stitch-frames-to-video.d.ts +1 -0
- package/dist/validate-opengl-renderer.d.ts +2 -3
- package/dist/validate-opengl-renderer.js +9 -4
- package/dist/validate-output-filename.d.ts +1 -1
- package/package.json +9 -10
|
@@ -13,29 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { Product } from './Product';
|
|
17
|
-
type Platform = 'linux' | 'mac' | 'mac_arm' | 'win32' | 'win64';
|
|
18
16
|
interface BrowserFetcherRevisionInfo {
|
|
19
17
|
folderPath: string;
|
|
20
18
|
executablePath: string;
|
|
21
19
|
url: string;
|
|
22
20
|
local: boolean;
|
|
23
|
-
revision: string;
|
|
24
|
-
product: string;
|
|
25
21
|
}
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
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;
|
|
22
|
+
export declare const downloadBrowser: () => Promise<BrowserFetcherRevisionInfo | undefined>;
|
|
23
|
+
export declare const getRevisionInfo: () => BrowserFetcherRevisionInfo;
|
|
41
24
|
export {};
|
|
@@ -41,95 +41,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.getRevisionInfo = exports.
|
|
45
|
-
const https = __importStar(require("https"));
|
|
44
|
+
exports.getRevisionInfo = exports.downloadBrowser = void 0;
|
|
46
45
|
const childProcess = __importStar(require("node:child_process"));
|
|
47
46
|
const fs = __importStar(require("node:fs"));
|
|
48
|
-
const http = __importStar(require("node:http"));
|
|
49
47
|
const os = __importStar(require("node:os"));
|
|
50
48
|
const path = __importStar(require("node:path"));
|
|
51
|
-
const node_util_1 = __importDefault(require("node:util"));
|
|
52
49
|
const extract_zip_1 = __importDefault(require("extract-zip"));
|
|
53
|
-
const
|
|
54
|
-
const node_util_2 = require("node:util");
|
|
50
|
+
const node_util_1 = require("node:util");
|
|
55
51
|
const assert_1 = require("./assert");
|
|
56
|
-
const
|
|
52
|
+
const download_file_1 = require("../assets/download-file");
|
|
53
|
+
const logger_1 = require("../logger");
|
|
57
54
|
const get_download_destination_1 = require("./get-download-destination");
|
|
58
|
-
const { PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM } = process.env;
|
|
59
55
|
const downloadURLs = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
win32: '%s/chromium-browser-snapshots/Win/%d/%s.zip',
|
|
65
|
-
win64: '%s/chromium-browser-snapshots/Win_x64/%d/%s.zip',
|
|
66
|
-
},
|
|
67
|
-
firefox: {
|
|
68
|
-
linux: '%s/firefox-%s.en-US.%s-x86_64.tar.bz2',
|
|
69
|
-
mac: '%s/firefox-%s.en-US.%s.dmg',
|
|
70
|
-
win32: '%s/firefox-%s.en-US.%s.zip',
|
|
71
|
-
win64: '%s/firefox-%s.en-US.%s.zip',
|
|
72
|
-
},
|
|
56
|
+
linux: 'https://github.com/Alex313031/thorium/releases/download/M114.0.5735.205/thorium-browser_114.0.5735.205_amd64.zip',
|
|
57
|
+
mac: 'https://github.com/Alex313031/Thorium-Special/releases/download/M114.0.5735.205-1/Thorium_MacOS_X64.dmg',
|
|
58
|
+
mac_arm: 'https://github.com/Alex313031/Thorium-Special/releases/download/M114.0.5735.205-1/Thorium_MacOS_ARM.dmg',
|
|
59
|
+
win64: 'https://github.com/Alex313031/Thorium-Win/releases/download/M114.0.5735.205/Thorium_114.0.5735.205.zip',
|
|
73
60
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
host: 'https://storage.googleapis.com',
|
|
77
|
-
destination: '.chromium',
|
|
78
|
-
},
|
|
79
|
-
firefox: {
|
|
80
|
-
host: 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central',
|
|
81
|
-
destination: '.firefox',
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
function archiveName(product, platform, revision) {
|
|
85
|
-
switch (product) {
|
|
86
|
-
case 'chrome':
|
|
87
|
-
switch (platform) {
|
|
88
|
-
case 'linux':
|
|
89
|
-
return 'chrome-linux';
|
|
90
|
-
case 'mac_arm':
|
|
91
|
-
case 'mac':
|
|
92
|
-
return 'chrome-mac';
|
|
93
|
-
case 'win32':
|
|
94
|
-
case 'win64':
|
|
95
|
-
// Windows archive name changed at r591479.
|
|
96
|
-
return parseInt(revision, 10) > 591479
|
|
97
|
-
? 'Thorium_107.0.5271.0\\BIN'
|
|
98
|
-
: 'chrome-win32';
|
|
99
|
-
default:
|
|
100
|
-
throw new Error('unknown browser');
|
|
101
|
-
}
|
|
102
|
-
case 'firefox':
|
|
103
|
-
return platform;
|
|
104
|
-
default:
|
|
105
|
-
throw new Error('unknown browser');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function _downloadURL(product, platform, host, revision) {
|
|
109
|
-
if (platform === 'win64' || platform === 'win32') {
|
|
110
|
-
return 'https://remotionchromium-binaries.s3.eu-central-1.amazonaws.com/thorium-107.zip';
|
|
111
|
-
}
|
|
112
|
-
return node_util_1.default.format(downloadURLs[product][platform], host, revision, archiveName(product, platform, revision));
|
|
61
|
+
function getThoriumDownloadUrl(platform) {
|
|
62
|
+
return downloadURLs[platform];
|
|
113
63
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
exists = fs.existsSync('/usr/bin/chromium');
|
|
120
|
-
if (exists) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
console.error('The chromium binary is not available for arm64.' +
|
|
124
|
-
'\nIf you are on Ubuntu, you can install with: ' +
|
|
125
|
-
'\n\n sudo apt install chromium\n' +
|
|
126
|
-
'\n\n sudo apt install chromium-browser\n');
|
|
127
|
-
throw new Error();
|
|
128
|
-
}
|
|
129
|
-
const readdirAsync = (0, node_util_2.promisify)(fs.readdir.bind(fs));
|
|
130
|
-
const mkdirAsync = (0, node_util_2.promisify)(fs.mkdir.bind(fs));
|
|
131
|
-
const unlinkAsync = (0, node_util_2.promisify)(fs.unlink.bind(fs));
|
|
132
|
-
const chmodAsync = (0, node_util_2.promisify)(fs.chmod.bind(fs));
|
|
64
|
+
const readdirAsync = fs.promises.readdir;
|
|
65
|
+
const mkdirAsync = fs.promises.mkdir;
|
|
66
|
+
const unlinkAsync = (0, node_util_1.promisify)(fs.unlink.bind(fs));
|
|
67
|
+
const chmodAsync = (0, node_util_1.promisify)(fs.chmod.bind(fs));
|
|
133
68
|
function existsAsync(filePath) {
|
|
134
69
|
return new Promise((resolve) => {
|
|
135
70
|
fs.access(filePath, (err) => {
|
|
@@ -137,46 +72,33 @@ function existsAsync(filePath) {
|
|
|
137
72
|
});
|
|
138
73
|
});
|
|
139
74
|
}
|
|
140
|
-
const getPlatform = (
|
|
75
|
+
const getPlatform = () => {
|
|
141
76
|
const platform = os.platform();
|
|
142
77
|
switch (platform) {
|
|
143
78
|
case 'darwin':
|
|
144
|
-
|
|
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';
|
|
152
|
-
default:
|
|
153
|
-
throw new Error('unknown browser');
|
|
154
|
-
}
|
|
79
|
+
return os.arch() === 'arm64' ? 'mac_arm' : 'mac';
|
|
155
80
|
case 'linux':
|
|
156
81
|
return 'linux';
|
|
157
82
|
case 'win32':
|
|
158
|
-
return
|
|
83
|
+
return 'win64';
|
|
159
84
|
default:
|
|
160
85
|
(0, assert_1.assert)(false, 'Unsupported platform: ' + platform);
|
|
161
86
|
}
|
|
162
87
|
};
|
|
163
|
-
|
|
164
|
-
const getDownloadsFolder = (
|
|
165
|
-
return path.join((0, get_download_destination_1.getDownloadsCacheDir)(),
|
|
166
|
-
};
|
|
167
|
-
exports.getDownloadsFolder = getDownloadsFolder;
|
|
168
|
-
const getDownloadHost = (product) => {
|
|
169
|
-
return browserConfig[product].host;
|
|
88
|
+
const destination = '.thorium';
|
|
89
|
+
const getDownloadsFolder = () => {
|
|
90
|
+
return path.join((0, get_download_destination_1.getDownloadsCacheDir)(), destination);
|
|
170
91
|
};
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
const fileName =
|
|
175
|
-
(0, assert_1.assert)(fileName, `A malformed download URL was found: ${
|
|
92
|
+
const downloadBrowser = async () => {
|
|
93
|
+
const platform = getPlatform();
|
|
94
|
+
const downloadURL = getThoriumDownloadUrl(platform);
|
|
95
|
+
const fileName = downloadURL.split('/').pop();
|
|
96
|
+
(0, assert_1.assert)(fileName, `A malformed download URL was found: ${downloadURL}.`);
|
|
97
|
+
const downloadsFolder = getDownloadsFolder();
|
|
176
98
|
const archivePath = path.join(downloadsFolder, fileName);
|
|
177
|
-
const outputPath =
|
|
99
|
+
const outputPath = getFolderPath(downloadsFolder, platform);
|
|
178
100
|
if (await existsAsync(outputPath)) {
|
|
179
|
-
return (0, exports.getRevisionInfo)(
|
|
101
|
+
return (0, exports.getRevisionInfo)();
|
|
180
102
|
}
|
|
181
103
|
if (!(await existsAsync(downloadsFolder))) {
|
|
182
104
|
await mkdirAsync(downloadsFolder, {
|
|
@@ -185,163 +107,75 @@ const download = async ({ revision, progressCallback, product, platform, downloa
|
|
|
185
107
|
}
|
|
186
108
|
// Use system Chromium builds on Linux ARM devices
|
|
187
109
|
if (os.platform() !== 'darwin' && os.arch() === 'arm64') {
|
|
188
|
-
|
|
189
|
-
|
|
110
|
+
throw new Error('The chromium binary is not available for arm64.' +
|
|
111
|
+
'\nIf you are on Ubuntu, you can install with: ' +
|
|
112
|
+
'\n\n sudo apt install chromium\n' +
|
|
113
|
+
'\n\n sudo apt install chromium-browser\n');
|
|
190
114
|
}
|
|
191
115
|
try {
|
|
192
|
-
|
|
193
|
-
await
|
|
116
|
+
let lastProgress = 0;
|
|
117
|
+
await (0, download_file_1.downloadFile)({
|
|
118
|
+
url: downloadURL,
|
|
119
|
+
to: () => archivePath,
|
|
120
|
+
onProgress: (progress) => {
|
|
121
|
+
if (progress.downloaded > lastProgress + 10000000) {
|
|
122
|
+
lastProgress = progress.downloaded;
|
|
123
|
+
logger_1.Log.info(`Downloading Thorium - ${toMegabytes(progress.downloaded)}/${toMegabytes(progress.totalSize)}`);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
await install({ archivePath, folderPath: outputPath });
|
|
194
128
|
}
|
|
195
129
|
finally {
|
|
196
130
|
if (await existsAsync(archivePath)) {
|
|
197
131
|
await unlinkAsync(archivePath);
|
|
198
132
|
}
|
|
199
133
|
}
|
|
200
|
-
const revisionInfo = (0, exports.getRevisionInfo)(
|
|
201
|
-
|
|
202
|
-
await chmodAsync(revisionInfo.executablePath, 0o755);
|
|
203
|
-
}
|
|
134
|
+
const revisionInfo = (0, exports.getRevisionInfo)();
|
|
135
|
+
await chmodAsync(revisionInfo.executablePath, 0o755);
|
|
204
136
|
return revisionInfo;
|
|
205
137
|
};
|
|
206
|
-
exports.
|
|
207
|
-
const
|
|
208
|
-
|
|
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}`);
|
|
138
|
+
exports.downloadBrowser = downloadBrowser;
|
|
139
|
+
const getFolderPath = (downloadsFolder, platform) => {
|
|
140
|
+
return path.resolve(downloadsFolder, platform);
|
|
232
141
|
};
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (platform === 'mac' || platform === 'mac_arm') {
|
|
240
|
-
return path.join(folderPath, archiveName(product, platform, revision), 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
|
|
241
|
-
}
|
|
242
|
-
if (platform === 'linux') {
|
|
243
|
-
return path.join(folderPath, archiveName(product, platform, revision), 'chrome');
|
|
244
|
-
}
|
|
245
|
-
if (platform === 'win32' || platform === 'win64') {
|
|
246
|
-
return path.join(folderPath, archiveName(product, platform, revision), 'thorium.exe');
|
|
247
|
-
}
|
|
248
|
-
throw new Error('Unsupported platform: ' + platform);
|
|
142
|
+
const getExecutablePath = () => {
|
|
143
|
+
const downloadsFolder = getDownloadsFolder();
|
|
144
|
+
const platform = getPlatform();
|
|
145
|
+
const folderPath = getFolderPath(downloadsFolder, platform);
|
|
146
|
+
if (platform === 'mac' || platform === 'mac_arm') {
|
|
147
|
+
return path.join(folderPath, 'Thorium.app', 'Contents', 'MacOS', 'Thorium');
|
|
249
148
|
}
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
return path.join(folderPath, 'Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
|
|
253
|
-
}
|
|
254
|
-
if (platform === 'linux') {
|
|
255
|
-
return path.join(folderPath, 'firefox', 'firefox');
|
|
256
|
-
}
|
|
257
|
-
if (platform === 'win32' || platform === 'win64') {
|
|
258
|
-
return path.join(folderPath, 'firefox', 'firefox.exe');
|
|
259
|
-
}
|
|
260
|
-
throw new Error('Unsupported platform: ' + platform);
|
|
149
|
+
if (platform === 'linux') {
|
|
150
|
+
return path.join(folderPath, 'thorium');
|
|
261
151
|
}
|
|
262
|
-
|
|
152
|
+
if (platform === 'win64') {
|
|
153
|
+
return path.join(folderPath, 'BIN', 'thorium.exe');
|
|
154
|
+
}
|
|
155
|
+
throw new Error('Can not download browser for platform: ' + platform);
|
|
263
156
|
};
|
|
264
|
-
const getRevisionInfo = (
|
|
265
|
-
const executablePath = getExecutablePath(
|
|
266
|
-
const downloadsFolder =
|
|
267
|
-
const platform =
|
|
268
|
-
const folderPath =
|
|
269
|
-
const url =
|
|
157
|
+
const getRevisionInfo = () => {
|
|
158
|
+
const executablePath = getExecutablePath();
|
|
159
|
+
const downloadsFolder = getDownloadsFolder();
|
|
160
|
+
const platform = getPlatform();
|
|
161
|
+
const folderPath = getFolderPath(downloadsFolder, platform);
|
|
162
|
+
const url = getThoriumDownloadUrl(platform);
|
|
270
163
|
const local = fs.existsSync(folderPath);
|
|
271
164
|
return {
|
|
272
|
-
revision,
|
|
273
165
|
executablePath,
|
|
274
166
|
folderPath,
|
|
275
167
|
local,
|
|
276
168
|
url,
|
|
277
|
-
product,
|
|
278
169
|
};
|
|
279
170
|
};
|
|
280
171
|
exports.getRevisionInfo = getRevisionInfo;
|
|
281
|
-
function
|
|
282
|
-
const name = path.basename(folderPath);
|
|
283
|
-
const splits = name.split('-');
|
|
284
|
-
if (splits.length !== 2) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
const [platform, revision] = splits;
|
|
288
|
-
if (!revision || !platform || !(platform in downloadURLs[product])) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
return { product, platform, revision };
|
|
292
|
-
}
|
|
293
|
-
function _downloadFile(url, destinationPath, progressCallback) {
|
|
294
|
-
let fulfill;
|
|
295
|
-
let reject;
|
|
296
|
-
const promise = new Promise((x, y) => {
|
|
297
|
-
fulfill = x;
|
|
298
|
-
reject = y;
|
|
299
|
-
});
|
|
300
|
-
let downloadedBytes = 0;
|
|
301
|
-
let totalBytes = 0;
|
|
302
|
-
let lastProgress = Date.now();
|
|
303
|
-
function onData(chunk) {
|
|
304
|
-
downloadedBytes += chunk.length;
|
|
305
|
-
if (Date.now() - lastProgress > 1000) {
|
|
306
|
-
progressCallback(downloadedBytes, totalBytes);
|
|
307
|
-
lastProgress = Date.now();
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
const request = httpRequest(url, 'GET', (response) => {
|
|
311
|
-
if (response.statusCode !== 200) {
|
|
312
|
-
const error = new Error(`Download failed: server returned code ${response.statusCode}. URL: ${url}`);
|
|
313
|
-
// consume response data to free up memory
|
|
314
|
-
response.resume();
|
|
315
|
-
reject(error);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const file = fs.createWriteStream(destinationPath);
|
|
319
|
-
file.on('close', () => {
|
|
320
|
-
return fulfill(totalBytes);
|
|
321
|
-
});
|
|
322
|
-
file.on('error', (error) => {
|
|
323
|
-
return reject(error);
|
|
324
|
-
});
|
|
325
|
-
response.pipe(file);
|
|
326
|
-
totalBytes = parseInt(response.headers['content-length'], 10);
|
|
327
|
-
response.on('data', onData);
|
|
328
|
-
});
|
|
329
|
-
request.on('error', (error) => {
|
|
330
|
-
return reject(error);
|
|
331
|
-
});
|
|
332
|
-
return promise;
|
|
333
|
-
}
|
|
334
|
-
function install(archivePath, folderPath) {
|
|
172
|
+
async function install({ archivePath, folderPath, }) {
|
|
335
173
|
if (archivePath.endsWith('.zip')) {
|
|
336
174
|
return (0, extract_zip_1.default)(archivePath, { dir: folderPath });
|
|
337
175
|
}
|
|
338
|
-
if (archivePath.endsWith('.tar.bz2')) {
|
|
339
|
-
throw new Error('bz2 currently not implemented');
|
|
340
|
-
}
|
|
341
176
|
if (archivePath.endsWith('.dmg')) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
});
|
|
177
|
+
await mkdirAsync(folderPath);
|
|
178
|
+
return _installDMG(archivePath, folderPath);
|
|
345
179
|
}
|
|
346
180
|
throw new Error(`Unsupported archive format: ${archivePath}`);
|
|
347
181
|
}
|
|
@@ -394,31 +228,7 @@ function _installDMG(dmgPath, folderPath) {
|
|
|
394
228
|
});
|
|
395
229
|
});
|
|
396
230
|
}
|
|
397
|
-
function
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
...urlParsed,
|
|
401
|
-
method,
|
|
402
|
-
headers: keepAlive
|
|
403
|
-
? {
|
|
404
|
-
Connection: 'keep-alive',
|
|
405
|
-
}
|
|
406
|
-
: undefined,
|
|
407
|
-
};
|
|
408
|
-
const requestCallback = (res) => {
|
|
409
|
-
if (res.statusCode &&
|
|
410
|
-
res.statusCode >= 300 &&
|
|
411
|
-
res.statusCode < 400 &&
|
|
412
|
-
res.headers.location) {
|
|
413
|
-
httpRequest(res.headers.location, method, response);
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
response(res);
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
const request = options.protocol === 'https:'
|
|
420
|
-
? https.request(options, requestCallback)
|
|
421
|
-
: http.request(options, requestCallback);
|
|
422
|
-
request.end();
|
|
423
|
-
return request;
|
|
231
|
+
function toMegabytes(bytes) {
|
|
232
|
+
const mb = bytes / 1024 / 1024;
|
|
233
|
+
return `${Math.round(mb * 10) / 10} Mb`;
|
|
424
234
|
}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { LogLevel } from '../log-level';
|
|
17
17
|
import type { BrowserConnectOptions } from './BrowserConnector';
|
|
18
|
-
import type { Product } from './Product';
|
|
19
18
|
export interface BrowserLaunchArgumentOptions {
|
|
20
19
|
headless?: boolean | 'chrome';
|
|
21
20
|
userDataDir?: string;
|
|
@@ -29,7 +28,6 @@ export interface LaunchOptions {
|
|
|
29
28
|
dumpio?: boolean;
|
|
30
29
|
logLevel: LogLevel;
|
|
31
30
|
env?: Record<string, string | undefined>;
|
|
32
|
-
product?: Product;
|
|
33
31
|
indent: boolean;
|
|
34
32
|
}
|
|
35
33
|
export type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions & LaunchOptions & BrowserConnectOptions;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { HeadlessBrowser } from './Browser';
|
|
2
2
|
import type { PuppeteerNodeLaunchOptions } from './LaunchOptions';
|
|
3
|
-
import type { Product } from './Product';
|
|
4
3
|
export interface ProductLauncher {
|
|
5
4
|
launch(object: PuppeteerNodeLaunchOptions): Promise<HeadlessBrowser>;
|
|
6
5
|
executablePath: (path?: any) => string;
|
|
7
|
-
product: Product;
|
|
8
6
|
}
|
|
9
7
|
export declare class ChromeLauncher implements ProductLauncher {
|
|
10
|
-
_preferredRevision: string;
|
|
11
|
-
constructor(preferredRevision: string);
|
|
12
8
|
launch(options: PuppeteerNodeLaunchOptions): Promise<HeadlessBrowser>;
|
|
13
9
|
executablePath(): string;
|
|
14
|
-
get product(): Product;
|
|
15
10
|
}
|
package/dist/browser/Launcher.js
CHANGED
|
@@ -52,9 +52,6 @@ const tmpDir = () => {
|
|
|
52
52
|
return process.env.PUPPETEER_TMP_DIR || os.tmpdir();
|
|
53
53
|
};
|
|
54
54
|
class ChromeLauncher {
|
|
55
|
-
constructor(preferredRevision) {
|
|
56
|
-
this._preferredRevision = preferredRevision;
|
|
57
|
-
}
|
|
58
55
|
async launch(options) {
|
|
59
56
|
const { args = [], dumpio = false, executablePath, env = process.env, defaultViewport, timeout = 60000, debuggingPort, indent, } = options;
|
|
60
57
|
const chromeArguments = args;
|
|
@@ -69,7 +66,7 @@ class ChromeLauncher {
|
|
|
69
66
|
chromeArguments.push(`--user-data-dir=${userDataDir}`);
|
|
70
67
|
let chromeExecutable = executablePath;
|
|
71
68
|
if (!chromeExecutable) {
|
|
72
|
-
const { missingText, executablePath: exPath } = resolveExecutablePath(
|
|
69
|
+
const { missingText, executablePath: exPath } = resolveExecutablePath();
|
|
73
70
|
if (missingText) {
|
|
74
71
|
throw new Error(missingText);
|
|
75
72
|
}
|
|
@@ -113,21 +110,15 @@ class ChromeLauncher {
|
|
|
113
110
|
return browser;
|
|
114
111
|
}
|
|
115
112
|
executablePath() {
|
|
116
|
-
const results = resolveExecutablePath(
|
|
113
|
+
const results = resolveExecutablePath();
|
|
117
114
|
return results.executablePath;
|
|
118
115
|
}
|
|
119
|
-
get product() {
|
|
120
|
-
return 'chrome';
|
|
121
|
-
}
|
|
122
116
|
}
|
|
123
117
|
exports.ChromeLauncher = ChromeLauncher;
|
|
124
|
-
function resolveExecutablePath(
|
|
125
|
-
const
|
|
126
|
-
const revisionInfo = (0, BrowserFetcher_1.getRevisionInfo)(_preferredRevision, 'chrome');
|
|
127
|
-
const firefoxHelp = `Run \`PUPPETEER_PRODUCT=firefox npm install\` to download a supported Firefox browser binary.`;
|
|
128
|
-
const chromeHelp = `Run \`npm install\` to download the correct Chromium revision.`;
|
|
118
|
+
function resolveExecutablePath() {
|
|
119
|
+
const revisionInfo = (0, BrowserFetcher_1.getRevisionInfo)();
|
|
129
120
|
const missingText = revisionInfo.local
|
|
130
121
|
? undefined
|
|
131
|
-
: `Could not find expected browser
|
|
122
|
+
: `Could not find expected browser locally.`;
|
|
132
123
|
return { executablePath: revisionInfo.executablePath, missingText };
|
|
133
124
|
}
|
|
@@ -17,21 +17,14 @@ import type { HeadlessBrowser } from './Browser';
|
|
|
17
17
|
import type { BrowserConnectOptions } from './BrowserConnector';
|
|
18
18
|
import type { ProductLauncher } from './Launcher';
|
|
19
19
|
import type { BrowserLaunchArgumentOptions, LaunchOptions } from './LaunchOptions';
|
|
20
|
-
import type { Product } from './Product';
|
|
21
20
|
interface PuppeteerLaunchOptions extends LaunchOptions, BrowserLaunchArgumentOptions, BrowserConnectOptions {
|
|
22
|
-
product?: Product;
|
|
23
21
|
extraPrefsFirefox?: Record<string, unknown>;
|
|
24
22
|
}
|
|
25
23
|
export declare class PuppeteerNode {
|
|
26
24
|
#private;
|
|
27
|
-
|
|
28
|
-
constructor(settings: {
|
|
29
|
-
preferredRevision: string;
|
|
30
|
-
productName?: Product;
|
|
31
|
-
});
|
|
25
|
+
constructor();
|
|
32
26
|
launch(options: PuppeteerLaunchOptions): Promise<HeadlessBrowser>;
|
|
33
27
|
executablePath(channel?: string): string;
|
|
34
28
|
get _launcher(): ProductLauncher;
|
|
35
|
-
get product(): string;
|
|
36
29
|
}
|
|
37
30
|
export {};
|
|
@@ -14,56 +14,39 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
17
22
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
18
23
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
19
24
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
20
25
|
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");
|
|
21
26
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
22
27
|
};
|
|
23
|
-
var
|
|
24
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
25
|
-
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");
|
|
26
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
27
|
-
};
|
|
28
|
-
var _PuppeteerNode_lazyLauncher, _PuppeteerNode_productName;
|
|
28
|
+
var _PuppeteerNode_lazyLauncher;
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.PuppeteerNode = void 0;
|
|
31
31
|
const Launcher_1 = require("./Launcher");
|
|
32
|
-
const revisions_1 = require("./revisions");
|
|
33
32
|
class PuppeteerNode {
|
|
34
|
-
constructor(
|
|
33
|
+
constructor() {
|
|
35
34
|
_PuppeteerNode_lazyLauncher.set(this, void 0);
|
|
36
|
-
_PuppeteerNode_productName.set(this, void 0);
|
|
37
|
-
const { preferredRevision, productName } = settings;
|
|
38
|
-
__classPrivateFieldSet(this, _PuppeteerNode_productName, productName, "f");
|
|
39
|
-
this._preferredRevision = preferredRevision;
|
|
40
35
|
this.launch = this.launch.bind(this);
|
|
41
36
|
this.executablePath = this.executablePath.bind(this);
|
|
42
37
|
}
|
|
43
38
|
launch(options) {
|
|
44
|
-
if (options.product) {
|
|
45
|
-
__classPrivateFieldSet(this, _PuppeteerNode_productName, options.product, "f");
|
|
46
|
-
}
|
|
47
39
|
return this._launcher.launch(options);
|
|
48
40
|
}
|
|
49
41
|
executablePath(channel) {
|
|
50
42
|
return this._launcher.executablePath(channel);
|
|
51
43
|
}
|
|
52
44
|
get _launcher() {
|
|
53
|
-
if (!__classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f")
|
|
54
|
-
|
|
55
|
-
switch (__classPrivateFieldGet(this, _PuppeteerNode_productName, "f")) {
|
|
56
|
-
case 'chrome':
|
|
57
|
-
default:
|
|
58
|
-
this._preferredRevision = revisions_1.PUPPETEER_REVISIONS.chromium;
|
|
59
|
-
}
|
|
60
|
-
__classPrivateFieldSet(this, _PuppeteerNode_lazyLauncher, new Launcher_1.ChromeLauncher(this._preferredRevision), "f");
|
|
45
|
+
if (!__classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f")) {
|
|
46
|
+
__classPrivateFieldSet(this, _PuppeteerNode_lazyLauncher, new Launcher_1.ChromeLauncher(), "f");
|
|
61
47
|
}
|
|
62
48
|
return __classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f");
|
|
63
49
|
}
|
|
64
|
-
get product() {
|
|
65
|
-
return this._launcher.product;
|
|
66
|
-
}
|
|
67
50
|
}
|
|
68
51
|
exports.PuppeteerNode = PuppeteerNode;
|
|
69
|
-
_PuppeteerNode_lazyLauncher = new WeakMap()
|
|
52
|
+
_PuppeteerNode_lazyLauncher = new WeakMap();
|
package/dist/browser/node.js
CHANGED
|
@@ -2,8 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.puppeteer = void 0;
|
|
4
4
|
const PuppeteerNode_1 = require("./PuppeteerNode");
|
|
5
|
-
|
|
6
|
-
exports.puppeteer = new PuppeteerNode_1.PuppeteerNode({
|
|
7
|
-
preferredRevision: revisions_1.PUPPETEER_REVISIONS.chromium,
|
|
8
|
-
productName: undefined,
|
|
9
|
-
});
|
|
5
|
+
exports.puppeteer = new PuppeteerNode_1.PuppeteerNode();
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type Browser = 'chrome'
|
|
1
|
+
export type Browser = 'chrome';
|
|
2
2
|
export declare const DEFAULT_BROWSER: Browser;
|