{"_id":"@rnx-kit/chromium-edge-launcher","_rev":"3565430","name":"@rnx-kit/chromium-edge-launcher","description":"EXPERIMENTAL - USE WITH CAUTION - Launch latest Edge with the Devtools Protocol port open","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"acoates","email":"acoates@microsoft.com"},{"name":"hansenyy","email":""},{"name":"jasonvmorse","email":""},{"name":"microsoft-oss-releases","email":""},{"name":"microsoft1es","email":""},{"name":"rnbot","email":""},{"name":"rnsdkbot","email":""},{"name":"tido64","email":""}],"time":{"modified":"2024-09-30T01:16:00.000Z","created":"2023-11-07T18:08:56.239Z","1.0.0":"2023-11-07T18:08:56.239Z"},"users":{},"author":{"name":"Microsoft Open Source","email":"microsoftopensource@users.noreply.github.com"},"repository":{"type":"git","url":"git+https://github.com/microsoft/rnx-kit.git","directory":"incubator/chromium-edge-launcher"},"versions":{"1.0.0":{"name":"@rnx-kit/chromium-edge-launcher","version":"1.0.0","description":"EXPERIMENTAL - USE WITH CAUTION - Launch latest Edge with the Devtools Protocol port open","homepage":"https://github.com/microsoft/rnx-kit/tree/main/incubator/chromium-edge-launcher#readme","license":"Apache-2.0","author":{"name":"Microsoft Open Source","email":"microsoftopensource@users.noreply.github.com"},"main":"lib/index.js","types":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/microsoft/rnx-kit.git","directory":"incubator/chromium-edge-launcher"},"engines":{"node":">=14.15"},"scripts":{"build":"rnx-kit-scripts build","format":"rnx-kit-scripts format","lint":"rnx-kit-scripts lint","test":"rnx-kit-scripts test"},"dependencies":{"@types/node":"^18.0.0","escape-string-regexp":"^4.0.0","is-wsl":"^2.2.0","lighthouse-logger":"^1.0.0","mkdirp":"^1.0.4","rimraf":"^3.0.2"},"devDependencies":{"@rnx-kit/eslint-config":"*","@rnx-kit/jest-preset":"*","@rnx-kit/scripts":"*","@types/mkdirp":"^1.0.1","@types/rimraf":"^3.0.0","@types/sinon":"^9.0.1","eslint":"^8.0.0","jest":"^29.2.1","prettier":"^3.0.0","sinon":"^9.0.1","typescript":"^5.0.0"},"jest":{"preset":"@rnx-kit/jest-preset/private"},"experimental":true,"gitHead":"290e59068295a0113840a0519353e015ac9cf19f","bugs":{"url":"https://github.com/microsoft/rnx-kit/issues"},"_id":"@rnx-kit/chromium-edge-launcher@1.0.0","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"shasum":"c0df8ea00a902c7a417cd9655aab06de398b939c","size":23273,"noattachment":false,"key":"/@rnx-kit/chromium-edge-launcher/-/@rnx-kit/chromium-edge-launcher-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@rnx-kit/chromium-edge-launcher/download/@rnx-kit/chromium-edge-launcher-1.0.0.tgz"},"_npmUser":{"name":"rnsdkbot","email":"rnsdkbot@microsoft.com"},"directories":{},"maintainers":[{"name":"acoates","email":"acoates@microsoft.com"},{"name":"hansenyy","email":""},{"name":"jasonvmorse","email":""},{"name":"microsoft-oss-releases","email":""},{"name":"microsoft1es","email":""},{"name":"rnbot","email":""},{"name":"rnsdkbot","email":""},{"name":"tido64","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chromium-edge-launcher_1.0.0_1699380536074_0.5745945842186613"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-07T18:08:56.239Z","publish_time":1699380536239,"_source_registry_name":"default","_cnpm_publish_time":1699380536239}},"readme":"# Edge Launcher\n\n<img src=\"https://user-images.githubusercontent.com/4672033/107800563-adb9ce00-6d3d-11eb-8425-2256d0278894.png\" align=right height=200>\n\nLaunch Microsoft Edge with ease from node.\n\n- [Disables many Edge services](https://github.com/microsoft/rnx-kit/incubator/chromium-edge-launcher/blob/main/src/flags.ts)\n  that add noise to automated scenarios\n- Opens up the browser's `remote-debugging-port` on an available port\n- Automagically locates a Edge binary to launch\n- Uses a fresh Edge profile for each launch, and cleans itself up on `kill()`\n- Binds `Ctrl-C` (by default) to terminate the Edge process\n- Exposes a small set of [options](#api) for configurability over these details\n\n> \\_This project started as a fork of\n> [Chrome Launcher](https://github.com/GoogleChrome/chrome-launcher) and\n> inherits, whereas possible, all its features.\n\n### Installing\n\n```sh\nyarn add @rnx-kit/chromium-edge-launcher\n\n# or with npm:\nnpm install @rnx-kit/chromium-edge-launcher\n```\n\n## API\n\n### `.launch([opts])`\n\n#### Launch options\n\n```js\n{\n  // (optional) remote debugging port number to use. If provided port is already busy, launch() will reject\n  // Default: an available port is autoselected\n  port: number;\n\n  // (optional) Additional flags to pass to Edge, for example: ['--headless', '--disable-gpu']\n  // See: https://github.com/microsoft/rnx-kit/incubator/chromium-edge-launcher/blob/main/docs/edge-flags-for-tools.md\n  // Do note, many flags are set by default: https://github.com/microsoft/rnx-kit/incubator/chromium-edge-launcher/blob/main/src/flags.ts\n  edgeFlags: Array<string>;\n\n  // (optional) Close the Edge process on `Ctrl-C`\n  // Default: true\n  handleSIGINT: boolean;\n\n  // (optional) Explicit path of intended Edge binary\n  // * If this `edgePath` option is defined, it will be used.\n  // * Otherwise, the `EDGE_PATH` env variable will be used if set. (`LIGHTHOUSE_CHROMIUM_PATH` is deprecated)\n  // * Otherwise, a detected Edge Canary will be used if found\n  // * Otherwise, a detected Edge (stable) will be used\n  edgePath: string;\n\n  // (optional) Edge profile path to use, if set to `false` then the default profile will be used.\n  // By default, a fresh Edge profile will be created\n  userDataDir: string | boolean;\n\n  // (optional) Starting URL to open the browser with\n  // Default: `about:blank`\n  startingUrl: string;\n\n  // (optional) Logging level\n  // Default: 'silent'\n  logLevel: 'verbose'|'info'|'error'|'silent';\n\n  // (optional) Flags specific in [flags.ts](src/flags.ts) will not be included.\n  // Typically used with the defaultFlags() method and edgeFlags option.\n  // Default: false\n  ignoreDefaultFlags: boolean;\n\n  // (optional) Interval in ms, which defines how often launcher checks browser port to be ready.\n  // Default: 500\n  connectionPollInterval: number;\n\n  // (optional) A number of retries, before browser launch considered unsuccessful.\n  // Default: 50\n  maxConnectionRetries: number;\n\n  // (optional) A dict of environmental key value pairs to pass to the spawned edge process.\n  envVars: {[key: string]: string};\n};\n```\n\n#### Launched edge interface\n\n#### `.launch().then(edge => ...`\n\n```js\n// The remote debugging port exposed by the launched edge\nedge.port: number;\n\n// Method to kill Edge (and cleanup the profile folder)\nedge.kill: () => Promise<void>;\n\n// The process id\nedge.pid: number;\n\n// The childProcess object for the launched Edge\nedge.process: childProcess\n```\n\n### `EdgeLauncher.Launcher.defaultFlags()`\n\nReturns an `Array<string>` of the default [flags](docs/edge-flags-for-tools.md)\nEdge is launched with. Typically used along with the `ignoreDefaultFlags` and\n`edgeFlags` options.\n\nNote: This array will exclude the following flags: `--remote-debugging-port`\n`--disable-setuid-sandbox` `--user-data-dir`.\n\n### `EdgeLauncher.Launcher.getInstallations()`\n\nReturns an `Array<string>` of paths to available Edge installations. When\n`edgePath` is not provided to `.launch()`, the first installation returned from\nthis method is used instead.\n\nNote: This method performs synchronous I/O operations.\n\n### `.killAll()`\n\nAttempts to kill all Edge instances created with\n[`.launch([opts])`](#launchopts). Returns a Promise that resolves to an array of\nerrors that occurred while killing instances. If all instances were killed\nsuccessfully, the array will be empty.\n\n```js\nconst EdgeLauncher = require(\"@rnx-kit/chromium-edge-launcher\");\n\nasync function cleanup() {\n  await EdgeLauncher.killAll();\n}\n```\n\n## Examples\n\n#### Launching edge:\n\n```js\nconst EdgeLauncher = require(\"@rnx-kit/chromium-edge-launcher\");\n\nEdgeLauncher.launch({\n  startingUrl: \"https://google.com\",\n}).then((edge) => {\n  console.log(`Edge debugging port running on ${edge.port}`);\n});\n```\n\n#### Launching headless edge:\n\n```js\nconst EdgeLauncher = require(\"@rnx-kit/chromium-edge-launcher\");\n\nEdgeLauncher.launch({\n  startingUrl: \"https://google.com\",\n  edgeFlags: [\"--headless\", \"--disable-gpu\"],\n}).then((edge) => {\n  console.log(`Edge debugging port running on ${edge.port}`);\n});\n```\n\n#### Launching with support for extensions and audio:\n\n```js\nconst EdgeLauncher = require('@rnx-kit/chromium-edge-launcher');\n\nconst newFlags = EdgeLauncher.Launcher.defaultFlags().filter(flag => flag !== '--disable-extensions' && flag !== '--mute-audio');\n\nEdgeLauncher.launch({\n  ignoreDefaultFlags: true,\n  edgeFlags: newFlags,\n}).then(edge => { ... });\n```\n\n### Continuous Integration\n\nIn a CI environment like Travis, Edge may not be installed. If you want to use\n`@rnx-kit/chromium-edge-launcher`, Travis can\n[install Edge at run time with an addon](https://docs.travis-ci.com/user/edge).\nAlternatively, you can also install Edge using the\n[`download-edge.sh`](https://raw.githubusercontent.com/cezaraugusto/chromium-edge-launcher/v0.8.0/scripts/download-edge.sh)\nscript.\n\nThen in `.travis.yml`, use it like so:\n\n```yaml\nlanguage: node_js\ninstall:\n  - yarn install\nbefore_script:\n  - export DISPLAY=:99.0\n  - export CHROME_PATH=\"$(pwd)/edge-linux/edge\"\n  - sh -e /etc/init.d/xvfb start\n  - sleep 3 # wait for xvfb to boot\n\naddons:\n  edge: stable\n```\n\n### Acknowledgements\n\nThis project is a fork of https://github.com/cezaraugusto/chromium-edge-launcher\nwhich started as a fork of, and is inspired by\nhttps://github.com/cezaraugusto/chromium-edge-launcher which is released under\nthe Apache-2.0 License, and is copyright of Google Inc.\n","_attachments":{},"homepage":"https://github.com/microsoft/rnx-kit/tree/main/incubator/chromium-edge-launcher#readme","bugs":{"url":"https://github.com/microsoft/rnx-kit/issues"},"license":"Apache-2.0"}