UNPKG

2.15 kBTypeScriptView Raw
1/// <reference types="node" />
2import { PassThrough } from 'stream';
3import { MessageName } from './MessageName';
4import { Locator } from './types';
5export declare class ReportError extends Error {
6 reportExtra?: ((report: Report) => void) | undefined;
7 reportCode: MessageName;
8 constructor(code: MessageName, message: string, reportExtra?: ((report: Report) => void) | undefined);
9}
10export declare function isReportError(error: Error): error is ReportError;
11export declare type ProgressDefinition = {
12 progress: number;
13 title?: string;
14};
15export declare abstract class Report {
16 private reportedInfos;
17 private reportedWarnings;
18 private reportedErrors;
19 abstract reportCacheHit(locator: Locator): void;
20 abstract reportCacheMiss(locator: Locator, message?: string): void;
21 abstract startTimerPromise<T>(what: string, cb: () => Promise<T>): Promise<T>;
22 abstract startTimerSync<T>(what: string, cb: () => T): T;
23 abstract startCacheReport<T>(cb: () => Promise<T>): Promise<T>;
24 abstract reportSeparator(): void;
25 abstract reportInfo(name: MessageName | null, text: string): void;
26 abstract reportWarning(name: MessageName, text: string): void;
27 abstract reportError(name: MessageName, text: string): void;
28 abstract reportProgress(progress: AsyncIterable<ProgressDefinition>): Promise<void> & {
29 stop: () => void;
30 };
31 abstract reportJson(data: any): void;
32 abstract finalize(): void;
33 static progressViaCounter(max: number): {
34 [Symbol.asyncIterator](): AsyncGenerator<{
35 progress: number;
36 }, void, unknown>;
37 set: (n: number) => void;
38 tick: (n?: number) => void;
39 };
40 reportInfoOnce(name: MessageName, text: string, opts?: {
41 key?: any;
42 }): void;
43 reportWarningOnce(name: MessageName, text: string, opts?: {
44 key?: any;
45 }): void;
46 reportErrorOnce(name: MessageName, text: string, opts?: {
47 key?: any;
48 reportExtra?: (report: Report) => void;
49 }): void;
50 reportExceptionOnce(error: Error | ReportError): void;
51 createStreamReporter(prefix?: string | null): PassThrough;
52}