-
Notifications
You must be signed in to change notification settings - Fork 40
/
index.d.ts
114 lines (97 loc) · 2.65 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// utility types
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'silent';
interface Pojo {
[x: string]: any;
}
interface AuthCredentials {
username: string;
password: string;
}
interface DiscoveryOptions {
requestHeaders?: Pojo;
authorization?: AuthCredentials;
allowedHostnames?: string[];
disableCache?: boolean;
captureMockedServiceWorker?: boolean;
captureSrcset?: boolean;
}
interface ScopeOptions {
scroll?: boolean;
}
interface DiscoveryLaunchOptions {
executable?: string;
args?: string[];
timeout?: number;
headless?: boolean;
}
interface AllDiscoveryOptions extends DiscoveryOptions {
networkIdleTimeout?: number;
concurrency?: number;
launchOptions?: DiscoveryLaunchOptions;
}
interface CommonSnapshotOptions {
widths?: number[];
minHeight?: number;
percyCSS?: string;
enableJavaScript?: boolean;
disableShadowDOM?: boolean;
enableLayout?: boolean;
domTransformation?: string;
reshuffleInvalidTags?: boolean;
devicePixelRatio?: number;
scope?: string;
scopeOptions?: ScopeOptions;
}
export interface SnapshotOptions extends CommonSnapshotOptions {
discovery?: DiscoveryOptions;
}
type ClientEnvInfo = {
clientInfo?: string,
environmentInfo?: string
}
export type PercyConfigOptions<C = Pojo> = C & {
snapshot?: CommonSnapshotOptions,
discovery?: AllDiscoveryOptions
}
export type PercyOptions<C = Pojo> = {
token?: string,
server?: boolean,
port?: number,
concurrency?: number,
loglevel?: LogLevel,
config?: undefined | string | false
} & ClientEnvInfo & PercyConfigOptions<C>;
type SnapshotExec = () => void | Promise<void>;
type AdditionalSnapshot = (XOR<XOR<
{ name: string },
{ prefix: string, suffix?: string }>,
{ suffix: string, prefix?: string }>
) & { execute: SnapshotExec };
declare class Percy {
static start(options?: PercyOptions): Promise<Percy>;
constructor(options?: PercyOptions);
loglevel(): LogLevel;
loglevel(level: LogLevel): void;
config: PercyConfigOptions;
setConfig(config: ClientEnvInfo & PercyConfigOptions): PercyConfigOptions;
start(): Promise<void>;
stop(force?: boolean): Promise<void>;
idle(): Promise<void>;
close(): void;
snapshot(options: {
url: string,
name?: string,
clientInfo?: string,
environmentInfo?: string
} & XOR<{
domSnapshot: string
}, {
waitForTimeout?: number,
waitForSelector?: string,
execute?: SnapshotExec,
additionalSnapshots?: AdditionalSnapshot[]
}> & SnapshotOptions): Promise<void>;
}
export default Percy;