UNPKG

@sparticuz/chromium

Version:

Chromium Binary for Serverless Platforms

87 lines (86 loc) 2.93 kB
/** Viewport taken from https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.viewport.md */ interface Viewport { /** * The page width in pixels. */ width: number; /** * The page height in pixels. */ height: number; /** * Specify device scale factor. * See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info. * @default 1 */ deviceScaleFactor?: number; /** * Whether the `meta viewport` tag is taken into account. * @default false */ isMobile?: boolean; /** * Specifies if the viewport is in landscape mode. * @default false */ isLandscape?: boolean; /** * Specify if the viewport supports touch events. * @default false */ hasTouch?: boolean; } declare class Chromium { /** * If true, the graphics stack and webgl is enabled, * If false, webgl will be disabled. * (If false, the swiftshader.tar.br file will also not extract) */ private static graphicsMode; /** * Downloads or symlinks a custom font and returns its basename, patching the environment so that Chromium can find it. */ static font(input: string): Promise<string>; /** * Returns a list of additional Chromium flags recommended for serverless environments. * The canonical list of flags can be found on https://peter.sh/experiments/chromium-command-line-switches/. */ static get args(): string[]; /** * Returns sensible default viewport settings for serverless environments. */ static get defaultViewport(): Required<Viewport>; /** * Inflates the included version of Chromium * @param input The location of the `bin` folder * @returns The path to the `chromium` binary */ static executablePath(input?: string): Promise<string>; /** * Returns the headless mode. * "shell" means the `chrome-headless-shell` headless mode. * @returns "shell" */ static get headless(): "shell"; /** * Sets the headless mode. * "shell" means the 'old' (legacy, chromium < 112) headless mode. * `true` means the 'new' headless mode. * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless * @deprecated 'New' headless mode will not be coming to chrome-headless-shell */ static set setHeadlessMode(_value: true | "shell"); /** * Returns whether the graphics stack is enabled or disabled * @returns boolean */ static get graphics(): boolean; /** * Sets whether the graphics stack is enabled or disabled. * @param true means the stack is enabled. WebGL will work. * @param false means that the stack is disabled. WebGL will not work. * @default true */ static set setGraphicsMode(value: boolean); } export = Chromium;