1 | import Webpack, { Stats } from 'webpack';
|
2 |
|
3 | type ReporterContextFunc<T = any> = (context: WebpackBarPlugin, opts: T) => void;
|
4 |
|
5 | interface State {
|
6 | start: [number, number] | null;
|
7 | progress: number;
|
8 | done: boolean;
|
9 | message: string;
|
10 | details: string[];
|
11 | request: null | {
|
12 | file: null | string;
|
13 | loaders: string[];
|
14 | };
|
15 | hasErrors: boolean;
|
16 | color: string;
|
17 | name: string;
|
18 | }
|
19 |
|
20 | interface Reporter {
|
21 | |
22 |
|
23 |
|
24 | start?: ReporterContextFunc;
|
25 |
|
26 | |
27 |
|
28 |
|
29 | change?: ReporterContextFunc<{ shortPath: string }>;
|
30 |
|
31 | |
32 |
|
33 |
|
34 | update?: ReporterContextFunc;
|
35 |
|
36 | |
37 |
|
38 |
|
39 | done?: ReporterContextFunc<{ stats: Stats }>;
|
40 |
|
41 | |
42 |
|
43 |
|
44 | progress?: ReporterContextFunc;
|
45 |
|
46 | |
47 |
|
48 |
|
49 | allDone?: ReporterContextFunc;
|
50 |
|
51 | beforeAllDone?: ReporterContextFunc;
|
52 |
|
53 | afterAllDone?: ReporterContextFunc;
|
54 | }
|
55 |
|
56 | type ReporterOpts = { reporter: Reporter | string; options?: any };
|
57 | type ReporterInput = string | [Reporter | string, any?] | ReporterOpts;
|
58 |
|
59 | interface WebpackBarOptions {
|
60 | |
61 |
|
62 |
|
63 |
|
64 | name?: string;
|
65 |
|
66 | |
67 |
|
68 |
|
69 |
|
70 | color?: string;
|
71 |
|
72 | |
73 |
|
74 |
|
75 |
|
76 | profile?: boolean;
|
77 |
|
78 | |
79 |
|
80 |
|
81 |
|
82 |
|
83 | fancy?: boolean;
|
84 |
|
85 | |
86 |
|
87 |
|
88 |
|
89 |
|
90 | basic?: boolean;
|
91 |
|
92 | |
93 |
|
94 |
|
95 | reporter?: ReporterInput;
|
96 |
|
97 | |
98 |
|
99 |
|
100 |
|
101 | reporters?: ReporterInput[];
|
102 | }
|
103 |
|
104 | declare class WebpackBarPlugin extends Webpack.ProgressPlugin {
|
105 | private options;
|
106 | private reporters;
|
107 | constructor(options?: WebpackBarOptions);
|
108 | callReporters(fn: any, payload?: {}): void;
|
109 | get hasRunning(): boolean;
|
110 | get hasErrors(): boolean;
|
111 | get statesArray(): any[];
|
112 | get states(): {
|
113 | [key: string]: State;
|
114 | };
|
115 | get state(): State;
|
116 | _ensureState(): void;
|
117 | apply(compiler: any): void;
|
118 | updateProgress(percent?: number, message?: string, details?: any[]): void;
|
119 | }
|
120 |
|
121 | export { type Reporter, type State, WebpackBarPlugin as default };
|