forked from NodeSecure/js-x-ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.d.ts
105 lines (90 loc) · 1.95 KB
/
api.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
import { Warning } from "./warnings.js";
import { Statement } from "meriyah/dist/src/estree.js";
export {
AstAnalyser,
SourceParser,
runASTAnalysis,
runASTAnalysisOnFile,
RuntimeOptions,
RuntimeFileOptions,
Report,
ReportOnFile,
SourceLocation,
Dependency
}
interface SourceLocation {
start: {
line: number;
column: number;
};
end: {
line: number;
column: number;
}
}
interface Dependency {
unsafe: boolean;
inTry: boolean;
location?: null | SourceLocation;
}
interface RuntimeOptions {
/**
* @default true
*/
module?: boolean;
/**
* @default false
*/
removeHTMLComments?: boolean;
/**
* @default false
*/
isMinified?: boolean;
}
interface RuntimeFileOptions extends Omit<RuntimeOptions, "isMinified"> {
packageName?: string;
}
interface AstAnalyserOptions {
/**
* @default JsSourceParser
*/
customParser?: SourceParser;
/**
* @default []
*/
customProbes?: Probe[];
/**
* @default false
*/
skipDefaultProbes?: boolean;
}
interface Probe {
validateNode: Function | Function[];
main: Function;
}
interface Report {
dependencies: Map<string, Dependency>;
warnings: Warning[];
idsLengthAvg: number;
stringScore: number;
isOneLineRequire: boolean;
}
type ReportOnFile = {
ok: true,
warnings: Warning[];
dependencies: Map<string, Dependency>;
isMinified: boolean;
} | {
ok: false,
warnings: Warning[];
}
interface SourceParser {
parse(source: string, options: unknown): Statement[];
}
declare class AstAnalyser {
constructor(options?: AstAnalyserOptions);
analyse: (str: string, options?: RuntimeOptions) => Report;
analyzeFile(pathToFile: string, options?: RuntimeFileOptions): Promise<ReportOnFile>;
}
declare function runASTAnalysis(str: string, options?: RuntimeOptions & AstAnalyserOptions): Report;
declare function runASTAnalysisOnFile(pathToFile: string, options?: RuntimeFileOptions & AstAnalyserOptions): Promise<ReportOnFile>;