UNPKG

2.49 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as childProcess from 'child_process';
3import * as fs from 'fs';
4import { ChildProcess } from 'child_process';
5declare type JSONLike = {
6 [property: string]: JSONLike;
7} | readonly JSONLike[] | string | number | boolean | null;
8export interface Options {
9 startingUrl?: string;
10 chromeFlags?: Array<string>;
11 prefs?: Record<string, JSONLike>;
12 port?: number;
13 handleSIGINT?: boolean;
14 chromePath?: string;
15 userDataDir?: string | boolean;
16 logLevel?: 'verbose' | 'info' | 'error' | 'silent';
17 ignoreDefaultFlags?: boolean;
18 connectionPollInterval?: number;
19 maxConnectionRetries?: number;
20 envVars?: {
21 [key: string]: string | undefined;
22 };
23}
24export interface LaunchedChrome {
25 pid: number;
26 port: number;
27 process: ChildProcess;
28 kill: () => Promise<void>;
29}
30export interface ModuleOverrides {
31 fs?: typeof fs;
32 spawn?: typeof childProcess.spawn;
33}
34declare function launch(opts?: Options): Promise<LaunchedChrome>;
35/** Returns Chrome installation path that chrome-launcher will launch by default. */
36declare function getChromePath(): string;
37declare function killAll(): Promise<Array<Error>>;
38declare class Launcher {
39 private opts;
40 private tmpDirandPidFileReady;
41 private pidFile;
42 private startingUrl;
43 private outFile?;
44 private errFile?;
45 private chromePath?;
46 private ignoreDefaultFlags?;
47 private chromeFlags;
48 private prefs;
49 private requestedPort?;
50 private connectionPollInterval;
51 private maxConnectionRetries;
52 private fs;
53 private spawn;
54 private useDefaultProfile;
55 private envVars;
56 chrome?: childProcess.ChildProcess;
57 userDataDir?: string;
58 port?: number;
59 pid?: number;
60 constructor(opts?: Options, moduleOverrides?: ModuleOverrides);
61 private get flags();
62 static defaultFlags(): string[];
63 /** Returns the highest priority chrome installation. */
64 static getFirstInstallation(): string | undefined;
65 /** Returns all available chrome installations in decreasing priority order. */
66 static getInstallations(): string[];
67 makeTmpDir(): string;
68 prepare(): void;
69 private setBrowserPrefs;
70 launch(): Promise<void>;
71 private spawnProcess;
72 private cleanup;
73 private isDebuggerReady;
74 waitUntilReady(): Promise<void>;
75 kill(): Promise<void>;
76 destroyTmp(): Promise<void>;
77}
78export default Launcher;
79export { Launcher, launch, killAll, getChromePath };