diff --git a/types/combine-source-map/combine-source-map-tests.ts b/types/combine-source-map/combine-source-map-tests.ts new file mode 100644 index 0000000000..70f426d7ce --- /dev/null +++ b/types/combine-source-map/combine-source-map-tests.ts @@ -0,0 +1,12 @@ +import combine = require("combine-source-map"); + +const sourcemap = combine.create(); + +sourcemap.addFile({ sourceFile: "file.js", source: "return 123" }) + .addFile({ sourceFile: "source.js", source: "return 'abc'" }); + +const res: string = sourcemap.base64(); + +const res2 = sourcemap.comment(); + +combine.removeComments("(123 | 'abc') // #sourceMappingURL=file.js.map"); diff --git a/types/combine-source-map/index.d.ts b/types/combine-source-map/index.d.ts new file mode 100644 index 0000000000..43f1c994b0 --- /dev/null +++ b/types/combine-source-map/index.d.ts @@ -0,0 +1,59 @@ +// Type definitions for combine-source-map 0.8 +// Project: https://github.com/thlorenz/combine-source-map +// Definitions by: TeamworkGuy2 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** Add source maps of multiple files, offset them and then combine them into one source map. + * (documentation based on project's README file) + */ +declare class Combiner { + constructor(file?: string, sourceRoot?: string); + + /** Adds map to underlying source map. + * If source contains a source map comment that has the source of the original file inlined it will offset these + * mappings and include them. + * If no source map comment is found or it has no source inlined, mappings for the file will be generated and included + * @param opts the 'sourceFile' path/name and the file's 'source' contents + * @param offset the source file 'line' number and 'column' number offsets + */ + addFile(opts: { sourceFile: string; source: string }, offset?: Combiner.Offset): Combiner; + + /** output the combined source map in base64 format + * @return base64 encoded combined source map + */ + base64(): string; + + /** generate a base64 encoded sourceMappingURL comment + * @return base64 encoded sourceMappingUrl comment of the combined source map + */ + comment(): string; + + _addGeneratedMap(sourceFile: string, source: string, offset?: Combiner.Offset): Combiner; + + _addExistingMap(sourceFile: string, source: string, existingMap: any, offset?: Combiner.Offset): Combiner; +} + +declare namespace Combiner { + /** An offset line and column number */ + interface Offset { + line?: number; + column?: number; + } + + /** Create a source map combiner that accepts multiple files, offsets them and then combines them into one source map. + * @param file optional name of the generated file + * @param sourceRoot optional sourceRoot of the map to be generated + * @return Combiner instance to which source maps can be added and later combined + */ + function create(file?: string, sourceRoot?: string): Combiner; + + /** removeComments + * @param src + * @return src with all sourceMappingUrl comments removed + */ + function removeComments(src: string): string; +} + +export = Combiner; + +export as namespace Combiner; diff --git a/types/combine-source-map/tsconfig.json b/types/combine-source-map/tsconfig.json new file mode 100644 index 0000000000..8ee6b85743 --- /dev/null +++ b/types/combine-source-map/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "combine-source-map-tests.ts" + ] +} \ No newline at end of file diff --git a/types/combine-source-map/tslint.json b/types/combine-source-map/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/combine-source-map/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }