metro-source-map
Advanced tools
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| /** | ||
| * Efficient builder for base64 VLQ mappings strings. | ||
| * | ||
| * This class uses a buffer that is preallocated with one megabyte and is | ||
| * reallocated dynamically as needed, doubling its size. | ||
| * | ||
| * Encoding never creates any complex value types (strings, objects), and only | ||
| * writes character values to the buffer. | ||
| * | ||
| * For details about source map terminology and specification, check | ||
| * https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit | ||
| */ | ||
| declare class B64Builder { | ||
| buffer: Buffer; | ||
| pos: number; | ||
| hasSegment: boolean; | ||
| constructor(); | ||
| /** | ||
| * Adds `n` markers for generated lines to the mappings. | ||
| */ | ||
| markLines(n: number): this; | ||
| /** | ||
| * Starts a segment at the specified column offset in the current line. | ||
| */ | ||
| startSegment(column: number): this; | ||
| /** | ||
| * Appends a single number to the mappings. | ||
| */ | ||
| append(value: number): this; | ||
| /** | ||
| * Returns the string representation of the mappings. | ||
| */ | ||
| toString(): string; | ||
| _writeByte(byte: number): void; | ||
| _realloc(): void; | ||
| } | ||
| export default B64Builder; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {IndexMap, IndexMapSection, MixedSourceMap} from './source-map'; | ||
| /** | ||
| * Builds a source-mapped bundle by concatenating strings and their | ||
| * corresponding source maps (if any). | ||
| * | ||
| * Usage: | ||
| * | ||
| * const builder = new BundleBuilder('bundle.js'); | ||
| * builder | ||
| * .append('foo\n', fooMap) | ||
| * .append('bar\n') | ||
| * // ... | ||
| * const code = builder.getCode(); | ||
| * const map = builder.getMap(); | ||
| */ | ||
| export declare class BundleBuilder { | ||
| _file: string; | ||
| _sections: Array<IndexMapSection>; | ||
| _line: number; | ||
| _column: number; | ||
| _code: string; | ||
| _afterMappedContent: boolean; | ||
| constructor(file: string); | ||
| _pushMapSection(map: MixedSourceMap): void; | ||
| _endMappedContent(): void; | ||
| append(code: string, map: null | undefined | MixedSourceMap): this; | ||
| getMap(): MixedSourceMap; | ||
| getCode(): string; | ||
| } | ||
| export declare function createIndexMap( | ||
| file: string, | ||
| sections: Array<IndexMapSection>, | ||
| ): IndexMap; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {MixedSourceMap} from './source-map'; | ||
| declare function composeSourceMaps( | ||
| maps: ReadonlyArray<MixedSourceMap>, | ||
| ): MixedSourceMap; | ||
| export default composeSourceMaps; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type { | ||
| GeneratedPositionLookup, | ||
| IConsumer, | ||
| IterationOrder, | ||
| Mapping, | ||
| SourcePosition, | ||
| } from './types'; | ||
| declare class AbstractConsumer implements IConsumer { | ||
| _sourceMap: {readonly file?: string}; | ||
| constructor(sourceMap: {readonly file?: string}); | ||
| originalPositionFor( | ||
| generatedPosition: GeneratedPositionLookup, | ||
| ): SourcePosition; | ||
| generatedMappings(): Iterable<Mapping>; | ||
| eachMapping( | ||
| callback: (mapping: Mapping) => unknown, | ||
| context?: unknown, | ||
| order?: IterationOrder, | ||
| ): void; | ||
| get file(): null | undefined | string; | ||
| sourceContentFor( | ||
| source: string, | ||
| nullOnMissing: true, | ||
| ): null | undefined | string; | ||
| } | ||
| export default AbstractConsumer; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {Number0, Number1} from 'ob1'; | ||
| declare const FIRST_COLUMN: Number0; | ||
| declare const FIRST_LINE: Number1; | ||
| export declare type IterationOrder = symbol & {__IterationOrder__: string}; | ||
| declare const GENERATED_ORDER: IterationOrder; | ||
| declare const ORIGINAL_ORDER: IterationOrder; | ||
| export declare type LookupBias = symbol & {__LookupBias__: string}; | ||
| declare const GREATEST_LOWER_BOUND: LookupBias; | ||
| declare const LEAST_UPPER_BOUND: LookupBias; | ||
| declare const EMPTY_POSITION: Readonly<{ | ||
| source: null; | ||
| name: null; | ||
| line: null; | ||
| column: null; | ||
| }>; | ||
| declare function iterationOrderToString(x: IterationOrder): string; | ||
| declare function lookupBiasToString(x: LookupBias): string; | ||
| export { | ||
| FIRST_COLUMN, | ||
| FIRST_LINE, | ||
| GENERATED_ORDER, | ||
| ORIGINAL_ORDER, | ||
| GREATEST_LOWER_BOUND, | ||
| LEAST_UPPER_BOUND, | ||
| EMPTY_POSITION, | ||
| iterationOrderToString, | ||
| lookupBiasToString, | ||
| }; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {MixedSourceMap} from '../source-map'; | ||
| import type {IConsumer} from './types'; | ||
| declare function createConsumer(sourceMap: MixedSourceMap): IConsumer; | ||
| export default createConsumer; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {MixedSourceMap} from '../source-map'; | ||
| import type {LookupBias} from './constants.js'; | ||
| import type { | ||
| GeneratedPositionLookup, | ||
| IConsumer, | ||
| IterationOrder, | ||
| Mapping, | ||
| SourcePosition, | ||
| } from './types'; | ||
| /** | ||
| * A source map consumer that supports both "basic" and "indexed" source maps. | ||
| * Uses `MappingsConsumer` and `SectionsConsumer` under the hood (via | ||
| * `createConsumer`). | ||
| */ | ||
| declare class DelegatingConsumer implements IConsumer { | ||
| static readonly GENERATED_ORDER: IterationOrder; | ||
| static readonly ORIGINAL_ORDER: IterationOrder; | ||
| static readonly GREATEST_LOWER_BOUND: LookupBias; | ||
| static readonly LEAST_UPPER_BOUND: LookupBias; | ||
| _rootConsumer: IConsumer; | ||
| constructor(sourceMap: MixedSourceMap); | ||
| originalPositionFor( | ||
| generatedPosition: GeneratedPositionLookup, | ||
| ): SourcePosition; | ||
| generatedMappings(): Iterable<Mapping>; | ||
| eachMapping( | ||
| callback: (mapping: Mapping) => unknown, | ||
| context?: unknown, | ||
| order?: IterationOrder, | ||
| ): void; | ||
| get file(): null | undefined | string; | ||
| sourceContentFor( | ||
| source: string, | ||
| nullOnMissing: true, | ||
| ): null | undefined | string; | ||
| } | ||
| export default DelegatingConsumer; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import DelegatingConsumer from './DelegatingConsumer'; | ||
| declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof DelegatingConsumer; | ||
| declare type $$EXPORT_DEFAULT_DECLARATION$$ = | ||
| typeof $$EXPORT_DEFAULT_DECLARATION$$; | ||
| export default $$EXPORT_DEFAULT_DECLARATION$$; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {BasicSourceMap} from '../source-map'; | ||
| import type { | ||
| GeneratedPositionLookup, | ||
| IConsumer, | ||
| Mapping, | ||
| SourcePosition, | ||
| } from './types'; | ||
| import type {Number0} from 'ob1'; | ||
| import AbstractConsumer from './AbstractConsumer'; | ||
| /** | ||
| * A source map consumer that supports "basic" source maps (that have a | ||
| * `mappings` field and no sections). | ||
| */ | ||
| declare class MappingsConsumer extends AbstractConsumer implements IConsumer { | ||
| _sourceMap: BasicSourceMap; | ||
| _decodedMappings: null | undefined | ReadonlyArray<Mapping>; | ||
| _normalizedSources: null | undefined | ReadonlyArray<string>; | ||
| constructor(sourceMap: BasicSourceMap); | ||
| originalPositionFor( | ||
| generatedPosition: GeneratedPositionLookup, | ||
| ): SourcePosition; | ||
| _decodeMappings(): Generator<Mapping, void, void>; | ||
| _normalizeAndCacheSources(): ReadonlyArray<string>; | ||
| _decodeAndCacheMappings(): ReadonlyArray<Mapping>; | ||
| generatedMappings(): Iterable<Mapping>; | ||
| _indexOfSource(source: string): null | undefined | Number0; | ||
| sourceContentFor( | ||
| source: string, | ||
| nullOnMissing: true, | ||
| ): null | undefined | string; | ||
| } | ||
| export default MappingsConsumer; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| declare function normalizeSourcePath( | ||
| sourceInput: string, | ||
| map: {readonly sourceRoot?: null | undefined | string}, | ||
| ): string; | ||
| export default normalizeSourcePath; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {GeneratedOffset} from './types'; | ||
| import type {Number0, Number1} from 'ob1'; | ||
| export declare function shiftPositionByOffset< | ||
| T extends { | ||
| readonly line: null | undefined | Number1; | ||
| readonly column: null | undefined | Number0; | ||
| }, | ||
| >(pos: T, offset: GeneratedOffset): T; | ||
| export declare function subtractOffsetFromPosition< | ||
| T extends { | ||
| readonly line: null | undefined | Number1; | ||
| readonly column: null | undefined | Number0; | ||
| }, | ||
| >(pos: T, offset: GeneratedOffset): T; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| export declare function greatestLowerBound<T, U>( | ||
| elements: ReadonlyArray<T>, | ||
| target: U, | ||
| comparator: ($$PARAM_0$$: U, $$PARAM_1$$: T) => number, | ||
| ): null | undefined | number; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {IndexMap} from '../source-map'; | ||
| import type { | ||
| GeneratedOffset, | ||
| GeneratedPositionLookup, | ||
| IConsumer, | ||
| Mapping, | ||
| SourcePosition, | ||
| } from './types'; | ||
| import AbstractConsumer from './AbstractConsumer'; | ||
| /** | ||
| * A source map consumer that supports "indexed" source maps (that have a | ||
| * `sections` field and no top-level mappings). | ||
| */ | ||
| declare class SectionsConsumer extends AbstractConsumer implements IConsumer { | ||
| _consumers: ReadonlyArray<[GeneratedOffset, IConsumer]>; | ||
| constructor(sourceMap: IndexMap); | ||
| originalPositionFor( | ||
| generatedPosition: GeneratedPositionLookup, | ||
| ): SourcePosition; | ||
| generatedMappings(): Iterable<Mapping>; | ||
| _consumerForPosition( | ||
| generatedPosition: GeneratedPositionLookup, | ||
| ): null | undefined | [GeneratedOffset, IConsumer]; | ||
| sourceContentFor( | ||
| source: string, | ||
| nullOnMissing: true, | ||
| ): null | undefined | string; | ||
| } | ||
| export default SectionsConsumer; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {IterationOrder, LookupBias} from './constants'; | ||
| import type {Number0, Number1} from 'ob1'; | ||
| export type {IterationOrder, LookupBias}; | ||
| export type GeneratedOffset = { | ||
| readonly lines: Number0; | ||
| readonly columns: Number0; | ||
| }; | ||
| export type SourcePosition = { | ||
| source: null | undefined | string; | ||
| line: null | undefined | Number1; | ||
| column: null | undefined | Number0; | ||
| name: null | undefined | string; | ||
| }; | ||
| export type GeneratedPosition = { | ||
| readonly line: Number1; | ||
| readonly column: Number0; | ||
| }; | ||
| export type GeneratedPositionLookup = { | ||
| readonly line: null | undefined | Number1; | ||
| readonly column: null | undefined | Number0; | ||
| readonly bias?: LookupBias; | ||
| }; | ||
| export type Mapping = Readonly<{ | ||
| source: null | undefined | string; | ||
| generatedLine: Number1; | ||
| generatedColumn: Number0; | ||
| originalLine: null | undefined | Number1; | ||
| originalColumn: null | undefined | Number0; | ||
| name: null | undefined | string; | ||
| }>; | ||
| export interface IConsumer { | ||
| originalPositionFor( | ||
| generatedPosition: GeneratedPositionLookup, | ||
| ): SourcePosition; | ||
| generatedMappings(): Iterable<Mapping>; | ||
| eachMapping( | ||
| callback: (mapping: Mapping) => unknown, | ||
| context?: unknown, | ||
| order?: IterationOrder, | ||
| ): void; | ||
| get file(): null | undefined | string; | ||
| sourceContentFor( | ||
| source: string, | ||
| nullOnMissing: true, | ||
| ): null | undefined | string; | ||
| } |
| /** | ||
| * Portions Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| /** | ||
| * Copyright 2011 Mozilla Foundation and contributors | ||
| * Licensed under the New BSD license. See LICENSE or: | ||
| * http://opensource.org/licenses/BSD-3-Clause | ||
| * | ||
| * Based on the Base 64 VLQ implementation in Closure Compiler: | ||
| * https://git.io/vymuA | ||
| * | ||
| * Copyright 2011 The Closure Compiler Authors. All rights reserved. | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following | ||
| * disclaimer in the documentation and/or other materials provided | ||
| * with the distribution. | ||
| * * Neither the name of Google Inc. nor the names of its | ||
| * contributors may be used to endorse or promote products derived | ||
| * from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * @copyright | ||
| * | ||
| * Associate this with the THIRD_PARTY_LICENCE type to ensure it isn't | ||
| * stripped by flow-api-translator. | ||
| */ | ||
| export type THIRD_PARTY_LICENSE = unknown; | ||
| /** | ||
| * Encodes a number to base64 VLQ format and appends it to the passed-in buffer | ||
| * | ||
| * DON'T USE COMPOUND OPERATORS (eg `>>>=`) ON `let`-DECLARED VARIABLES! | ||
| * V8 WILL DEOPTIMIZE THIS FUNCTION AND MAP CREATION WILL BE 25% SLOWER! | ||
| * | ||
| * DON'T ADD MORE COMMENTS TO THIS FUNCTION TO KEEP ITS LENGTH SHORT ENOUGH FOR | ||
| * V8 OPTIMIZATION! | ||
| */ | ||
| declare function encode( | ||
| value: number, | ||
| buffer: Buffer, | ||
| position: number, | ||
| ): number; | ||
| export default encode; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {FBSourceFunctionMap} from './source-map'; | ||
| import type {PluginObj} from '@babel/core'; | ||
| import type {Node as BabelNode} from '@babel/types'; | ||
| type Position = {line: number; column: number}; | ||
| type RangeMapping = {name: string; start: Position}; | ||
| export type Context = {filename?: null | undefined | string}; | ||
| /** | ||
| * Generate a map of source positions to function names. The names are meant to | ||
| * describe the stack frame in an error trace and may contain more contextual | ||
| * information than just the actual name of the function. | ||
| * | ||
| * The output is encoded for use in a source map. For details about the format, | ||
| * see MappingEncoder below. | ||
| */ | ||
| declare function generateFunctionMap( | ||
| ast: BabelNode, | ||
| context?: Context, | ||
| ): FBSourceFunctionMap; | ||
| /** | ||
| * Same as generateFunctionMap, but returns the raw array of mappings instead | ||
| * of encoding it for use in a source map. | ||
| * | ||
| * Lines are 1-based and columns are 0-based. | ||
| */ | ||
| declare function generateFunctionMappingsArray( | ||
| ast: BabelNode, | ||
| context?: Context, | ||
| ): ReadonlyArray<RangeMapping>; | ||
| declare function functionMapBabelPlugin(): PluginObj; | ||
| export { | ||
| functionMapBabelPlugin, | ||
| generateFunctionMap, | ||
| generateFunctionMappingsArray, | ||
| }; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type { | ||
| BasicSourceMap, | ||
| FBSourceFunctionMap, | ||
| FBSourceMetadata, | ||
| } from './source-map'; | ||
| import B64Builder from './B64Builder'; | ||
| type FileFlags = Readonly<{addToIgnoreList?: boolean}>; | ||
| /** | ||
| * Generates a source map from raw mappings. | ||
| * | ||
| * Raw mappings are a set of 2, 4, or five elements: | ||
| * | ||
| * - line and column number in the generated source | ||
| * - line and column number in the original source | ||
| * - symbol name in the original source | ||
| * | ||
| * Mappings have to be passed in the order appearance in the generated source. | ||
| */ | ||
| declare class Generator { | ||
| builder: B64Builder; | ||
| last: { | ||
| generatedColumn: number; | ||
| generatedLine: number; | ||
| name: number; | ||
| source: number; | ||
| sourceColumn: number; | ||
| sourceLine: number; | ||
| }; | ||
| names: IndexedSet; | ||
| source: number; | ||
| sources: Array<string>; | ||
| sourcesContent: Array<null | undefined | string>; | ||
| x_facebook_sources: Array<null | undefined | FBSourceMetadata>; | ||
| x_google_ignoreList: Array<number>; | ||
| constructor(); | ||
| /** | ||
| * Mark the beginning of a new source file. | ||
| */ | ||
| startFile( | ||
| file: string, | ||
| code: string, | ||
| functionMap: null | undefined | FBSourceFunctionMap, | ||
| flags?: FileFlags, | ||
| ): void; | ||
| /** | ||
| * Mark the end of the current source file | ||
| */ | ||
| endFile(): void; | ||
| /** | ||
| * Adds a mapping for generated code without a corresponding source location. | ||
| */ | ||
| addSimpleMapping(generatedLine: number, generatedColumn: number): void; | ||
| /** | ||
| * Adds a mapping for generated code with a corresponding source location. | ||
| */ | ||
| addSourceMapping( | ||
| generatedLine: number, | ||
| generatedColumn: number, | ||
| sourceLine: number, | ||
| sourceColumn: number, | ||
| ): void; | ||
| /** | ||
| * Adds a mapping for code with a corresponding source location + symbol name. | ||
| */ | ||
| addNamedSourceMapping( | ||
| generatedLine: number, | ||
| generatedColumn: number, | ||
| sourceLine: number, | ||
| sourceColumn: number, | ||
| name: string, | ||
| ): void; | ||
| /** | ||
| * Return the source map as object. | ||
| */ | ||
| toMap(file?: string, options?: {excludeSource?: boolean}): BasicSourceMap; | ||
| /** | ||
| * Return the source map as string. | ||
| * | ||
| * This is ~2.5x faster than calling `JSON.stringify(generator.toMap())` | ||
| */ | ||
| toString(file?: string, options?: {excludeSource?: boolean}): string; | ||
| /** | ||
| * Determine whether we need to write the `x_facebook_sources` field. | ||
| * If the metadata is all `null`s, we can omit the field entirely. | ||
| */ | ||
| hasSourcesMetadata(): boolean; | ||
| } | ||
| export default Generator; | ||
| declare class IndexedSet { | ||
| map: Map<string, number>; | ||
| nextIndex: number; | ||
| constructor(); | ||
| indexFor(x: string): number; | ||
| items(): Array<string>; | ||
| } |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {IConsumer} from './Consumer/types'; | ||
| import {BundleBuilder, createIndexMap} from './BundleBuilder'; | ||
| import composeSourceMaps from './composeSourceMaps'; | ||
| import Consumer from './Consumer'; | ||
| import normalizeSourcePath from './Consumer/normalizeSourcePath'; | ||
| import { | ||
| functionMapBabelPlugin, | ||
| generateFunctionMap, | ||
| } from './generateFunctionMap'; | ||
| import Generator from './Generator'; | ||
| export type {IConsumer}; | ||
| type GeneratedCodeMapping = [number, number]; | ||
| type SourceMapping = [number, number, number, number]; | ||
| type SourceMappingWithName = [number, number, number, number, string]; | ||
| export type MetroSourceMapSegmentTuple = | ||
| | SourceMappingWithName | ||
| | SourceMapping | ||
| | GeneratedCodeMapping; | ||
| export type HermesFunctionOffsets = { | ||
| [$$Key$$: number]: ReadonlyArray<number>; | ||
| }; | ||
| export type FBSourcesArray = ReadonlyArray<null | undefined | FBSourceMetadata>; | ||
| export type FBSourceMetadata = [null | undefined | FBSourceFunctionMap]; | ||
| export type FBSourceFunctionMap = { | ||
| readonly names: ReadonlyArray<string>; | ||
| readonly mappings: string; | ||
| }; | ||
| export type BabelSourceMapSegment = Readonly<{ | ||
| generated: Readonly<{column: number; line: number}>; | ||
| original?: Readonly<{column: number; line: number}>; | ||
| source?: null | undefined | string; | ||
| name?: null | undefined | string; | ||
| }>; | ||
| export type FBSegmentMap = {[id: string]: MixedSourceMap}; | ||
| export type BasicSourceMap = { | ||
| readonly file?: string; | ||
| readonly mappings: string; | ||
| readonly names: Array<string>; | ||
| readonly sourceRoot?: string; | ||
| readonly sources: Array<string>; | ||
| readonly sourcesContent?: Array<null | undefined | string>; | ||
| readonly version: number; | ||
| readonly x_facebook_offsets?: Array<number>; | ||
| readonly x_metro_module_paths?: Array<string>; | ||
| readonly x_facebook_sources?: FBSourcesArray; | ||
| readonly x_facebook_segments?: FBSegmentMap; | ||
| readonly x_hermes_function_offsets?: HermesFunctionOffsets; | ||
| readonly x_google_ignoreList?: Array<number>; | ||
| }; | ||
| export type IndexMapSection = { | ||
| map: IndexMap | BasicSourceMap; | ||
| offset: {line: number; column: number}; | ||
| }; | ||
| export type IndexMap = { | ||
| readonly file?: string; | ||
| readonly mappings?: void; | ||
| readonly sourcesContent?: void; | ||
| readonly sections: Array<IndexMapSection>; | ||
| readonly version: number; | ||
| readonly x_facebook_offsets?: Array<number>; | ||
| readonly x_metro_module_paths?: Array<string>; | ||
| readonly x_facebook_sources?: void; | ||
| readonly x_facebook_segments?: FBSegmentMap; | ||
| readonly x_hermes_function_offsets?: HermesFunctionOffsets; | ||
| readonly x_google_ignoreList?: void; | ||
| }; | ||
| export type MixedSourceMap = IndexMap | BasicSourceMap; | ||
| /** | ||
| * Creates a source map from modules with "raw mappings", i.e. an array of | ||
| * tuples with either 2, 4, or 5 elements: | ||
| * generated line, generated column, source line, source line, symbol name. | ||
| * Accepts an `offsetLines` argument in case modules' code is to be offset in | ||
| * the resulting bundle, e.g. by some prefix code. | ||
| */ | ||
| declare function fromRawMappings( | ||
| modules: ReadonlyArray<{ | ||
| readonly map: null | undefined | ReadonlyArray<MetroSourceMapSegmentTuple>; | ||
| readonly functionMap: null | undefined | FBSourceFunctionMap; | ||
| readonly path: string; | ||
| readonly source: string; | ||
| readonly code: string; | ||
| readonly isIgnored: boolean; | ||
| readonly lineCount?: number; | ||
| }>, | ||
| offsetLines?: number, | ||
| ): Generator; | ||
| declare function fromRawMappingsNonBlocking( | ||
| modules: ReadonlyArray<{ | ||
| readonly map: null | undefined | ReadonlyArray<MetroSourceMapSegmentTuple>; | ||
| readonly functionMap: null | undefined | FBSourceFunctionMap; | ||
| readonly path: string; | ||
| readonly source: string; | ||
| readonly code: string; | ||
| readonly isIgnored: boolean; | ||
| readonly lineCount?: number; | ||
| }>, | ||
| offsetLines?: number, | ||
| ): Promise<Generator>; | ||
| /** | ||
| * Transforms a standard source map object into a Raw Mappings object, to be | ||
| * used across the bundler. | ||
| */ | ||
| declare function toBabelSegments( | ||
| sourceMap: BasicSourceMap, | ||
| ): Array<BabelSourceMapSegment>; | ||
| declare function toSegmentTuple( | ||
| mapping: BabelSourceMapSegment, | ||
| ): MetroSourceMapSegmentTuple; | ||
| export { | ||
| BundleBuilder, | ||
| composeSourceMaps, | ||
| Consumer, | ||
| createIndexMap, | ||
| generateFunctionMap, | ||
| fromRawMappings, | ||
| fromRawMappingsNonBlocking, | ||
| functionMapBabelPlugin, | ||
| normalizeSourcePath, | ||
| toBabelSegments, | ||
| toSegmentTuple, | ||
| }; | ||
| /** | ||
| * Backwards-compatibility with CommonJS consumers using interopRequireDefault. | ||
| * Do not add to this list. | ||
| * | ||
| * @deprecated Default import from 'metro-source-map' is deprecated, use named exports. | ||
| */ | ||
| declare const $$EXPORT_DEFAULT_DECLARATION$$: { | ||
| BundleBuilder: typeof BundleBuilder; | ||
| composeSourceMaps: typeof composeSourceMaps; | ||
| Consumer: typeof Consumer; | ||
| createIndexMap: typeof createIndexMap; | ||
| generateFunctionMap: typeof generateFunctionMap; | ||
| fromRawMappings: typeof fromRawMappings; | ||
| fromRawMappingsNonBlocking: typeof fromRawMappingsNonBlocking; | ||
| functionMapBabelPlugin: typeof functionMapBabelPlugin; | ||
| normalizeSourcePath: typeof normalizeSourcePath; | ||
| toBabelSegments: typeof toBabelSegments; | ||
| toSegmentTuple: typeof toSegmentTuple; | ||
| }; | ||
| declare type $$EXPORT_DEFAULT_DECLARATION$$ = | ||
| typeof $$EXPORT_DEFAULT_DECLARATION$$; | ||
| export default $$EXPORT_DEFAULT_DECLARATION$$; |
+5
-4
| { | ||
| "name": "metro-source-map", | ||
| "version": "0.83.4", | ||
| "version": "0.83.5", | ||
| "description": "🚇 Source map generator for Metro.", | ||
@@ -13,3 +13,4 @@ "main": "src/source-map.js", | ||
| "type": "git", | ||
| "url": "git@github.com:facebook/metro.git" | ||
| "url": "git+https://github.com/facebook/metro.git", | ||
| "directory": "packages/metro-source-map" | ||
| }, | ||
@@ -25,5 +26,5 @@ "scripts": { | ||
| "invariant": "^2.2.4", | ||
| "metro-symbolicate": "0.83.4", | ||
| "metro-symbolicate": "0.83.5", | ||
| "nullthrows": "^1.1.1", | ||
| "ob1": "0.83.4", | ||
| "ob1": "0.83.5", | ||
| "source-map": "^0.5.6", | ||
@@ -30,0 +31,0 @@ "vlq": "^1.0.0" |
@@ -9,7 +9,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -16,0 +12,0 @@ const MAX_SEGMENT_LENGTH = 7; |
@@ -10,7 +10,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -17,0 +13,0 @@ _Consumer.default; |
@@ -10,7 +10,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -17,0 +13,0 @@ class AbstractConsumer { |
@@ -11,7 +11,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -18,0 +14,0 @@ function createConsumer(sourceMap) { |
@@ -10,7 +10,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -17,0 +13,0 @@ class DelegatingConsumer { |
@@ -11,8 +11,4 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
| var _default = (exports.default = _DelegatingConsumer.default); |
@@ -17,7 +17,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -24,0 +20,0 @@ class MappingsConsumer extends _AbstractConsumer.default { |
@@ -9,7 +9,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -16,0 +12,0 @@ function normalizeSourcePath(sourceInput, map) { |
@@ -14,7 +14,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -21,0 +17,0 @@ class SectionsConsumer extends _AbstractConsumer.default { |
@@ -24,6 +24,3 @@ "use strict"; | ||
| i, | ||
| f = { | ||
| __proto__: null, | ||
| default: e, | ||
| }; | ||
| f = { __proto__: null, default: e }; | ||
| if (null === e || ("object" != typeof e && "function" != typeof e)) | ||
@@ -48,7 +45,3 @@ return f; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -55,0 +48,0 @@ function generateFunctionMap(ast, context) { |
+1
-5
@@ -9,7 +9,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -16,0 +12,0 @@ class Generator { |
@@ -63,7 +63,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -70,0 +66,0 @@ function fromRawMappingsImpl(isBlocking, onDone, modules, offsetLines) { |
139777
21.65%56
47.37%2390
45.29%+ Added
+ Added
- Removed
- Removed
Updated
Updated