1/** 2 * Copyright 2017 Google Inc. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16import { Product } from '../common/Product.js'; 17/** 18 * Supported platforms. 19 * @public 20 */ 21export declare type Platform = 'linux' | 'mac' | 'win32' | 'win64'; 22/** 23 * @public 24 */ 25export interface BrowserFetcherOptions { 26 platform?: Platform; 27 product?: string; 28 path?: string; 29 host?: string; 30} 31/** 32 * @public 33 */ 34export interface BrowserFetcherRevisionInfo { 35 folderPath: string; 36 executablePath: string; 37 url: string; 38 local: boolean; 39 revision: string; 40 product: string; 41} 42/** 43 * BrowserFetcher can download and manage different versions of Chromium and Firefox. 44 * 45 * @remarks 46 * BrowserFetcher operates on revision strings that specify a precise version of Chromium, e.g. `"533271"`. Revision strings can be obtained from {@link http://omahaproxy.appspot.com/ | omahaproxy.appspot.com}. 47 * In the Firefox case, BrowserFetcher downloads Firefox Nightly and 48 * operates on version numbers such as `"75"`. 49 * 50 * @example 51 * An example of using BrowserFetcher to download a specific version of Chromium 52 * and running Puppeteer against it: 53 * 54 * ```js 55 * const browserFetcher = puppeteer.createBrowserFetcher(); 56 * const revisionInfo = await browserFetcher.download('533271'); 57 * const browser = await puppeteer.launch({executablePath: revisionInfo.executablePath}) 58 * ``` 59 * 60 * **NOTE** BrowserFetcher is not designed to work concurrently with other 61 * instances of BrowserFetcher that share the same downloads directory. 62 * 63 * @public 64 */ 65export declare class BrowserFetcher { 66 private _product; 67 private _downloadsFolder; 68 private _downloadHost; 69 private _platform; 70 /** 71 * @internal 72 */ 73 constructor(projectRoot: string, options?: BrowserFetcherOptions); 74 private setPlatform; 75 /** 76 * @returns Returns the current `Platform`. 77 */ 78 platform(): Platform; 79 /** 80 * @returns Returns the current `Product`. 81 */ 82 product(): Product; 83 /** 84 * @returns The download host being used. 85 */ 86 host(): string; 87 /** 88 * Initiates a HEAD request to check if the revision is available. 89 * @remarks 90 * This method is affected by the current `product`. 91 * @param revision - The revision to check availability for. 92 * @returns A promise that resolves to `true` if the revision could be downloaded 93 * from the host. 94 */ 95 canDownload(revision: string): Promise<boolean>; 96 /** 97 * Initiates a GET request to download the revision from the host. 98 * @remarks 99 * This method is affected by the current `product`. 100 * @param revision - The revision to download. 101 * @param progressCallback - A function that will be called with two arguments: 102 * How many bytes have been downloaded and the total number of bytes of the download. 103 * @returns A promise with revision information when the revision is downloaded 104 * and extracted. 105 */ 106 download(revision: string, progressCallback?: (x: number, y: number) => void): Promise<BrowserFetcherRevisionInfo>; 107 /** 108 * @remarks 109 * This method is affected by the current `product`. 110 * @returns A promise with a list of all revision strings (for the current `product`) 111 * available locally on disk. 112 */ 113 localRevisions(): Promise<string[]>; 114 /** 115 * @remarks 116 * This method is affected by the current `product`. 117 * @param revision - A revision to remove for the current `product`. 118 * @returns A promise that resolves when the revision has been removes or 119 * throws if the revision has not been downloaded. 120 */ 121 remove(revision: string): Promise<void>; 122 /** 123 * @param revision - The revision to get info for. 124 * @returns The revision info for the given revision. 125 */ 126 revisionInfo(revision: string): BrowserFetcherRevisionInfo; 127 /** 128 * @internal 129 */ 130 _getFolderPath(revision: string): string; 131} 132//# sourceMappingURL=BrowserFetcher.d.ts.map