1declare module 'metro-source-map' {
2  //#region metro-source-map/src/source-map.js.flow
3
4  type GeneratedCodeMapping = [number, number];
5  type SourceMapping = [number, number, number, number];
6  type SourceMappingWithName = [number, number, number, number, string];
7
8  type HermesFunctionOffsets = { [key: number]: Readonly<Array<number>> };
9
10  type FBSourcesArray = Readonly<Array<FBSourceMetadata | null>>;
11  type FBSourceMetadata = [FBSourceFunctionMap | null];
12  export type FBSourceFunctionMap = {
13    names: Readonly<Array<string>>;
14    mappings: string;
15  };
16
17  type FBSegmentMap = { [id: string]: MixedSourceMap };
18
19  interface BasicSourceMap {
20    file?: string;
21    mappings: string;
22    names: Array<string>;
23    sourceRoot?: string;
24    sources: Array<string>;
25    sourcesContent?: Array<string | null>;
26    version: number;
27    x_facebook_offsets?: Array<number>;
28    x_metro_module_paths?: Array<string>;
29    x_facebook_sources?: FBSourcesArray;
30    x_facebook_segments?: FBSegmentMap;
31    x_hermes_function_offsets?: HermesFunctionOffsets;
32  }
33
34  interface IndexMapSection {
35    map: IndexMap | BasicSourceMap;
36    offset: {
37      line: number;
38      column: number;
39    };
40  }
41
42  interface IndexMap {
43    file?: string;
44    mappings?: void; // avoids SourceMap being a disjoint union
45    sections: Array<IndexMapSection>;
46    version: number;
47    x_facebook_offsets?: Array<number>;
48    x_metro_module_paths?: Array<string>;
49    x_facebook_sources?: FBSourcesArray;
50    x_facebook_segments?: FBSegmentMap;
51    x_hermes_function_offsets?: HermesFunctionOffsets;
52  }
53
54  type MixedSourceMap = IndexMap | BasicSourceMap;
55
56  //#endregion
57
58  //#region metro-source-map/src/composeSourceMaps.js.flow
59
60  export function composeSourceMaps(maps: Readonly<Array<MixedSourceMap>>): MixedSourceMap;
61
62  //#endregion
63
64  //#region metro-source-map/src/composeSourceMaps.js.flow
65
66  import type { Ast } from '@babel/core';
67
68  type Context = { filename?: string };
69
70  /**
71   * Generate a map of source positions to function names. The names are meant to
72   * describe the stack frame in an error trace and may contain more contextual
73   * information than just the actual name of the function.
74   *
75   * The output is encoded for use in a source map. For details about the format,
76   * see MappingEncoder below.
77   */
78  export function generateFunctionMap(ast: Ast, context?: Context): FBSourceFunctionMap;
79
80  //#endregion
81}
82