chromeless
Version:
🖥 Chrome automation made simple. Runs locally or headless on AWS Lambda.
221 lines (220 loc) • 4.36 kB
TypeScript
export interface Client {
Network: any;
Page: any;
DOM: any;
Input: any;
Runtime: any;
Emulation: any;
Storage: any;
close: () => void;
target: {
id: string;
};
port: any;
host: any;
}
export interface DeviceMetrics {
width: number;
height: number;
deviceScaleFactor?: number;
mobile?: boolean;
scale?: number;
screenOrientation?: ScreenOrientation;
}
export interface ScreenOrientation {
type: string;
angle: number;
}
export interface RemoteOptions {
endpointUrl: string;
apiKey?: string;
}
export interface CDPOptions {
host?: string;
port?: number;
secure?: boolean;
closeTab?: boolean;
}
export interface ChromelessOptions {
debug?: boolean;
waitTimeout?: number;
implicitWait?: boolean;
scrollBeforeClick?: boolean;
viewport?: {
width?: number;
height?: number;
scale?: number;
};
launchChrome?: boolean;
cdp?: CDPOptions;
remote?: RemoteOptions | boolean;
}
export interface Chrome {
process<T extends any>(command: Command): Promise<T>;
close(): Promise<void>;
}
export declare type Command = {
type: 'goto';
url: string;
timeout?: number;
} | {
type: 'clearCache';
} | {
type: 'setViewport';
options: DeviceMetrics;
} | {
type: 'setUserAgent';
useragent: string;
} | {
type: 'wait';
timeout?: number;
selector?: string;
fn?: string;
args?: any[];
} | {
type: 'click';
selector: string;
} | {
type: 'returnCode';
fn: string;
args?: any[];
} | {
type: 'returnInputValue';
selector: string;
} | {
type: 'returnExists';
selector: string;
} | {
type: 'returnValue';
selector: string;
} | {
type: 'returnScreenshot';
selector?: string;
options?: ScreenshotOptions;
} | {
type: 'returnHtml';
} | {
type: 'returnHtmlUrl';
} | {
type: 'returnPdf';
options?: PdfOptions;
} | {
type: 'scrollTo';
x: number;
y: number;
} | {
type: 'scrollToElement';
selector: string;
} | {
type: 'setHtml';
html: string;
} | {
type: 'setExtraHTTPHeaders';
headers: Headers;
} | {
type: 'press';
keyCode: number;
count?: number;
modifiers?: any;
} | {
type: 'type';
input: string;
selector?: string;
} | {
type: 'clearCookies';
} | {
type: 'clearStorage';
origin: string;
storageTypes: string;
} | {
type: 'deleteCookies';
name: string;
url: string;
} | {
type: 'setCookies';
nameOrCookies: string | Cookie | Cookie[];
value?: string;
} | {
type: 'allCookies';
} | {
type: 'cookies';
nameOrQuery?: string | CookieQuery;
} | {
type: 'mousedown';
selector: string;
} | {
type: 'mouseup';
selector: string;
} | {
type: 'focus';
selector: string;
} | {
type: 'clearInput';
selector: string;
} | {
type: 'setFileInput';
selector: string;
files: string[];
};
export declare type Headers = Record<string, string>;
export interface Cookie {
url?: string;
domain?: string;
name: string;
value: string;
path?: string;
expires?: number;
size?: number;
httpOnly?: boolean;
secure?: boolean;
session?: boolean;
}
export interface CookieQuery {
name: string;
path?: string;
expires?: number;
size?: number;
httpOnly?: boolean;
secure?: boolean;
session?: boolean;
}
export interface PdfOptions {
landscape?: boolean;
displayHeaderFooter?: boolean;
printBackground?: boolean;
scale?: number;
paperWidth?: number;
paperHeight?: number;
marginTop?: number;
marginBottom?: number;
marginLeft?: number;
marginRight?: number;
pageRanges?: string;
ignoreInvalidPageRanges?: boolean;
filePath?: string;
}
export interface ScreenshotOptions {
filePath?: string;
}
export declare type Quad = Array<number>;
export interface ShapeOutsideInfo {
bounds: Quad;
shape: Array<any>;
marginShape: Array<any>;
}
export interface BoxModel {
content: Quad;
padding: Quad;
border: Quad;
margin: Quad;
width: number;
height: number;
shapeOutside: ShapeOutsideInfo;
}
export interface Viewport {
x: number;
y: number;
width: number;
height: number;
scale: number;
}