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