Permalink
Browse files

Move Launcher.makeLaunchOptions + type to Puppeteer and deprecate

It makes more sense to have these in the same module as where they are
used. Deprecates Launcher.launchOptions and
Launcher.makeLaunchOptions.
  • Loading branch information...
zploskey committed Mar 9, 2018
1 parent e6f787d commit a19ae2f6a0b34ce738414c3f6a63341591f51a4f
Showing with 163 additions and 155 deletions.
  1. +1 −1 __tests__/puppeteer_test.re
  2. +2 −2 lib/js/__tests__/puppeteer_test.js
  3. +2 −55 lib/js/src/Launcher.js
  4. +56 −0 lib/js/src/Puppeteer.js
  5. +4 −95 src/Launcher.re
  6. +98 −2 src/Puppeteer.re
@@ -35,7 +35,7 @@ let testPageCssPath = Node.Path.resolve(fixturesPath, "./testPage.css");
let testPageContent = Node.Fs.readFileAsUtf8Sync(testPagePath);

let noSandbox =
Launcher.makeLaunchOptions(
Puppeteer.makeLaunchOptions(
~args=[|"--no-sandbox", "--disable-setuid-sandbox"|],
(),
);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,96 +1,5 @@
type launchOptions = {
.
/* Whether to ignore HTTPS errors during navigation. Defaults to false. */
"ignoreHTTPSErrors": Js.Nullable.t(Js.boolean),
/* Whether to run Chromium in headless mode. Defaults to true. */
"headless": Js.Nullable.t(Js.boolean),
/*
* Path to a Chromium executable to run instead of bundled Chromium. If
* executablePath is a relative path, then it is resolved relative to current
* working directory.
*/
"executablePath": Js.Nullable.t(string),
/*
* Slows down Puppeteer operations by the specified amount of milliseconds.
* Useful so that you can see what is going on.
*/
"slowMo": Js.Nullable.t(float),
/*
* Additional arguments to pass to the Chromium instance. List of Chromium
* flags can be found here.
*/
"args": Js.Nullable.t(array(string)),
/* Close chrome process on Ctrl-C. Defaults to true. */
"handleSIGINT": Js.Nullable.t(Js.boolean),
/*
* Maximum time in milliseconds to wait for the Chrome instance to start.
* Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
*/
"timeout": Js.Nullable.t(int),
/*
* Whether to pipe browser process stdout and stderr into process.stdout and
* process.stderr. Defaults to false.
*/
"dumpio": Js.Nullable.t(Js.boolean),
/* Path to a User Data Directory. */
"userDataDir": Js.Nullable.t(string),
};
[@ocaml.deprecated "Use [Puppeteer.launchOptions] instead."]
type launchOptions = Puppeteer.launchOptions;

[@bs.obj]
external makeLaunchOptions :
(
~ignoreHTTPSErrors: Js.boolean=?,
~headless: Js.boolean=?,
~executablePath: string=?,
~slowMo: float=?,
~args: array(string)=?,
~ignoreDefaultArgs: Js.boolean=?,
~handleSIGINT: Js.boolean=?,
~handleSIGTERM: Js.boolean=?,
~handleSIGHUP: Js.boolean=?,
~timeout: float=?,
~dumpio: Js.boolean=?,
~userDataDir: string=?,
~env: Js.t('a)=?,
~devtools: Js.boolean=?,
unit
) =>
launchOptions =
"";

let makeLaunchOptions =
(
~ignoreHTTPSErrors=?,
~headless=?,
~executablePath=?,
~slowMo=?,
~args=?,
~ignoreDefaultArgs=?,
~handleSIGINT=?,
~handleSIGTERM=?,
~handleSIGHUP=?,
~timeout=?,
~dumpio=?,
~userDataDir=?,
~env=?,
~devtools=?,
(),
)
: launchOptions =>
makeLaunchOptions(
~ignoreHTTPSErrors=?Util.optBoolToJs(ignoreHTTPSErrors),
~headless=?Util.optBoolToJs(headless),
~executablePath?,
~slowMo?,
~args?,
~ignoreDefaultArgs=?Util.optBoolToJs(ignoreDefaultArgs),
~handleSIGINT=?Util.optBoolToJs(handleSIGINT),
~handleSIGTERM=?Util.optBoolToJs(handleSIGTERM),
~handleSIGHUP=?Util.optBoolToJs(handleSIGHUP),
~timeout?,
~dumpio=?Util.optBoolToJs(dumpio),
~userDataDir?,
~env?,
~devtools=?Util.optBoolToJs(devtools),
(),
);
[@ocaml.deprecated "Use [Puppeteer.makeLaunchOptions] instead."]
let makeLaunchOptions = Puppeteer.makeLaunchOptions;
@@ -30,11 +30,107 @@ external connect :
[@bs.module "puppeteer"]
external executablePath : unit => string = "";

type launchOptions = {
.
/* Whether to ignore HTTPS errors during navigation. Defaults to false. */
"ignoreHTTPSErrors": Js.Nullable.t(Js.boolean),
/* Whether to run Chromium in headless mode. Defaults to true. */
"headless": Js.Nullable.t(Js.boolean),
/*
* Path to a Chromium executable to run instead of bundled Chromium. If
* executablePath is a relative path, then it is resolved relative to current
* working directory.
*/
"executablePath": Js.Nullable.t(string),
/*
* Slows down Puppeteer operations by the specified amount of milliseconds.
* Useful so that you can see what is going on.
*/
"slowMo": Js.Nullable.t(float),
/*
* Additional arguments to pass to the Chromium instance. List of Chromium
* flags can be found here.
*/
"args": Js.Nullable.t(array(string)),
/* Close chrome process on Ctrl-C. Defaults to true. */
"handleSIGINT": Js.Nullable.t(Js.boolean),
/*
* Maximum time in milliseconds to wait for the Chrome instance to start.
* Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
*/
"timeout": Js.Nullable.t(int),
/*
* Whether to pipe browser process stdout and stderr into process.stdout and
* process.stderr. Defaults to false.
*/
"dumpio": Js.Nullable.t(Js.boolean),
/* Path to a User Data Directory. */
"userDataDir": Js.Nullable.t(string),
};

[@bs.obj]
external makeLaunchOptions :
(
~ignoreHTTPSErrors: Js.boolean=?,
~headless: Js.boolean=?,
~executablePath: string=?,
~slowMo: float=?,
~args: array(string)=?,
~ignoreDefaultArgs: Js.boolean=?,
~handleSIGINT: Js.boolean=?,
~handleSIGTERM: Js.boolean=?,
~handleSIGHUP: Js.boolean=?,
~timeout: float=?,
~dumpio: Js.boolean=?,
~userDataDir: string=?,
~env: Js.t('a)=?,
~devtools: Js.boolean=?,
unit
) =>
launchOptions =
"";

let makeLaunchOptions =
(
~ignoreHTTPSErrors=?,
~headless=?,
~executablePath=?,
~slowMo=?,
~args=?,
~ignoreDefaultArgs=?,
~handleSIGINT=?,
~handleSIGTERM=?,
~handleSIGHUP=?,
~timeout=?,
~dumpio=?,
~userDataDir=?,
~env=?,
~devtools=?,
(),
)
: launchOptions =>
makeLaunchOptions(
~ignoreHTTPSErrors=?Util.optBoolToJs(ignoreHTTPSErrors),
~headless=?Util.optBoolToJs(headless),
~executablePath?,
~slowMo?,
~args?,
~ignoreDefaultArgs=?Util.optBoolToJs(ignoreDefaultArgs),
~handleSIGINT=?Util.optBoolToJs(handleSIGINT),
~handleSIGTERM=?Util.optBoolToJs(handleSIGTERM),
~handleSIGHUP=?Util.optBoolToJs(handleSIGHUP),
~timeout?,
~dumpio=?Util.optBoolToJs(dumpio),
~userDataDir?,
~env?,
~devtools=?Util.optBoolToJs(devtools),
(),
);

/** Launch a browser instance. */
[@bs.val]
[@bs.module "puppeteer"]
external launch :
(~options: Launcher.launchOptions=?, unit) => Js.Promise.t(Browser.t) =
external launch : (~options: launchOptions=?, unit) => Js.Promise.t(Browser.t) =
"";

/** The default flags that Chromium will launch with. */

0 comments on commit a19ae2f

Please sign in to comment.