blob: d8cb9d8d352ed05b79068a6e41a821c1aa60cb42 [file] [log] [blame]
Samuel Shuert274a4d62023-12-01 15:04:55 -05001// Type definitions for source-map-support 0.5
2// Project: https://github.com/evanw/node-source-map-support
3// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
4// Jason Cheatham <https://github.com/jason0x43>
5// Alcedo Nathaniel De Guzman Jr <https://github.com/natealcedo>
6// Griffin Yourick <https://github.com/tough-griff>
7// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
8
9export interface RawSourceMap {
10 version: 3;
11 sources: string[];
12 names: string[];
13 sourceRoot?: string;
14 sourcesContent?: string[];
15 mappings: string;
16 file: string;
17}
18
19/**
20 * Output of retrieveSourceMap().
21 * From source-map-support:
22 * The map field may be either a string or the parsed JSON object (i.e.,
23 * it must be a valid argument to the SourceMapConsumer constructor).
24 */
25export interface UrlAndMap {
26 url: string;
27 map: string | RawSourceMap;
28}
29
30/**
31 * Options to install().
32 */
33export interface Options {
34 handleUncaughtExceptions?: boolean | undefined;
35 hookRequire?: boolean | undefined;
36 emptyCacheBetweenOperations?: boolean | undefined;
37 environment?: 'auto' | 'browser' | 'node' | undefined;
38 overrideRetrieveFile?: boolean | undefined;
39 overrideRetrieveSourceMap?: boolean | undefined;
40 retrieveFile?(path: string): string;
41 retrieveSourceMap?(source: string): UrlAndMap | null;
42 /**
43 * Set false to disable redirection of require / import `source-map-support` to `@cspotcode/source-map-support`
44 */
45 redirectConflictingLibrary?: boolean;
46 /**
47 * Callback will be called every time we redirect due to `redirectConflictingLibrary`
48 * This allows consumers to log helpful warnings if they choose.
49 * @param parent NodeJS.Module which made the require() or require.resolve() call
50 * @param options options object internally passed to node's `_resolveFilename` hook
51 */
52 onConflictingLibraryRedirect?: (request: string, parent: any, isMain: boolean, options: any, redirectedRequest: string) => void;
53}
54
55export interface Position {
56 source: string;
57 line: number;
58 column: number;
59}
60
61export function wrapCallSite(frame: any /* StackFrame */): any /* StackFrame */;
62export function getErrorSource(error: Error): string | null;
63export function mapSourcePosition(position: Position): Position;
64export function retrieveSourceMap(source: string): UrlAndMap | null;
65export function resetRetrieveHandlers(): void;
66
67/**
68 * Install SourceMap support.
69 * @param options Can be used to e.g. disable uncaughtException handler.
70 */
71export function install(options?: Options): void;
72
73/**
74 * Uninstall SourceMap support.
75 */
76export function uninstall(): void;