1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | import { ParsedDocument } from '..';
|
16 | import { Analysis } from '../model/model';
|
17 | import { PackageRelativeUrl, ResolvedUrl } from '../model/url';
|
18 | import { Parser } from '../parser/parser';
|
19 | import { Scanner } from '../scanning/scanner';
|
20 | import { UrlLoader } from '../url-loader/url-loader';
|
21 | import { UrlResolver } from '../url-loader/url-resolver';
|
22 | import { AnalysisContext } from './analysis-context';
|
23 | import { MinimalCancelToken } from './cancel-token';
|
24 | export interface Options {
|
25 | urlLoader: UrlLoader;
|
26 | urlResolver?: UrlResolver;
|
27 | parsers?: Map<string, Parser<ParsedDocument>>;
|
28 | scanners?: ScannerTable;
|
29 | |
30 |
|
31 |
|
32 |
|
33 | lazyEdges?: LazyEdgeMap;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | moduleResolution?: 'node';
|
40 | __contextPromise?: Promise<AnalysisContext>;
|
41 | }
|
42 | export interface AnalyzeOptions {
|
43 | |
44 |
|
45 |
|
46 |
|
47 | readonly cancelToken?: MinimalCancelToken;
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | export interface ForkOptions {
|
54 | urlLoader?: UrlLoader;
|
55 | }
|
56 | export declare class NoKnownParserError extends Error {
|
57 | }
|
58 | export declare type ScannerTable = Map<string, Scanner<ParsedDocument, {} | null | undefined, {}>[]>;
|
59 | export declare type LazyEdgeMap = Map<ResolvedUrl, PackageRelativeUrl[]>;
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | export declare class Analyzer {
|
69 | private _analysisComplete;
|
70 | readonly urlResolver: UrlResolver;
|
71 | private readonly _urlLoader;
|
72 | constructor(options: Options);
|
73 | /**
|
74 | * Loads, parses and analyzes the root document of a dependency graph and its
|
75 | * transitive dependencies.
|
76 | */
|
77 | analyze(urls: string[], options?: AnalyzeOptions): Promise<Analysis>;
|
78 | analyzePackage(options?: AnalyzeOptions): Promise<Analysis>;
|
79 | private _filterFilesByParsableExtension;
|
80 | private _constructAnalysis;
|
81 | /**
|
82 | * Clears all information about the given files from our caches, such that
|
83 | * future calls to analyze() will reload these files if they're needed.
|
84 | *
|
85 | * The analyzer assumes that if this method isn't called with a file's url,
|
86 | * then that file has not changed and does not need to be reloaded.
|
87 | *
|
88 | * @param urls The urls of files which may have changed.
|
89 | */
|
90 | filesChanged(urls: string[]): Promise<void>;
|
91 | /**
|
92 | * Clear all cached information from this analyzer instance.
|
93 | *
|
94 | * Note: if at all possible, instead tell the analyzer about the specific
|
95 | * files that changed rather than clearing caches like this. Caching provides
|
96 | * large performance gains.
|
97 | */
|
98 | clearCaches(): Promise<void>;
|
99 | /**
|
100 | * Returns a copy of the analyzer. If options are given, the AnalysisContext
|
101 | * is also forked and individual properties are overridden by the options.
|
102 | * is forked with the given options.
|
103 | *
|
104 | * When the analysis context is forked, its cache is preserved, so you will
|
105 | * see a mixture of pre-fork and post-fork contents when you analyze with a
|
106 | * forked analyzer.
|
107 | *
|
108 | * Note: this feature is experimental. It may be removed without being
|
109 | * considered a breaking change, so check for its existence before calling
|
110 | * it.
|
111 | */
|
112 | _fork(options?: ForkOptions): Analyzer;
|
113 | /**
|
114 | * Returns `true` if the provided resolved URL can be loaded. Obeys the
|
115 | * semantics defined by `UrlLoader` and should only be used to check
|
116 | * resolved URLs.
|
117 | */
|
118 | canLoad(resolvedUrl: ResolvedUrl): boolean;
|
119 | /**
|
120 | * Loads the content at the provided resolved URL. Obeys the semantics
|
121 | * defined by `UrlLoader` and should only be used to attempt to load resolved
|
122 | * URLs.
|
123 | */
|
124 | load(resolvedUrl: ResolvedUrl): Promise<string>;
|
125 | /**
|
126 | * Resoves `url` to a new location.
|
127 | */
|
128 | resolveUrl(url: string): ResolvedUrl | undefined;
|
129 | private brandUserInputUrls;
|
130 | }
|