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