2017-08-21 22:29:58 +00:00
|
|
|
// Type definitions for convert-source-map 1.5
|
2016-02-15 16:20:30 +00:00
|
|
|
// Project: https://github.com/thlorenz/convert-source-map
|
2017-08-20 22:37:53 +00:00
|
|
|
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar>, Melvin Groenhoff <https://github.com/mgroenhoff>, TeamworkGuy2 <https://github.com/TeamworkGuy2>
|
2016-03-16 15:31:58 +00:00
|
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
2016-02-15 16:20:30 +00:00
|
|
|
|
2017-10-22 22:22:50 +00:00
|
|
|
/**
|
|
|
|
|
* Converts a source-map from/to different formats and allows adding/changing properties.
|
2016-12-29 21:44:30 +00:00
|
|
|
* (documentation based on project's README file)
|
|
|
|
|
*/
|
2016-12-30 00:10:54 +00:00
|
|
|
export interface SourceMapConverter {
|
|
|
|
|
/** The parsed sourcemap object */
|
|
|
|
|
sourcemap: any;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns a copy of the underlying source map */
|
|
|
|
|
toObject(): any;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Converts source map to json string. If space is given (optional), this will be passed to JSON.stringify when the JSON string is generated */
|
|
|
|
|
toJSON(space?: string | number): string;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Converts source map to base64 encoded json string */
|
|
|
|
|
toBase64(): string;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-10-22 22:22:50 +00:00
|
|
|
/**
|
|
|
|
|
* Converts source map to an inline comment that can be appended to the source-file.
|
2016-12-30 00:10:54 +00:00
|
|
|
* By default, the comment is formatted like: //# sourceMappingURL=..., which you would normally see in a JS source file.
|
|
|
|
|
* When options.multiline == true, the comment is formatted like: /*# sourceMappingURL=... *\/, which you would find in a CSS source file
|
|
|
|
|
*/
|
|
|
|
|
toComment(options?: { multiline?: boolean }): string;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Adds given property to the source map. Throws an error if property already exists */
|
|
|
|
|
addProperty(key: string, value: any): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Sets given property to the source map. If property doesn't exist it is added, otherwise its value is updated */
|
|
|
|
|
setProperty(key: string, value: any): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Gets given property of the source map */
|
|
|
|
|
getProperty(key: string): any;
|
|
|
|
|
}
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns source map converter from given object */
|
|
|
|
|
export function fromObject(obj: any): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns source map converter from given json string */
|
|
|
|
|
export function fromJSON(json: string): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns source map converter from given base64 encoded json string */
|
|
|
|
|
export function fromBase64(base64: string): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns source map converter from given base64 encoded json string prefixed with //# sourceMappingURL=... */
|
|
|
|
|
export function fromComment(comment: string): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-10-22 22:22:50 +00:00
|
|
|
/**
|
|
|
|
|
* Returns source map converter from given filename by parsing //# sourceMappingURL=filename.
|
2016-12-30 00:10:54 +00:00
|
|
|
* filename must point to a file that is found inside the mapFileDir. Most tools store this file right next to the generated file, i.e. the one containing the source map.
|
|
|
|
|
*/
|
|
|
|
|
export function fromMapFileComment(comment: string, commentFileDir: string): SourceMapConverter;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-10-22 22:22:50 +00:00
|
|
|
/**
|
|
|
|
|
* Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found.
|
2016-12-30 00:10:54 +00:00
|
|
|
*/
|
2017-08-21 22:29:58 +00:00
|
|
|
export function fromSource(content: string): SourceMapConverter | null;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-10-22 22:22:50 +00:00
|
|
|
/**
|
|
|
|
|
* Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found.
|
2016-12-30 00:10:54 +00:00
|
|
|
* The sourcemap will be read from the map file found by parsing # sourceMappingURL=file comment. For more info see fromMapFileComment.
|
|
|
|
|
*/
|
|
|
|
|
export function fromMapFileSource(content: string, commentFileDir: string): SourceMapConverter | null;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns src with all source map comments removed */
|
|
|
|
|
export function removeComments(src: string): string;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2016-12-30 00:10:54 +00:00
|
|
|
/** Returns src with all source map comments pointing to map files removed */
|
|
|
|
|
export function removeMapFileComments(src: string): string;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-08-21 22:29:58 +00:00
|
|
|
/** Returns a new regex used to find source map comments */
|
2017-03-31 18:01:26 +00:00
|
|
|
export const commentRegex: RegExp;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-08-21 22:29:58 +00:00
|
|
|
/** Returns a new regex used to find source map comments pointing to map files */
|
2017-03-31 18:01:26 +00:00
|
|
|
export const mapFileCommentRegex: RegExp;
|
2016-12-29 21:44:30 +00:00
|
|
|
|
2017-10-22 22:22:50 +00:00
|
|
|
/**
|
|
|
|
|
* Returns a comment that links to an external source map via file.
|
2016-12-30 00:10:54 +00:00
|
|
|
* By default, the comment is formatted like: //# sourceMappingURL=..., which you would normally see in a JS source file.
|
|
|
|
|
* When options.multiline == true, the comment is formatted like: /*# sourceMappingURL=... *\/, which you would find in a CSS source file.
|
|
|
|
|
*/
|
2017-03-31 18:01:26 +00:00
|
|
|
export function generateMapFileComment(file: string, options?: { multiline?: boolean }): string;
|