1 | import * as babelTypes from "babel-types";
|
2 | import { FileCoverage, FileCoverageData, Range } from "istanbul-lib-coverage";
|
3 | import { RawSourceMap } from "source-map";
|
4 |
|
5 | export interface InstrumenterOptions {
|
6 | coverageVariable: string;
|
7 | preserveComments: boolean;
|
8 | compact: boolean;
|
9 | esModules: boolean;
|
10 | autoWrap: boolean;
|
11 | produceSourceMap: boolean;
|
12 | sourceMapUrlCallback(filename: string, url: string): void;
|
13 | debug: boolean;
|
14 | }
|
15 |
|
16 | export type InstrumenterCallback = (error: Error | null, code: string) => void;
|
17 |
|
18 | export class Instrumenter {
|
19 | fileCoverage: FileCoverage;
|
20 | sourceMap: RawSourceMap | null;
|
21 | opts: InstrumenterOptions;
|
22 |
|
23 | constructor(options?: Partial<InstrumenterOptions>);
|
24 |
|
25 | normalizeOpts(options?: Partial<InstrumenterOptions>): InstrumenterOptions;
|
26 |
|
27 | instrumentSync(
|
28 | code: string,
|
29 | filename: string,
|
30 | inputSourceMap?: RawSourceMap,
|
31 | ): string;
|
32 |
|
33 | instrument(
|
34 | code: string,
|
35 | filenameOrCallback: string | InstrumenterCallback,
|
36 | callback?: InstrumenterCallback,
|
37 | inputSourceMap?: RawSourceMap,
|
38 | ): void;
|
39 |
|
40 | lastFileCoverage(): FileCoverageData;
|
41 | lastSourceMap(): RawSourceMap;
|
42 | }
|
43 |
|
44 | export function createInstrumenter(
|
45 | options?: Partial<InstrumenterOptions>,
|
46 | ): Instrumenter;
|
47 |
|
48 | export interface InitialCoverage {
|
49 | path: string;
|
50 | hash: string;
|
51 | gcv: any;
|
52 | coverageData: any;
|
53 | }
|
54 |
|
55 | export function readInitialCoverage(code: string): InitialCoverage;
|
56 |
|
57 | export interface Visitor {
|
58 | enter(path: string): void;
|
59 | exit(path: string): { fileCoverage: FileCoverage; sourceMappingURL: string };
|
60 | }
|
61 |
|
62 | export interface VisitorOptions {
|
63 | coverageVariable: string;
|
64 | inputSourceMap: RawSourceMap;
|
65 | }
|
66 |
|
67 | export function programVisitor(
|
68 | types: typeof babelTypes,
|
69 | sourceFilePath?: string,
|
70 | opts?: Partial<VisitorOptions>,
|
71 | ): Visitor;
|