source-map-support.d.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // 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. export interface RawSourceMap {
  9. version: 3;
  10. sources: string[];
  11. names: string[];
  12. sourceRoot?: string;
  13. sourcesContent?: string[];
  14. mappings: string;
  15. file: string;
  16. }
  17. /**
  18. * Output of retrieveSourceMap().
  19. * From source-map-support:
  20. * The map field may be either a string or the parsed JSON object (i.e.,
  21. * it must be a valid argument to the SourceMapConsumer constructor).
  22. */
  23. export interface UrlAndMap {
  24. url: string;
  25. map: string | RawSourceMap;
  26. }
  27. /**
  28. * Options to install().
  29. */
  30. export interface Options {
  31. handleUncaughtExceptions?: boolean | undefined;
  32. hookRequire?: boolean | undefined;
  33. emptyCacheBetweenOperations?: boolean | undefined;
  34. environment?: 'auto' | 'browser' | 'node' | undefined;
  35. overrideRetrieveFile?: boolean | undefined;
  36. overrideRetrieveSourceMap?: boolean | undefined;
  37. retrieveFile?(path: string): string;
  38. retrieveSourceMap?(source: string): UrlAndMap | null;
  39. /**
  40. * Set false to disable redirection of require / import `source-map-support` to `@cspotcode/source-map-support`
  41. */
  42. redirectConflictingLibrary?: boolean;
  43. /**
  44. * Callback will be called every time we redirect due to `redirectConflictingLibrary`
  45. * This allows consumers to log helpful warnings if they choose.
  46. * @param parent NodeJS.Module which made the require() or require.resolve() call
  47. * @param options options object internally passed to node's `_resolveFilename` hook
  48. */
  49. onConflictingLibraryRedirect?: (request: string, parent: any, isMain: boolean, options: any, redirectedRequest: string) => void;
  50. }
  51. export interface Position {
  52. source: string;
  53. line: number;
  54. column: number;
  55. }
  56. export function wrapCallSite(frame: any /* StackFrame */): any /* StackFrame */;
  57. export function getErrorSource(error: Error): string | null;
  58. export function mapSourcePosition(position: Position): Position;
  59. export function retrieveSourceMap(source: string): UrlAndMap | null;
  60. export function resetRetrieveHandlers(): void;
  61. /**
  62. * Install SourceMap support.
  63. * @param options Can be used to e.g. disable uncaughtException handler.
  64. */
  65. export function install(options?: Options): void;
  66. /**
  67. * Uninstall SourceMap support.
  68. */
  69. export function uninstall(): void;