@percy/core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +94 -0
- package/dist/browser.js +292 -0
- package/dist/config.js +551 -0
- package/dist/discovery.js +118 -0
- package/dist/index.js +5 -0
- package/dist/install.js +156 -0
- package/dist/network.js +298 -0
- package/dist/page.js +264 -0
- package/dist/percy.js +484 -0
- package/dist/queue.js +152 -0
- package/dist/server.js +430 -0
- package/dist/session.js +103 -0
- package/dist/snapshot.js +433 -0
- package/dist/utils.js +127 -0
- package/package.json +10 -10
- package/post-install.js +20 -0
- package/test/helpers/server.js +33 -0
- package/types/index.d.ts +101 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// utility types
|
|
2
|
+
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
|
3
|
+
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
4
|
+
|
|
5
|
+
type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'silent';
|
|
6
|
+
|
|
7
|
+
interface Pojo {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface AuthCredentials {
|
|
12
|
+
username: string;
|
|
13
|
+
password: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DiscoveryOptions {
|
|
17
|
+
requestHeaders?: Pojo;
|
|
18
|
+
authorization?: AuthCredentials;
|
|
19
|
+
allowedHostnames?: string[];
|
|
20
|
+
disableCache?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface DiscoveryLaunchOptions {
|
|
24
|
+
executable?: string;
|
|
25
|
+
args?: string[];
|
|
26
|
+
timeout?: number;
|
|
27
|
+
headless?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface AllDiscoveryOptions extends DiscoveryOptions {
|
|
31
|
+
networkIdleTimeout?: number;
|
|
32
|
+
concurrency?: number;
|
|
33
|
+
launchOptions?: DiscoveryLaunchOptions;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface CommonSnapshotOptions {
|
|
37
|
+
widths?: number[];
|
|
38
|
+
minHeight?: number;
|
|
39
|
+
percyCSS?: string;
|
|
40
|
+
enableJavaScript?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SnapshotOptions extends CommonSnapshotOptions {
|
|
44
|
+
discovery?: DiscoveryOptions;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type ClientEnvInfo = {
|
|
48
|
+
clientInfo?: string,
|
|
49
|
+
environmentInfo?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type PercyConfigOptions<C = Pojo> = C & {
|
|
53
|
+
snapshot?: CommonSnapshotOptions,
|
|
54
|
+
discovery?: AllDiscoveryOptions
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type PercyOptions<C = Pojo> = {
|
|
58
|
+
token?: string,
|
|
59
|
+
server?: boolean,
|
|
60
|
+
port?: number,
|
|
61
|
+
concurrency?: number,
|
|
62
|
+
loglevel?: LogLevel,
|
|
63
|
+
config?: undefined | string | false
|
|
64
|
+
} & ClientEnvInfo & PercyConfigOptions<C>;
|
|
65
|
+
|
|
66
|
+
type SnapshotExec = () => void | Promise<void>;
|
|
67
|
+
|
|
68
|
+
type AdditionalSnapshot = (XOR<XOR<
|
|
69
|
+
{ name: string },
|
|
70
|
+
{ prefix: string, suffix?: string }>,
|
|
71
|
+
{ suffix: string, prefix?: string }>
|
|
72
|
+
) & { execute: SnapshotExec };
|
|
73
|
+
|
|
74
|
+
declare class Percy {
|
|
75
|
+
static start(options?: PercyOptions): Promise<Percy>;
|
|
76
|
+
constructor(options?: PercyOptions);
|
|
77
|
+
loglevel(): LogLevel;
|
|
78
|
+
loglevel(level: LogLevel): void;
|
|
79
|
+
config: PercyConfigOptions;
|
|
80
|
+
setConfig(config: ClientEnvInfo & PercyConfigOptions): PercyConfigOptions;
|
|
81
|
+
start(): Promise<void>;
|
|
82
|
+
stop(force?: boolean): Promise<void>;
|
|
83
|
+
idle(): Promise<void>;
|
|
84
|
+
close(): void;
|
|
85
|
+
|
|
86
|
+
snapshot(options: {
|
|
87
|
+
url: string,
|
|
88
|
+
name?: string,
|
|
89
|
+
clientInfo?: string,
|
|
90
|
+
environmentInfo?: string
|
|
91
|
+
} & XOR<{
|
|
92
|
+
domSnapshot: string
|
|
93
|
+
}, {
|
|
94
|
+
waitForTimeout?: number,
|
|
95
|
+
waitForSelector?: string,
|
|
96
|
+
execute?: SnapshotExec,
|
|
97
|
+
additionalSnapshots?: AdditionalSnapshot[]
|
|
98
|
+
}> & SnapshotOptions): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default Percy;
|