tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

LaunchOptions.ts (4201B)


      1 /**
      2 * @license
      3 * Copyright 2020 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 import type {ConnectOptions} from '../common/ConnectOptions.js';
      8 import type {SupportedBrowser} from '../common/SupportedBrowser.js';
      9 
     10 /**
     11 * @public
     12 */
     13 export type ChromeReleaseChannel =
     14  | 'chrome'
     15  | 'chrome-beta'
     16  | 'chrome-canary'
     17  | 'chrome-dev';
     18 
     19 /**
     20 * Generic launch options that can be passed when launching any browser.
     21 * @public
     22 */
     23 export interface LaunchOptions extends ConnectOptions {
     24  /**
     25   * If specified for Chrome, looks for a regular Chrome installation at a known
     26   * system location instead of using the bundled Chrome binary.
     27   */
     28  channel?: ChromeReleaseChannel;
     29  /**
     30   * Path to a browser executable to use instead of the bundled browser. Note
     31   * that Puppeteer is only guaranteed to work with the bundled browser, so use
     32   * this setting at your own risk.
     33   *
     34   * @remarks
     35   * When using this is recommended to set the `browser` property as well
     36   * as Puppeteer will default to `chrome` by default.
     37   */
     38  executablePath?: string;
     39  /**
     40   * If `true`, do not use `puppeteer.defaultArgs()` when creating a browser. If
     41   * an array is provided, these args will be filtered out. Use this with care -
     42   * you probably want the default arguments Puppeteer uses.
     43   * @defaultValue `false`
     44   */
     45  ignoreDefaultArgs?: boolean | string[];
     46  /**
     47   * If `true`, avoids passing default arguments to the browser that would
     48   * prevent extensions from being enabled. Passing a list of strings will
     49   * load the provided paths as unpacked extensions.
     50   */
     51  enableExtensions?: boolean | string[];
     52  /**
     53   * Close the browser process on `Ctrl+C`.
     54   * @defaultValue `true`
     55   */
     56  handleSIGINT?: boolean;
     57  /**
     58   * Close the browser process on `SIGTERM`.
     59   * @defaultValue `true`
     60   */
     61  handleSIGTERM?: boolean;
     62  /**
     63   * Close the browser process on `SIGHUP`.
     64   * @defaultValue `true`
     65   */
     66  handleSIGHUP?: boolean;
     67  /**
     68   * Maximum time in milliseconds to wait for the browser to start.
     69   * Pass `0` to disable the timeout.
     70   * @defaultValue `30_000` (30 seconds).
     71   */
     72  timeout?: number;
     73  /**
     74   * If true, pipes the browser process stdout and stderr to `process.stdout`
     75   * and `process.stderr`.
     76   * @defaultValue `false`
     77   */
     78  dumpio?: boolean;
     79  /**
     80   * Specify environment variables that will be visible to the browser.
     81   * @defaultValue The contents of `process.env`.
     82   */
     83  env?: Record<string, string | undefined>;
     84  /**
     85   * Connect to a browser over a pipe instead of a WebSocket. Only supported
     86   * with Chrome.
     87   *
     88   * @defaultValue `false`
     89   */
     90  pipe?: boolean;
     91  /**
     92   * Which browser to launch.
     93   * @defaultValue `chrome`
     94   */
     95  browser?: SupportedBrowser;
     96  /**
     97   * {@link https://searchfox.org/mozilla-release/source/modules/libpref/init/all.js | Additional preferences } that can be passed when launching with Firefox.
     98   */
     99  extraPrefsFirefox?: Record<string, unknown>;
    100  /**
    101   * Whether to wait for the initial page to be ready.
    102   * Useful when a user explicitly disables that (e.g. `--no-startup-window` for Chrome).
    103   * @defaultValue `true`
    104   */
    105  waitForInitialPage?: boolean;
    106  /**
    107   * Whether to run the browser in headless mode.
    108   *
    109   * @remarks
    110   *
    111   * - `true` launches the browser in the
    112   *   {@link https://developer.chrome.com/articles/new-headless/ | new headless}
    113   *   mode.
    114   *
    115   * - `'shell'` launches
    116   *   {@link https://developer.chrome.com/blog/chrome-headless-shell | shell}
    117   *   known as the old headless mode.
    118   *
    119   * @defaultValue `true`
    120   */
    121  headless?: boolean | 'shell';
    122  /**
    123   * Path to a user data directory.
    124   * {@link https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/user_data_dir.md | see the Chromium docs}
    125   * for more info.
    126   */
    127  userDataDir?: string;
    128  /**
    129   * Whether to auto-open a DevTools panel for each tab. If this is set to
    130   * `true`, then `headless` will be forced to `false`.
    131   * @defaultValue `false`
    132   */
    133  devtools?: boolean;
    134  /**
    135   * Specify the debugging port number to use
    136   */
    137  debuggingPort?: number;
    138  /**
    139   * Additional command line arguments to pass to the browser instance.
    140   */
    141  args?: string[];
    142 }