@nextnextools/xrom
TypeScript icon, indicating that this package has built-in type declarations

3.4.0 • Public • Published

xrom npm

Run dockerized Chromium or Firefox in headless remote debugging mode and return browserWSEndpoint needed for puppeteer.connect().

Install

$ yarn add xrom

Usage

type TRunBrowserOptions = {
  browser: 'chromium' | 'firefox',
  version: string,
  dockerUrlRoot?: string
  port?: number,
  fontsDir?: string,
  mountVolumes?: {
    from: string,
    to: string,
  }[],
  cpus?: number,
  cpusetCpus?: number[]
}

type TRunBrowserResult = {
  browserWSEndpoint: string,
  closeBrowser: () => Promise<void>,
}

runBrowser(options: TRunBrowserOptions) => Promise<TRunBrowserResult>
import { runBrowser } from 'xrom'
import puppeteer from 'puppeteer-core'

const { browserWSEndpoint } = await runBrowser({ browser: 'chromium' })
const browser = await puppeteer.connect({ browserWSEndpoint })

Overriding the docker root URL to another set of browser images

You can override the root URL to use some other set of docker images of Chromium and/or Firefox.

Make sure the final link, which is evaluated as ${dockerUrlRoot}/${browser}:${version}, points to a docker image that is valid and public.

const { browserWSEndpoint, closeBrowser } = await runBrowser({
  dockerUrlRoot: 'ghcr.io/shenato/docker-browser',
  browser: 'chromium',
  version: opts.chromiumVersion,
  fontsDir: opts.fontsDir,
})

Readme

Keywords

none

Package Sidebar

Install

npm i @nextnextools/xrom

Weekly Downloads

64,331

Version

3.4.0

License

MIT

Unpacked Size

6.33 kB

Total Files

7

Last publish

Collaborators

  • xaviervia
  • shenato