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 | */
|
16 | const {helper} = require('./helper');
|
17 | const Launcher = require('./Launcher');
|
18 | const BrowserFetcher = require('./BrowserFetcher');
|
19 |
|
20 | module.exports = class {
|
21 | /**
|
22 | * @param {string} projectRoot
|
23 | * @param {string} preferredRevision
|
24 | * @param {boolean} isPuppeteerCore
|
25 | */
|
26 | constructor(projectRoot, preferredRevision, isPuppeteerCore) {
|
27 | this._projectRoot = projectRoot;
|
28 | this._launcher = new Launcher(projectRoot, preferredRevision, isPuppeteerCore);
|
29 | }
|
30 |
|
31 | /**
|
32 | * @param {!Object=} options
|
33 | * @return {!Promise<!Puppeteer.Browser>}
|
34 | */
|
35 | launch(options) {
|
36 | return this._launcher.launch(options);
|
37 | }
|
38 |
|
39 | /**
|
40 | * @param {{browserWSEndpoint: string, ignoreHTTPSErrors: boolean, transport?: !Puppeteer.ConnectionTransport}} options
|
41 | * @return {!Promise<!Puppeteer.Browser>}
|
42 | */
|
43 | connect(options) {
|
44 | return this._launcher.connect(options);
|
45 | }
|
46 |
|
47 | /**
|
48 | * @return {string}
|
49 | */
|
50 | executablePath() {
|
51 | return this._launcher.executablePath();
|
52 | }
|
53 |
|
54 | /**
|
55 | * @return {!Array<string>}
|
56 | */
|
57 | defaultArgs(options) {
|
58 | return this._launcher.defaultArgs(options);
|
59 | }
|
60 |
|
61 | /**
|
62 | * @param {!Object=} options
|
63 | * @return {!BrowserFetcher}
|
64 | */
|
65 | createBrowserFetcher(options) {
|
66 | return new BrowserFetcher(this._projectRoot, options);
|
67 | }
|
68 | };
|
69 |
|
70 | helper.tracePublicAPI(module.exports, 'Puppeteer');
|