{"name":"chromium-edge-launcher","version":"2.0.0","author":{"name":"Cezar Augusto"},"license":"Apache-2.0","_id":"chromium-edge-launcher@2.0.0","maintainers":[{"name":"cezaraugusto","email":"boss@cezaraugusto.net"}],"homepage":"https://github.com/cezaraugusto/chromium-edge-launcher#readme","bugs":{"url":"https://github.com/cezaraugusto/chromium-edge-launcher/issues"},"bin":{"print-edge-path":"bin/print-edge-path.cjs"},"dist":{"shasum":"afb5a472fb9d216035d510c82afafdf6f5751c68","tarball":"http://registry-npm.ywwl.com/chromium-edge-launcher/download/chromium-edge-launcher-2.0.0.tgz","fileCount":29,"integrity":"sha512-hONPjjGNPDKjDZk8bZflbC454kK2mPM7YG9UsRqpTFVigtSDSNqmXitg8NOr8jPlAyGE/6Gwi6EtPa2DuXkx4Q==","signatures":[{"sig":"MEQCIBSGoq3/S7JCpQwE53DDjwlS/b/shaGgvR2BQqSRIJ9aAiBJ0n3shd5aiA8KWJF0Whq5PQ9oi9oiO8+w/wki5N5I3g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":265170,"size":174387,"noattachment":false,"key":"/chromium-edge-launcher/-/chromium-edge-launcher-2.0.0.tgz"},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=12.13.0"},"gitHead":"3fe17886e641e77c89dde8c4f55c60876614bcda","scripts":{"dev":"tsc -w","test":"test/run-tests.sh","build":"tsc","format":"scripts/format.sh","reset-link":"(yarn unlink || true) && yarn link && yarn --cwd node_modules/lighthouse/ link edge-launcher","type-check":"tsc --allowJs --checkJs --noEmit --target es2019 *.js","prepublishOnly":"npm run build && npm run test","test-formatting":"test/check-formatting.sh"},"_npmUser":{"name":"cezaraugusto","email":"boss@cezaraugusto.net"},"repository":{"url":"git+https://github.com/cezaraugusto/chromium-edge-launcher.git","type":"git"},"_npmVersion":"11.11.0","description":"Launch latest Edge with the Devtools Protocol port open","directories":{},"_nodeVersion":"23.8.0","dependencies":{"is-wsl":"^2.2.0","@types/node":"*","lighthouse-logger":"^2.0.1","escape-string-regexp":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","sinon":"^9.0.1","ts-node":"^10.9.1","typescript":"^4.1.2","@types/mocha":"^8.0.4","@types/sinon":"^9.0.1","clang-format":"^1.0.50"},"_npmOperationalInternal":{"tmp":"tmp/chromium-edge-launcher_2.0.0_1775905288391_0.46229793894763693","host":"s3://npm-registry-packages-npm-production"},"readme":"# Edge Launcher [![GitHub Actions Status Badge](https://github.com/cezaraugusto/chromium-edge-launcher/workflows/🛠/badge.svg)](https://github.com/cezaraugusto/chromium-edge-launcher/actions) [![NPM chromium-edge-launcher package](https://img.shields.io/npm/v/chromium-edge-launcher.svg)](https://npmjs.org/package/chromium-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/cezaraugusto/chromium-edge-launcher/blob/main/src/flags.ts) 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\nOnce launched, interacting with the browser must be done over the [devtools protocol](https://chromedevtools.github.io/devtools-protocol/), typically via [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface/). For many cases [Puppeteer](https://github.com/GoogleChrome/puppeteer) is recommended, though it has its own browser launching mechanism.\n\n### Installing\n\n```sh\nyarn add chromium-edge-launcher\n\n# or with npm:\nnpm install chromium-edge-launcher\n```\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) When `port` is specified *and* no Edge is found at that port,\n  // * if `false` (default), chromium-edge-launcher will launch a new Edge with that port.\n  // * if `true`, throw an error\n  // This option is useful when you wish to explicitly connect to a running Edge, such as on a mobile device via adb\n  // Default: false\n  portStrictMode: boolean;\n\n  // (optional) Additional flags to pass to Edge, for example: ['--headless', '--disable-gpu']\n  // See: https://github.com/cezaraugusto/chromium-edge-launcher/blob/main/docs/edge-flags-for-tools.md\n  // Do note, many flags are set by default: https://github.com/cezaraugusto/chromium-edge-launcher/blob/main/src/flags.ts\n  edgeFlags: Array<string>;\n\n  // (optional) Additional preferences to be set in Edge, for example: {'download.default_directory': __dirname}\n  // See: https://chromium.googlesource.com/chromium/src/+/main/chrome/common/pref_names.cc\n  // Do note, if you set preferences when using your default profile it will overwrite these\n  prefs: {[key: string]: Object};\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'|'warn'|'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: () => void;\n\n// The process id\nedge.pid: number;\n\n// The childProcess object for the launched Edge\nedge.process: childProcess\n\n// If edgeFlags contains --remote-debugging-pipe. Otherwise remoteDebuggingPipes is null.\nedge.remoteDebuggingPipes.incoming: ReadableStream\nedge.remoteDebuggingPipes.outgoing: WritableStream\n```\n\nWhen `--remote-debugging-pipe` is passed via `edgeFlags`, then `port` will be\nunusable (0) by default. Instead, debugging messages are exchanged via\n`remoteDebuggingPipes.incoming` and `remoteDebuggingPipes.outgoing`. The data\nin these pipes are JSON values terminated by a NULL byte (`\\x00`).\nData written to `remoteDebuggingPipes.outgoing` are sent to Edge,\ndata read from `remoteDebuggingPipes.incoming` are received from Edge.\n\n### `EdgeLauncher.Launcher.defaultFlags()`\n\nReturns an `Array<string>` of the default [flags](docs/edge-flags-for-tools.md) Edge is launched with. Typically used along with the `ignoreDefaultFlags` and `edgeFlags` options.\n\nNote: This array will exclude the following flags: `--remote-debugging-port` `--disable-setuid-sandbox` `--user-data-dir`.\n\n### `EdgeLauncher.Launcher.getInstallations()`\n\nReturns an `Array<string>` of paths to available Edge installations. When `edgePath` is not provided to `.launch()`, the first installation returned from this 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 [`.launch([opts])`](#launchopts). Returns an array of errors that occurred while killing instances. If all instances were killed successfully, the array will be empty.\n\n```js\nimport * as EdgeLauncher from 'chromium-edge-launcher';\n\nfunction cleanup() {\n  const errors = EdgeLauncher.killAll();\n}\n```\n\n### `.getEdgePath()`\n\nReturns a `string` with the path to the Edge installation that will be used by default when launching. Throws if no installation is found.\n\n```js\nimport * as EdgeLauncher from 'chromium-edge-launcher';\n\nconst edgePath = EdgeLauncher.getEdgePath();\nconsole.log(edgePath);\n```\n\n## Examples\n\n#### Launching Edge:\n\n```js\nimport * as EdgeLauncher from '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\n#### Launching headless Edge:\n\n```js\nimport * as EdgeLauncher from '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\nimport * as EdgeLauncher from '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\nTo programatically load an extension at runtime, use `--remote-debugging-pipe`\nas shown in [test/load-extension-test.ts](test/load-extension-test.ts).\n\n### Continuous Integration\n\nIn a CI environment like GitHub Actions, Edge may not be installed. You can set the `EDGE_PATH` environment variable to point to a Chromium-based browser binary, or install Edge as part of your CI setup.\n\n```yaml\n# Example GitHub Actions setup\n- name: Set Edge path\n  run: export EDGE_PATH=$(which microsoft-edge-stable || which microsoft-edge)\n```\n","publish_time":1775905288574,"_cnpm_publish_time":1775905288574,"dist-tags":{"latest":"2.0.1"}}