@remotion/renderer 4.0.0-alpha.217 → 4.0.0-alpha10
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/README.md +5 -37
- package/dist/assets/download-and-map-assets-to-file.js +6 -6
- package/dist/assets/download-file.d.ts +3 -2
- package/dist/assets/download-file.js +18 -3
- package/dist/assets/download-map.d.ts +0 -26
- package/dist/assets/download-map.js +7 -12
- package/dist/assets/get-video-stream-duration.d.ts +5 -2
- package/dist/assets/get-video-stream-duration.js +12 -6
- package/dist/assets/read-file.d.ts +1 -1
- package/dist/assets/read-file.js +2 -2
- package/dist/assets/sanitize-filepath.js +2 -2
- package/dist/browser/Browser.d.ts +4 -4
- package/dist/browser/Browser.js +38 -38
- package/dist/browser/BrowserFetcher.d.ts +15 -63
- package/dist/browser/BrowserFetcher.js +138 -226
- package/dist/browser/BrowserPage.d.ts +4 -4
- package/dist/browser/BrowserRunner.d.ts +1 -1
- package/dist/browser/BrowserRunner.js +9 -22
- package/dist/browser/DOMWorld.d.ts +3 -3
- package/dist/browser/LaunchOptions.d.ts +1 -2
- package/dist/browser/Launcher.d.ts +3 -3
- package/dist/browser/Launcher.js +10 -23
- package/dist/browser/NodeWebSocketTransport.js +4 -4
- package/dist/browser/PuppeteerNode.d.ts +2 -5
- package/dist/browser/PuppeteerNode.js +0 -5
- package/dist/browser/Target.d.ts +2 -2
- package/dist/browser/create-browser-fetcher.js +34 -48
- package/dist/browser/get-download-destination.js +8 -8
- package/dist/browser/util.d.ts +2 -2
- package/dist/call-ffmpeg.d.ts +4 -7
- package/dist/call-ffmpeg.js +24 -16
- package/dist/chalk/index.d.ts +54 -0
- package/dist/chalk/index.js +135 -0
- package/dist/chalk/is-color-supported.d.ts +1 -0
- package/dist/chalk/is-color-supported.js +37 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/codec-supports-media.d.ts +1 -0
- package/dist/codec-supports-media.js +20 -5
- package/dist/combine-videos.js +6 -6
- package/dist/compositor/compose.d.ts +6 -2
- package/dist/compositor/compose.js +43 -20
- package/dist/compositor/compositor.d.ts +4 -8
- package/dist/compositor/compositor.js +67 -53
- package/dist/compositor/get-executable-path.js +3 -0
- package/dist/compositor/payloads.d.ts +34 -7
- package/dist/crf.js +8 -2
- package/dist/delete-directory.js +3 -3
- package/dist/does-have-m2-bug.js +2 -2
- package/dist/ensure-output-directory.js +5 -5
- package/dist/ensure-presentation-timestamp.d.ts +9 -2
- package/dist/ensure-presentation-timestamp.js +13 -5
- package/dist/extract-frame-from-video.d.ts +3 -1
- package/dist/extract-frame-from-video.js +29 -7
- package/dist/ffmpeg-filter-file.js +7 -7
- package/dist/find-closest-package-json.js +6 -6
- package/dist/get-browser-instance.d.ts +2 -2
- package/dist/get-can-extract-frames-fast.d.ts +4 -1
- package/dist/get-can-extract-frames-fast.js +12 -1
- package/dist/get-compositions.d.ts +8 -3
- package/dist/get-compositions.js +6 -2
- package/dist/get-concurrency.js +3 -3
- package/dist/get-extension-of-filename.js +2 -2
- package/dist/get-frame-of-video-slow.d.ts +8 -3
- package/dist/get-frame-of-video-slow.js +11 -3
- package/dist/get-local-browser-executable.js +6 -15
- package/dist/get-video-info.d.ts +5 -2
- package/dist/get-video-info.js +12 -6
- package/dist/get-video-threads-flag.js +3 -3
- package/dist/index.d.ts +92 -16
- package/dist/index.js +15 -6
- package/dist/last-frame-from-video-cache.d.ts +4 -1
- package/dist/last-frame-from-video-cache.js +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.js +61 -0
- package/dist/merge-audio-track.js +2 -2
- package/dist/mime-types.js +2 -2
- package/dist/offthread-video-server.d.ts +12 -6
- package/dist/offthread-video-server.js +66 -56
- package/dist/open-browser.d.ts +3 -3
- package/dist/open-browser.js +1 -1
- package/dist/options/jpeg-quality.js +1 -1
- package/dist/options/video-codec.js +1 -1
- package/dist/prepare-server.d.ts +6 -1
- package/dist/prepare-server.js +15 -7
- package/dist/prespawn-ffmpeg.d.ts +1 -0
- package/dist/prespawn-ffmpeg.js +37 -14
- package/dist/prestitcher-memory-usage.js +2 -2
- package/dist/puppeteer-evaluate.js +2 -2
- package/dist/puppeteer-screenshot.js +1 -1
- package/dist/render-frames.d.ts +9 -4
- package/dist/render-frames.js +28 -12
- package/dist/render-media.d.ts +7 -4
- package/dist/render-media.js +49 -26
- package/dist/render-still.d.ts +10 -3
- package/dist/render-still.js +26 -9
- package/dist/replace-browser.d.ts +4 -4
- package/dist/resolve-asset-src.js +2 -2
- package/dist/screenshot-task.js +2 -2
- package/dist/select-composition.d.ts +33 -0
- package/dist/select-composition.js +119 -0
- package/dist/serve-handler/index.d.ts +1 -1
- package/dist/serve-handler/index.js +15 -15
- package/dist/serve-handler/is-path-inside.js +3 -3
- package/dist/serve-static.d.ts +5 -0
- package/dist/serve-static.js +25 -20
- package/dist/set-props-and-env.d.ts +5 -3
- package/dist/set-props-and-env.js +13 -3
- package/dist/stitch-frames-to-video.d.ts +1 -0
- package/dist/stitch-frames-to-video.js +76 -53
- package/dist/take-frame-and-compose.d.ts +3 -1
- package/dist/take-frame-and-compose.js +8 -7
- package/dist/tmp-dir.js +7 -7
- package/dist/try-to-extract-frame-of-video-fast.d.ts +4 -2
- package/dist/try-to-extract-frame-of-video-fast.js +7 -3
- package/install-toolchain.mjs +3 -9
- package/package.json +70 -71
- package/types/ws/index.d.ts +5 -5
- package/ffmpeg/SOURCE.md +0 -1
- package/ffmpeg/linux-arm-musl.gz +0 -0
- package/ffmpeg/linux-arm.gz +0 -0
- package/ffmpeg/linux-x64-musl.gz +0 -0
- package/ffmpeg/linux-x64.gz +0 -0
- package/ffmpeg/macos-arm.gz +0 -0
- package/ffmpeg/macos-x64.gz +0 -0
- package/ffmpeg/windows.gz +0 -0
|
@@ -37,33 +37,21 @@ 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.
|
|
57
|
-
const childProcess = __importStar(require("child_process"));
|
|
58
|
-
const fs = __importStar(require("fs"));
|
|
59
|
-
const http = __importStar(require("http"));
|
|
44
|
+
exports.getRevisionInfo = exports.getFolderPath = exports.removeBrowser = exports.localRevisions = exports.download = exports.getDownloadHost = exports.getDownloadsFolder = exports.getPlatform = void 0;
|
|
60
45
|
const https = __importStar(require("https"));
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
46
|
+
const childProcess = __importStar(require("node:child_process"));
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const http = __importStar(require("node:http"));
|
|
49
|
+
const os = __importStar(require("node:os"));
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
64
52
|
const extract_zip_1 = __importDefault(require("extract-zip"));
|
|
65
|
-
const URL = __importStar(require("url"));
|
|
66
|
-
const
|
|
53
|
+
const URL = __importStar(require("node:url"));
|
|
54
|
+
const node_util_2 = require("node:util");
|
|
67
55
|
const assert_1 = require("./assert");
|
|
68
56
|
const delete_directory_1 = require("../delete-directory");
|
|
69
57
|
const get_download_destination_1 = require("./get-download-destination");
|
|
@@ -121,7 +109,7 @@ function _downloadURL(product, platform, host, revision) {
|
|
|
121
109
|
if (platform === 'win64' || platform === 'win32') {
|
|
122
110
|
return 'https://remotionchromium-binaries.s3.eu-central-1.amazonaws.com/thorium-107.zip';
|
|
123
111
|
}
|
|
124
|
-
return
|
|
112
|
+
return node_util_1.default.format(downloadURLs[product][platform], host, revision, archiveName(product, platform, revision));
|
|
125
113
|
}
|
|
126
114
|
function handleArm64() {
|
|
127
115
|
let exists = fs.existsSync('/usr/bin/chromium-browser');
|
|
@@ -138,10 +126,10 @@ function handleArm64() {
|
|
|
138
126
|
'\n\n sudo apt install chromium-browser\n');
|
|
139
127
|
throw new Error();
|
|
140
128
|
}
|
|
141
|
-
const readdirAsync = (0,
|
|
142
|
-
const mkdirAsync = (0,
|
|
143
|
-
const unlinkAsync = (0,
|
|
144
|
-
const chmodAsync = (0,
|
|
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));
|
|
145
133
|
function existsAsync(filePath) {
|
|
146
134
|
return new Promise((resolve) => {
|
|
147
135
|
fs.access(filePath, (err) => {
|
|
@@ -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('-');
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { HeadlessBrowser } from './Browser';
|
|
17
17
|
import type { CDPSession } from './Connection';
|
|
18
18
|
import { ConsoleMessage } from './ConsoleMessage';
|
|
19
19
|
import type { EvaluateFn, EvaluateFnReturnType, EvaluateHandleFn, SerializableOrJSHandle, UnwrapPromiseLike } from './EvalTypes';
|
|
@@ -40,11 +40,11 @@ interface PageEventObject {
|
|
|
40
40
|
export declare class Page extends EventEmitter {
|
|
41
41
|
#private;
|
|
42
42
|
id: string;
|
|
43
|
-
static _create(client: CDPSession, target: Target, defaultViewport: Viewport, browser:
|
|
43
|
+
static _create(client: CDPSession, target: Target, defaultViewport: Viewport, browser: HeadlessBrowser): Promise<Page>;
|
|
44
44
|
closed: boolean;
|
|
45
|
-
browser:
|
|
45
|
+
browser: HeadlessBrowser;
|
|
46
46
|
screenshotTaskQueue: TaskQueue;
|
|
47
|
-
constructor(client: CDPSession, target: Target, browser:
|
|
47
|
+
constructor(client: CDPSession, target: Target, browser: HeadlessBrowser);
|
|
48
48
|
/**
|
|
49
49
|
* Listen to page events.
|
|
50
50
|
*/
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
/// <reference types="node" />
|
|
17
|
-
import * as childProcess from 'child_process';
|
|
17
|
+
import * as childProcess from 'node:child_process';
|
|
18
18
|
import { Connection } from './Connection';
|
|
19
19
|
import type { LaunchOptions } from './LaunchOptions';
|
|
20
20
|
export declare class BrowserRunner {
|
|
@@ -51,10 +51,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
51
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
|
-
const childProcess = __importStar(require("child_process"));
|
|
55
|
-
const fs = __importStar(require("fs"));
|
|
54
|
+
const childProcess = __importStar(require("node:child_process"));
|
|
55
|
+
const fs = __importStar(require("node:fs"));
|
|
56
56
|
const readline = __importStar(require("readline"));
|
|
57
57
|
const delete_directory_1 = require("../delete-directory");
|
|
58
|
+
const logger_1 = require("../logger");
|
|
58
59
|
const assert_1 = require("./assert");
|
|
59
60
|
const Connection_1 = require("./Connection");
|
|
60
61
|
const Errors_1 = require("./Errors");
|
|
@@ -78,22 +79,10 @@ class BrowserRunner {
|
|
|
78
79
|
}
|
|
79
80
|
start(options) {
|
|
80
81
|
var _a, _b;
|
|
81
|
-
const { dumpio, env
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
stdio = ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'];
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
stdio = ['ignore', 'ignore', 'ignore', 'pipe', 'pipe'];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (dumpio) {
|
|
92
|
-
stdio = ['pipe', 'pipe', 'pipe'];
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
stdio = ['pipe', 'ignore', 'pipe'];
|
|
96
|
-
}
|
|
82
|
+
const { dumpio, env } = options;
|
|
83
|
+
const stdio = dumpio
|
|
84
|
+
? ['ignore', 'pipe', 'pipe']
|
|
85
|
+
: ['pipe', 'ignore', 'pipe'];
|
|
97
86
|
(0, assert_1.assert)(!this.proc, 'This process has previously been started.');
|
|
98
87
|
this.proc = childProcess.spawn(__classPrivateFieldGet(this, _BrowserRunner_executablePath, "f"), __classPrivateFieldGet(this, _BrowserRunner_processArguments, "f"), {
|
|
99
88
|
// On non-windows platforms, `detached: true` makes child process a
|
|
@@ -106,12 +95,10 @@ class BrowserRunner {
|
|
|
106
95
|
});
|
|
107
96
|
if (dumpio) {
|
|
108
97
|
(_a = this.proc.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (d) => {
|
|
109
|
-
|
|
110
|
-
process.stdout.write(d.toString().trimStart());
|
|
98
|
+
logger_1.Log.verboseAdvanced({ indent: options.indent, logLevel: (0, logger_1.getLogLevel)(), tag: 'chrome' }, d.toString().trim());
|
|
111
99
|
});
|
|
112
100
|
(_b = this.proc.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (d) => {
|
|
113
|
-
|
|
114
|
-
process.stderr.write(d.toString().trimStart());
|
|
101
|
+
logger_1.Log.verboseAdvanced({ indent: options.indent, logLevel: (0, logger_1.getLogLevel)(), tag: 'chrome' }, d.toString().trim());
|
|
115
102
|
});
|
|
116
103
|
}
|
|
117
104
|
__classPrivateFieldSet(this, _BrowserRunner_closed, false, "f");
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { HeadlessBrowser } from './Browser';
|
|
17
17
|
import type { EvaluateFn, EvaluateFnReturnType, EvaluateHandleFn, SerializableOrJSHandle, UnwrapPromiseLike } from './EvalTypes';
|
|
18
18
|
import type { ExecutionContext } from './ExecutionContext';
|
|
19
19
|
import type { Frame } from './FrameManager';
|
|
@@ -30,7 +30,7 @@ export declare class DOMWorld {
|
|
|
30
30
|
executionContext(): Promise<ExecutionContext>;
|
|
31
31
|
evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
|
|
32
32
|
evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>;
|
|
33
|
-
waitForFunction(browser:
|
|
33
|
+
waitForFunction(browser: HeadlessBrowser, pageFunction: Function | string, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
|
|
34
34
|
title(): Promise<string>;
|
|
35
35
|
}
|
|
36
36
|
interface WaitTaskOptions {
|
|
@@ -38,7 +38,7 @@ interface WaitTaskOptions {
|
|
|
38
38
|
predicateBody: Function | string;
|
|
39
39
|
title: string;
|
|
40
40
|
timeout: number;
|
|
41
|
-
browser:
|
|
41
|
+
browser: HeadlessBrowser;
|
|
42
42
|
args: SerializableOrJSHandle[];
|
|
43
43
|
}
|
|
44
44
|
declare class WaitTask {
|
|
@@ -27,8 +27,7 @@ export interface LaunchOptions {
|
|
|
27
27
|
timeout?: number;
|
|
28
28
|
dumpio?: boolean;
|
|
29
29
|
env?: Record<string, string | undefined>;
|
|
30
|
-
pipe?: boolean;
|
|
31
30
|
product?: Product;
|
|
32
|
-
|
|
31
|
+
indent: boolean;
|
|
33
32
|
}
|
|
34
33
|
export declare type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions & LaunchOptions & BrowserConnectOptions;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HeadlessBrowser } from './Browser';
|
|
2
2
|
import type { PuppeteerNodeLaunchOptions } from './LaunchOptions';
|
|
3
3
|
import type { Product } from './Product';
|
|
4
4
|
export interface ProductLauncher {
|
|
5
|
-
launch(object: PuppeteerNodeLaunchOptions): Promise<
|
|
5
|
+
launch(object: PuppeteerNodeLaunchOptions): Promise<HeadlessBrowser>;
|
|
6
6
|
executablePath: (path?: any) => string;
|
|
7
7
|
product: Product;
|
|
8
8
|
}
|
|
9
9
|
export declare class ChromeLauncher implements ProductLauncher {
|
|
10
10
|
_preferredRevision: string;
|
|
11
11
|
constructor(preferredRevision: string);
|
|
12
|
-
launch(options: PuppeteerNodeLaunchOptions): Promise<
|
|
12
|
+
launch(options: PuppeteerNodeLaunchOptions): Promise<HeadlessBrowser>;
|
|
13
13
|
executablePath(): string;
|
|
14
14
|
get product(): Product;
|
|
15
15
|
}
|
package/dist/browser/Launcher.js
CHANGED
|
@@ -42,13 +42,12 @@ exports.ChromeLauncher = void 0;
|
|
|
42
42
|
* See the License for the specific language governing permissions and
|
|
43
43
|
* limitations under the License.
|
|
44
44
|
*/
|
|
45
|
-
const
|
|
46
|
-
const os = __importStar(require("os"));
|
|
47
|
-
const path = __importStar(require("path"));
|
|
48
|
-
const assert_1 = require("./assert");
|
|
45
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
46
|
+
const os = __importStar(require("node:os"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
49
48
|
const Browser_1 = require("./Browser");
|
|
50
|
-
const BrowserFetcher_1 = require("./BrowserFetcher");
|
|
51
49
|
const BrowserRunner_1 = require("./BrowserRunner");
|
|
50
|
+
const BrowserFetcher_1 = require("./BrowserFetcher");
|
|
52
51
|
const tmpDir = () => {
|
|
53
52
|
return process.env.PUPPETEER_TMP_DIR || os.tmpdir();
|
|
54
53
|
};
|
|
@@ -57,22 +56,16 @@ class ChromeLauncher {
|
|
|
57
56
|
this._preferredRevision = preferredRevision;
|
|
58
57
|
}
|
|
59
58
|
async launch(options) {
|
|
60
|
-
const { args = [], dumpio = false, executablePath,
|
|
59
|
+
const { args = [], dumpio = false, executablePath, env = process.env, defaultViewport, timeout = 60000, debuggingPort, indent, } = options;
|
|
61
60
|
const chromeArguments = args;
|
|
62
61
|
if (!chromeArguments.some((argument) => {
|
|
63
62
|
return argument.startsWith('--remote-debugging-');
|
|
64
63
|
})) {
|
|
65
|
-
|
|
66
|
-
(0, assert_1.assert)(!debuggingPort, 'Browser should be launched with either pipe or debugging port - not both.');
|
|
67
|
-
chromeArguments.push('--remote-debugging-pipe');
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
chromeArguments.push(`--remote-debugging-port=${debuggingPort || 0}`);
|
|
71
|
-
}
|
|
64
|
+
chromeArguments.push(`--remote-debugging-port=${debuggingPort || 0}`);
|
|
72
65
|
}
|
|
73
66
|
// Check for the user data dir argument, which will always be set even
|
|
74
67
|
// with a custom directory specified via the userDataDir option.
|
|
75
|
-
const userDataDir = await
|
|
68
|
+
const userDataDir = await node_fs_1.default.promises.mkdtemp(path.join(tmpDir(), 'puppeteer_dev_chrome_profile-'));
|
|
76
69
|
chromeArguments.push(`--user-data-dir=${userDataDir}`);
|
|
77
70
|
let chromeExecutable = executablePath;
|
|
78
71
|
if (!chromeExecutable) {
|
|
@@ -90,8 +83,7 @@ class ChromeLauncher {
|
|
|
90
83
|
runner.start({
|
|
91
84
|
dumpio,
|
|
92
85
|
env,
|
|
93
|
-
|
|
94
|
-
indentationString,
|
|
86
|
+
indent,
|
|
95
87
|
});
|
|
96
88
|
let browser;
|
|
97
89
|
try {
|
|
@@ -99,7 +91,7 @@ class ChromeLauncher {
|
|
|
99
91
|
timeout,
|
|
100
92
|
preferredRevision: this._preferredRevision,
|
|
101
93
|
});
|
|
102
|
-
browser = await Browser_1.
|
|
94
|
+
browser = await Browser_1.HeadlessBrowser._create({
|
|
103
95
|
connection,
|
|
104
96
|
contextIds: [],
|
|
105
97
|
defaultViewport,
|
|
@@ -132,12 +124,7 @@ class ChromeLauncher {
|
|
|
132
124
|
exports.ChromeLauncher = ChromeLauncher;
|
|
133
125
|
function resolveExecutablePath(launcher) {
|
|
134
126
|
const { product, _preferredRevision } = launcher;
|
|
135
|
-
const
|
|
136
|
-
product,
|
|
137
|
-
path: null,
|
|
138
|
-
platform: null,
|
|
139
|
-
});
|
|
140
|
-
const revisionInfo = browserFetcher.revisionInfo(_preferredRevision);
|
|
127
|
+
const revisionInfo = (0, BrowserFetcher_1.getRevisionInfo)(_preferredRevision, 'chrome');
|
|
141
128
|
const firefoxHelp = `Run \`PUPPETEER_PRODUCT=firefox npm install\` to download a supported Firefox browser binary.`;
|
|
142
129
|
const chromeHelp = `Run \`npm install\` to download the correct Chromium revision (${launcher._preferredRevision}).`;
|
|
143
130
|
const missingText = revisionInfo.local
|