prepack/flow-typed/npm/source-map_vx.x.x.js
Nikolai Tillmann 9d02cbc575 Fixing fixup of source locations, mostly. (#2356)
Summary:
Release notes: Fixing source map support.

I kept getting seemingly garbage source locations in error messages, and looked into that.
I found various issues:
- We in-place update positions, but they are actually shared between locations, and thus we may revisit positions. When we do, we map them again, and so on...
- Locations are also shared between nodes, so we kept revisiting and rewriting yet again.
- The actual mapping doesn't pay attention to the filename, so we apply the wrong mapping altogether, especially in the presence of multiple input files. I am not fixing this, but added a TODO, and opened #2353.
- Another remaining but not blocking issue is that something goes wrong with end-positions: They are sometimes mapped to some seemingly random position in the right line. If anyone knows anything about this, please let me know...
Pull Request resolved: https://github.com/facebook/prepack/pull/2356

Differential Revision: D9141809

Pulled By: NTillmann

fbshipit-source-id: d765e99706d69e3c792fba4c553d4110963067eb
2018-08-06 18:54:38 -07:00

278 lines
9.6 KiB
JavaScript

// flow-typed signature: 36b5a181ae05a516a711d68a54030532
// flow-typed version: <<STUB>>/source-map_v^0.5.6/flow_v0.76.0
/**
* This is an autogenerated libdef stub for:
*
* 'source-map'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'source-map' {
// Adapted from https://raw.githubusercontent.com/mozilla/source-map/c73baa52dedcbb77af97d90390d9def4d594c75f/source-map.d.ts
// Type definitions for source-map
// Project: https://github.com/mozilla/source-map
// Definitions by: Morten Houston Ludvigsen <https://github.com/MortenHoustonLudvigsen>,
// Ron Buckton <https://github.com/rbuckton>,
// John Vilk <https://github.com/jvilk>
// Definitions: https://github.com/mozilla/source-map
declare type SourceMapUrl = string;
declare interface Position {
line: number;
column: number;
}
declare interface NullablePosition {
line: number | null;
column: number | null;
lastColumn: number | null;
}
declare interface MappedPosition {
source: string;
line: number;
column: number;
name?: string;
}
declare interface NullableMappedPosition {
source: string | null;
line: number | null;
column: number | null;
name: string | null;
}
declare interface MappingItem {
source: string;
generatedLine: number;
generatedColumn: number;
originalLine: number;
originalColumn: number;
name: string;
}
declare interface Mapping {
generated: Position;
original: Position;
source: string;
name?: string;
}
declare class SourceMapConsumer {
constructor (rawSourceMap: string, sourceMapUrl?: SourceMapUrl): void;
/**
* Compute the last column for each generated mapping. The last column is
* inclusive.
*/
computeColumnSpans(): void;
/**
* Returns the original source, line, and column information for the generated
* source's line and column positions provided. The only argument is an object
* with the following properties:
*
* - line: The line number in the generated source.
* - column: The column number in the generated source.
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
* closest element that is smaller than or greater than the one we are
* searching for, respectively, if the exact element cannot be found.
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
*
* and an object is returned with the following properties:
*
* - source: The original source file, or null.
* - line: The line number in the original source, or null.
* - column: The column number in the original source, or null.
* - name: The original identifier, or null.
*/
originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition;
/**
* Returns the generated line and column information for the original source,
* line, and column positions provided. The only argument is an object with
* the following properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
* - column: The column number in the original source.
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
* closest element that is smaller than or greater than the one we are
* searching for, respectively, if the exact element cannot be found.
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
*
* and an object is returned with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition;
/**
* Returns all generated line and column information for the original source,
* line, and column provided. If no column is provided, returns all mappings
* corresponding to a either the line we are searching for or the next
* closest line that has any mappings. Otherwise, returns all mappings
* corresponding to the given line and either the column we are searching for
* or the next closest column that has any offsets.
*
* The only argument is an object with the following properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
* - column: Optional. the column number in the original source.
*
* and an array of objects is returned, each with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[];
/**
* Return true if we have the source content for every source in the source
* map, false otherwise.
*/
hasContentsOfAllSources(): boolean;
/**
* Returns the original source content. The only argument is the url of the
* original source file. Returns null if no original source content is
* available.
*/
sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
/**
* Iterate over each mapping between an original source/line/column and a
* generated line/column in this source map.
*
* @param callback
* The function that is called with each mapping.
* @param context
* Optional. If specified, this object will be the value of `this` every
* time that `aCallback` is called.
* @param order
* Either `SourceMapConsumer.GENERATED_ORDER` or
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
* iterate over the mappings sorted by the generated file's line/column
* order or the original's source/line/column order, respectively. Defaults to
* `SourceMapConsumer.GENERATED_ORDER`.
*/
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
}
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'source-map/dist/source-map.debug' {
declare module.exports: any;
}
declare module 'source-map/dist/source-map' {
declare module.exports: any;
}
declare module 'source-map/dist/source-map.min' {
declare module.exports: any;
}
declare module 'source-map/lib/array-set' {
declare module.exports: any;
}
declare module 'source-map/lib/base64-vlq' {
declare module.exports: any;
}
declare module 'source-map/lib/base64' {
declare module.exports: any;
}
declare module 'source-map/lib/binary-search' {
declare module.exports: any;
}
declare module 'source-map/lib/mapping-list' {
declare module.exports: any;
}
declare module 'source-map/lib/quick-sort' {
declare module.exports: any;
}
declare module 'source-map/lib/source-map-consumer' {
declare module.exports: any;
}
declare module 'source-map/lib/source-map-generator' {
declare module.exports: any;
}
declare module 'source-map/lib/source-node' {
declare module.exports: any;
}
declare module 'source-map/lib/util' {
declare module.exports: any;
}
declare module 'source-map/source-map' {
declare module.exports: any;
}
// Filename aliases
declare module 'source-map/dist/source-map.debug.js' {
declare module.exports: $Exports<'source-map/dist/source-map.debug'>;
}
declare module 'source-map/dist/source-map.js' {
declare module.exports: $Exports<'source-map/dist/source-map'>;
}
declare module 'source-map/dist/source-map.min.js' {
declare module.exports: $Exports<'source-map/dist/source-map.min'>;
}
declare module 'source-map/lib/array-set.js' {
declare module.exports: $Exports<'source-map/lib/array-set'>;
}
declare module 'source-map/lib/base64-vlq.js' {
declare module.exports: $Exports<'source-map/lib/base64-vlq'>;
}
declare module 'source-map/lib/base64.js' {
declare module.exports: $Exports<'source-map/lib/base64'>;
}
declare module 'source-map/lib/binary-search.js' {
declare module.exports: $Exports<'source-map/lib/binary-search'>;
}
declare module 'source-map/lib/mapping-list.js' {
declare module.exports: $Exports<'source-map/lib/mapping-list'>;
}
declare module 'source-map/lib/quick-sort.js' {
declare module.exports: $Exports<'source-map/lib/quick-sort'>;
}
declare module 'source-map/lib/source-map-consumer.js' {
declare module.exports: $Exports<'source-map/lib/source-map-consumer'>;
}
declare module 'source-map/lib/source-map-generator.js' {
declare module.exports: $Exports<'source-map/lib/source-map-generator'>;
}
declare module 'source-map/lib/source-node.js' {
declare module.exports: $Exports<'source-map/lib/source-node'>;
}
declare module 'source-map/lib/util.js' {
declare module.exports: $Exports<'source-map/lib/util'>;
}
declare module 'source-map/source-map.js' {
declare module.exports: $Exports<'source-map/source-map'>;
}