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 | 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 | }
|
24 | export interface LaunchedChrome {
|
25 | pid: number;
|
26 | port: number;
|
27 | process: ChildProcess;
|
28 | kill: () => Promise<void>;
|
29 | }
|
30 | export interface ModuleOverrides {
|
31 | fs?: typeof fs;
|
32 | spawn?: typeof childProcess.spawn;
|
33 | }
|
34 | declare function launch(opts?: Options): Promise<LaunchedChrome>;
|
35 |
|
36 | declare function getChromePath(): string;
|
37 | declare function killAll(): Promise<Array<Error>>;
|
38 | declare 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 | }
|
78 | export default Launcher;
|
79 | export { Launcher, launch, killAll, getChromePath };
|