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