aboutsummaryrefslogtreecommitdiff
path: root/node_modules/istanbul-lib-source-maps
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/istanbul-lib-source-maps')
-rw-r--r--node_modules/istanbul-lib-source-maps/CHANGELOG.md295
-rw-r--r--node_modules/istanbul-lib-source-maps/LICENSE24
-rw-r--r--node_modules/istanbul-lib-source-maps/README.md11
-rw-r--r--node_modules/istanbul-lib-source-maps/index.js15
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/get-mapping.js182
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/map-store.js226
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/mapped.js113
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/pathutils.js21
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/transform-utils.js21
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/transformer.js147
-rw-r--r--node_modules/istanbul-lib-source-maps/package.json45
11 files changed, 1100 insertions, 0 deletions
diff --git a/node_modules/istanbul-lib-source-maps/CHANGELOG.md b/node_modules/istanbul-lib-source-maps/CHANGELOG.md
new file mode 100644
index 0000000..a1c55c2
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/CHANGELOG.md
@@ -0,0 +1,295 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+
+# [4.0.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.5...istanbul-lib-source-maps@4.0.0) (2019-12-20)
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+
+
+
+
+# [4.0.0-alpha.5](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.4...istanbul-lib-source-maps@4.0.0-alpha.5) (2019-12-07)
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+
+
+
+
+# [4.0.0-alpha.4](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.3...istanbul-lib-source-maps@4.0.0-alpha.4) (2019-11-16)
+
+
+### Bug Fixes
+
+* sourceFinder cannot be async. ([#501](https://github.com/istanbuljs/istanbuljs/issues/501)) ([094f1b8](https://github.com/istanbuljs/istanbuljs/commit/094f1b83b4652c5ba492781620cb6358c685a849))
+
+
+
+
+
+# [4.0.0-alpha.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.2...istanbul-lib-source-maps@4.0.0-alpha.3) (2019-11-15)
+
+
+### Bug Fixes
+
+* mappedCoverage.addStatement is not a function ([#500](https://github.com/istanbuljs/istanbuljs/issues/500)) ([d77cc14](https://github.com/istanbuljs/istanbuljs/commit/d77cc147f7d791686af2975f7d906603335d0bfc)), closes [istanbuljs/nyc#940](https://github.com/istanbuljs/nyc/issues/940)
+
+
+
+
+
+# [4.0.0-alpha.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.1...istanbul-lib-source-maps@4.0.0-alpha.2) (2019-10-09)
+
+
+### Features
+
+* Convert to async API ([#489](https://github.com/istanbuljs/istanbuljs/issues/489)) ([f8ebbc9](https://github.com/istanbuljs/istanbuljs/commit/f8ebbc9))
+
+
+### BREAKING CHANGES
+
+* MapStore#transformCoverage is now async and returns a
+the coverage data only. The `sourceFinder` method is now async and
+provided directly on the `MapStore` instance.
+
+
+
+
+
+# [4.0.0-alpha.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.0...istanbul-lib-source-maps@4.0.0-alpha.1) (2019-10-06)
+
+
+### Bug Fixes
+
+* **package:** update rimraf to version 3.0.0 ([b6e7953](https://github.com/istanbuljs/istanbuljs/commit/b6e7953))
+
+
+### Features
+
+* Accept SourceStore and sourceStoreOpts options ([#482](https://github.com/istanbuljs/istanbuljs/issues/482)) ([0dc45a6](https://github.com/istanbuljs/istanbuljs/commit/0dc45a6))
+* Add addInputSourceMapsSync and getSourceMapSync methods ([#484](https://github.com/istanbuljs/istanbuljs/issues/484)) ([dd7048e](https://github.com/istanbuljs/istanbuljs/commit/dd7048e))
+
+
+### BREAKING CHANGES
+
+* sourceStore and tmpdir options are removed.
+
+
+
+
+
+# [4.0.0-alpha.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.6...istanbul-lib-source-maps@4.0.0-alpha.0) (2019-06-19)
+
+
+### Features
+
+* Update dependencies, require Node.js 8 ([#401](https://github.com/istanbuljs/istanbuljs/issues/401)) ([bf3a539](https://github.com/istanbuljs/istanbuljs/commit/bf3a539))
+
+
+### BREAKING CHANGES
+
+* Node.js 8 is now required
+
+
+
+
+
+### [4.0.1](https://www.github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps-v4.0.0...istanbul-lib-source-maps-v4.0.1) (2021-10-12)
+
+
+### Bug Fixes
+
+* source mapping for branch statements ([#518](https://www.github.com/istanbuljs/istanbuljs/issues/518)) ([3833708](https://www.github.com/istanbuljs/istanbuljs/commit/38337081d97baa6295707d569dee9c4abc3f7da7))
+
+## [3.0.6](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.5...istanbul-lib-source-maps@3.0.6) (2019-04-24)
+
+
+### Bug Fixes
+
+* if LEAST_UPPER_BOUND returns null, try GREATEST_LOWER_BOUND ([#375](https://github.com/istanbuljs/istanbuljs/issues/375)) ([72b0f05](https://github.com/istanbuljs/istanbuljs/commit/72b0f05))
+
+
+
+
+
+## [3.0.5](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.4...istanbul-lib-source-maps@3.0.5) (2019-04-09)
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+
+
+
+
+## [3.0.4](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.3...istanbul-lib-source-maps@3.0.4) (2019-04-03)
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+
+
+
+
+## [3.0.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.2...istanbul-lib-source-maps@3.0.3) (2019-03-12)
+
+
+### Bug Fixes
+
+* Map unique files once, regardless of path separator ([#287](https://github.com/istanbuljs/istanbuljs/issues/287)) ([39a1e56](https://github.com/istanbuljs/istanbuljs/commit/39a1e56))
+
+
+
+
+
+## [3.0.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.1...istanbul-lib-source-maps@3.0.2) (2019-01-26)
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+
+
+
+
+<a name="3.0.1"></a>
+## [3.0.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.0...istanbul-lib-source-maps@3.0.1) (2018-12-25)
+
+
+### Bug Fixes
+
+* correct variable name in source-map transform ([#257](https://github.com/istanbuljs/istanbuljs/issues/257)) ([de9c921](https://github.com/istanbuljs/istanbuljs/commit/de9c921))
+
+
+
+
+<a name="3.0.0"></a>
+# [3.0.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@2.0.1...istanbul-lib-source-maps@3.0.0) (2018-12-19)
+
+
+### Bug Fixes
+
+* correctly calculate end position of sourcemap statement ([f97ffc7](https://github.com/istanbuljs/istanbuljs/commit/f97ffc7))
+
+
+### BREAKING CHANGES
+
+* coverage output can now contain Infinity, when a range extends past the source in a file.
+
+
+
+
+<a name="2.0.1"></a>
+## [2.0.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@2.0.0...istanbul-lib-source-maps@2.0.1) (2018-07-07)
+
+
+
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+<a name="2.0.0"></a>
+# [2.0.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.5...istanbul-lib-source-maps@2.0.0) (2018-06-06)
+
+
+### Bug Fixes
+
+* use null prototype for map objects ([#177](https://github.com/istanbuljs/istanbuljs/issues/177)) ([9a5a30c](https://github.com/istanbuljs/istanbuljs/commit/9a5a30c))
+
+
+### BREAKING CHANGES
+
+* a null prototype is now used in several places rather than the default `{}` assignment.
+
+
+
+
+<a name="1.2.5"></a>
+## [1.2.5](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.4...istanbul-lib-source-maps@1.2.5) (2018-05-31)
+
+
+### Bug Fixes
+
+* process.cwd is a function not a string ([#163](https://github.com/istanbuljs/istanbuljs/issues/163)). ([#171](https://github.com/istanbuljs/istanbuljs/issues/171)) ([9c7802c](https://github.com/istanbuljs/istanbuljs/commit/9c7802c))
+
+
+
+
+<a name="1.2.4"></a>
+## [1.2.4](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.3...istanbul-lib-source-maps@1.2.4) (2018-03-04)
+
+
+
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+<a name="1.2.3"></a>
+## [1.2.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.2...istanbul-lib-source-maps@1.2.3) (2018-02-13)
+
+
+
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+<a name="1.2.2"></a>
+## [1.2.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.1...istanbul-lib-source-maps@1.2.2) (2017-10-21)
+
+
+
+
+**Note:** Version bump only for package istanbul-lib-source-maps
+
+<a name="1.2.1"></a>
+## [1.2.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.0...istanbul-lib-source-maps@1.2.1) (2017-05-27)
+
+
+
+
+<a name="1.2.0"></a>
+# [1.2.0](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/istanbul-lib-source-maps@1.1.1...istanbul-lib-source-maps@1.2.0) (2017-04-29)
+
+
+### Features
+
+* pull in debug module, to make debug messages optional ([#36](https://github.com/istanbuljs/istanbuljs/issues/36)) ([189519d](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/189519d))
+
+
+
+
+<a name="1.1.1"></a>
+## [1.1.1](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/istanbul-lib-source-maps@1.1.0...istanbul-lib-source-maps@1.1.1) (2017-03-27)
+
+<a name="1.1.0"></a>
+# [1.1.0](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.2...v1.1.0) (2016-11-10)
+
+
+### Features
+
+* read and apply any input source maps stored with coverage data ([#4](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/4)) ([aea405b](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/aea405b))
+
+
+
+<a name="1.0.2"></a>
+## [1.0.2](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.1...v1.0.2) (2016-10-03)
+
+
+### Bug Fixes
+
+* broken mapped coverage report ([#6](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/6)) ([d9dd738](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/d9dd738))
+
+
+
+<a name="1.0.1"></a>
+## [1.0.1](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.0...v1.0.1) (2016-09-13)
+
+
+### Bug Fixes
+
+* position validation shouldn't throw away locations with 0 ([#5](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/5)) ([ac4b72c](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/ac4b72c))
+
+
+
+<a name="1.0.0"></a>
+# [1.0.0](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.0-alpha.9...v1.0.0) (2016-08-31)
+
+
+### Bug Fixes
+
+* discard more bad source map positions ([#3](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/3)) ([ed7b27f](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/ed7b27f))
diff --git a/node_modules/istanbul-lib-source-maps/LICENSE b/node_modules/istanbul-lib-source-maps/LICENSE
new file mode 100644
index 0000000..c05aaaf
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/LICENSE
@@ -0,0 +1,24 @@
+Copyright 2015 Yahoo! Inc.
+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 the Yahoo! 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 YAHOO! INC. 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.
diff --git a/node_modules/istanbul-lib-source-maps/README.md b/node_modules/istanbul-lib-source-maps/README.md
new file mode 100644
index 0000000..f9a75f8
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/README.md
@@ -0,0 +1,11 @@
+# istanbul-lib-source-maps
+
+[![Build Status](https://travis-ci.org/istanbuljs/istanbuljs.svg?branch=master)](https://travis-ci.org/istanbuljs/istanbuljs)
+
+Source map support for istanbuljs.
+
+## Debugging
+
+_istanbul-lib-source-maps_ uses the [debug](https://www.npmjs.com/package/debug) module.
+Run your application with the environment variable `DEBUG=istanbuljs`, to receive debug
+output.
diff --git a/node_modules/istanbul-lib-source-maps/index.js b/node_modules/istanbul-lib-source-maps/index.js
new file mode 100644
index 0000000..1bcb74c
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/index.js
@@ -0,0 +1,15 @@
+/*
+ Copyright 2012-2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+const { MapStore } = require('./lib/map-store');
+/**
+ * @module Exports
+ */
+module.exports = {
+ createSourceMapStore(opts) {
+ return new MapStore(opts);
+ }
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/get-mapping.js b/node_modules/istanbul-lib-source-maps/lib/get-mapping.js
new file mode 100644
index 0000000..c24f618
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/get-mapping.js
@@ -0,0 +1,182 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+const pathutils = require('./pathutils');
+const {
+ GREATEST_LOWER_BOUND,
+ LEAST_UPPER_BOUND
+} = require('source-map').SourceMapConsumer;
+
+/**
+ * AST ranges are inclusive for start positions and exclusive for end positions.
+ * Source maps are also logically ranges over text, though interacting with
+ * them is generally achieved by working with explicit positions.
+ *
+ * When finding the _end_ location of an AST item, the range behavior is
+ * important because what we're asking for is the _end_ of whatever range
+ * corresponds to the end location we seek.
+ *
+ * This boils down to the following steps, conceptually, though the source-map
+ * library doesn't expose primitives to do this nicely:
+ *
+ * 1. Find the range on the generated file that ends at, or exclusively
+ * contains the end position of the AST node.
+ * 2. Find the range on the original file that corresponds to
+ * that generated range.
+ * 3. Find the _end_ location of that original range.
+ */
+function originalEndPositionFor(sourceMap, generatedEnd) {
+ // Given the generated location, find the original location of the mapping
+ // that corresponds to a range on the generated file that overlaps the
+ // generated file end location. Note however that this position on its
+ // own is not useful because it is the position of the _start_ of the range
+ // on the original file, and we want the _end_ of the range.
+ const beforeEndMapping = originalPositionTryBoth(
+ sourceMap,
+ generatedEnd.line,
+ generatedEnd.column - 1
+ );
+ if (beforeEndMapping.source === null) {
+ return null;
+ }
+
+ // Convert that original position back to a generated one, with a bump
+ // to the right, and a rightward bias. Since 'generatedPositionFor' searches
+ // for mappings in the original-order sorted list, this will find the
+ // mapping that corresponds to the one immediately after the
+ // beforeEndMapping mapping.
+ const afterEndMapping = sourceMap.generatedPositionFor({
+ source: beforeEndMapping.source,
+ line: beforeEndMapping.line,
+ column: beforeEndMapping.column + 1,
+ bias: LEAST_UPPER_BOUND
+ });
+ if (
+ // If this is null, it means that we've hit the end of the file,
+ // so we can use Infinity as the end column.
+ afterEndMapping.line === null ||
+ // If these don't match, it means that the call to
+ // 'generatedPositionFor' didn't find any other original mappings on
+ // the line we gave, so consider the binding to extend to infinity.
+ sourceMap.originalPositionFor(afterEndMapping).line !==
+ beforeEndMapping.line
+ ) {
+ return {
+ source: beforeEndMapping.source,
+ line: beforeEndMapping.line,
+ column: Infinity
+ };
+ }
+
+ // Convert the end mapping into the real original position.
+ return sourceMap.originalPositionFor(afterEndMapping);
+}
+
+/**
+ * Attempts to determine the original source position, first
+ * returning the closest element to the left (GREATEST_LOWER_BOUND),
+ * and next returning the closest element to the right (LEAST_UPPER_BOUND).
+ */
+function originalPositionTryBoth(sourceMap, line, column) {
+ const mapping = sourceMap.originalPositionFor({
+ line,
+ column,
+ bias: GREATEST_LOWER_BOUND
+ });
+ if (mapping.source === null) {
+ return sourceMap.originalPositionFor({
+ line,
+ column,
+ bias: LEAST_UPPER_BOUND
+ });
+ } else {
+ return mapping;
+ }
+}
+
+function isInvalidPosition(pos) {
+ return (
+ !pos ||
+ typeof pos.line !== 'number' ||
+ typeof pos.column !== 'number' ||
+ pos.line < 0 ||
+ pos.column < 0
+ );
+}
+
+/**
+ * determines the original position for a given location
+ * @param {SourceMapConsumer} sourceMap the source map
+ * @param {Object} generatedLocation the original location Object
+ * @returns {Object} the remapped location Object
+ */
+function getMapping(sourceMap, generatedLocation, origFile) {
+ if (!generatedLocation) {
+ return null;
+ }
+
+ if (
+ isInvalidPosition(generatedLocation.start) ||
+ isInvalidPosition(generatedLocation.end)
+ ) {
+ return null;
+ }
+
+ const start = originalPositionTryBoth(
+ sourceMap,
+ generatedLocation.start.line,
+ generatedLocation.start.column
+ );
+ let end = originalEndPositionFor(sourceMap, generatedLocation.end);
+
+ /* istanbul ignore if: edge case too hard to test for */
+ if (!(start && end)) {
+ return null;
+ }
+
+ if (!(start.source && end.source)) {
+ return null;
+ }
+
+ if (start.source !== end.source) {
+ return null;
+ }
+
+ /* istanbul ignore if: edge case too hard to test for */
+ if (start.line === null || start.column === null) {
+ return null;
+ }
+
+ /* istanbul ignore if: edge case too hard to test for */
+ if (end.line === null || end.column === null) {
+ return null;
+ }
+
+ if (start.line === end.line && start.column === end.column) {
+ end = sourceMap.originalPositionFor({
+ line: generatedLocation.end.line,
+ column: generatedLocation.end.column,
+ bias: LEAST_UPPER_BOUND
+ });
+ end.column -= 1;
+ }
+
+ return {
+ source: pathutils.relativeTo(start.source, origFile),
+ loc: {
+ start: {
+ line: start.line,
+ column: start.column
+ },
+ end: {
+ line: end.line,
+ column: end.column
+ }
+ }
+ };
+}
+
+module.exports = getMapping;
diff --git a/node_modules/istanbul-lib-source-maps/lib/map-store.js b/node_modules/istanbul-lib-source-maps/lib/map-store.js
new file mode 100644
index 0000000..a99b79a
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/map-store.js
@@ -0,0 +1,226 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+const path = require('path');
+const fs = require('fs');
+const debug = require('debug')('istanbuljs');
+const { SourceMapConsumer } = require('source-map');
+const pathutils = require('./pathutils');
+const { SourceMapTransformer } = require('./transformer');
+
+/**
+ * Tracks source maps for registered files
+ */
+class MapStore {
+ /**
+ * @param {Object} opts [opts=undefined] options.
+ * @param {Boolean} opts.verbose [opts.verbose=false] verbose mode
+ * @param {String} opts.baseDir [opts.baseDir=null] alternate base directory
+ * to resolve sourcemap files
+ * @param {Class} opts.SourceStore [opts.SourceStore=Map] class to use for
+ * SourceStore. Must support `get`, `set` and `clear` methods.
+ * @param {Array} opts.sourceStoreOpts [opts.sourceStoreOpts=[]] arguments
+ * to use in the SourceStore constructor.
+ * @constructor
+ */
+ constructor(opts) {
+ opts = {
+ baseDir: null,
+ verbose: false,
+ SourceStore: Map,
+ sourceStoreOpts: [],
+ ...opts
+ };
+ this.baseDir = opts.baseDir;
+ this.verbose = opts.verbose;
+ this.sourceStore = new opts.SourceStore(...opts.sourceStoreOpts);
+ this.data = Object.create(null);
+ this.sourceFinder = this.sourceFinder.bind(this);
+ }
+
+ /**
+ * Registers a source map URL with this store. It makes some input sanity checks
+ * and silently fails on malformed input.
+ * @param transformedFilePath - the file path for which the source map is valid.
+ * This must *exactly* match the path stashed for the coverage object to be
+ * useful.
+ * @param sourceMapUrl - the source map URL, **not** a comment
+ */
+ registerURL(transformedFilePath, sourceMapUrl) {
+ const d = 'data:';
+
+ if (
+ sourceMapUrl.length > d.length &&
+ sourceMapUrl.substring(0, d.length) === d
+ ) {
+ const b64 = 'base64,';
+ const pos = sourceMapUrl.indexOf(b64);
+ if (pos > 0) {
+ this.data[transformedFilePath] = {
+ type: 'encoded',
+ data: sourceMapUrl.substring(pos + b64.length)
+ };
+ } else {
+ debug(`Unable to interpret source map URL: ${sourceMapUrl}`);
+ }
+
+ return;
+ }
+
+ const dir = path.dirname(path.resolve(transformedFilePath));
+ const file = path.resolve(dir, sourceMapUrl);
+ this.data[transformedFilePath] = { type: 'file', data: file };
+ }
+
+ /**
+ * Registers a source map object with this store. Makes some basic sanity checks
+ * and silently fails on malformed input.
+ * @param transformedFilePath - the file path for which the source map is valid
+ * @param sourceMap - the source map object
+ */
+ registerMap(transformedFilePath, sourceMap) {
+ if (sourceMap && sourceMap.version) {
+ this.data[transformedFilePath] = {
+ type: 'object',
+ data: sourceMap
+ };
+ } else {
+ debug(
+ 'Invalid source map object: ' +
+ JSON.stringify(sourceMap, null, 2)
+ );
+ }
+ }
+
+ /**
+ * Retrieve a source map object from this store.
+ * @param filePath - the file path for which the source map is valid
+ * @returns {Object} a parsed source map object
+ */
+ getSourceMapSync(filePath) {
+ try {
+ if (!this.data[filePath]) {
+ return;
+ }
+
+ const d = this.data[filePath];
+ if (d.type === 'file') {
+ return JSON.parse(fs.readFileSync(d.data, 'utf8'));
+ }
+
+ if (d.type === 'encoded') {
+ return JSON.parse(Buffer.from(d.data, 'base64').toString());
+ }
+
+ /* The caller might delete properties */
+ return {
+ ...d.data
+ };
+ } catch (error) {
+ debug('Error returning source map for ' + filePath);
+ debug(error.stack);
+
+ return;
+ }
+ }
+
+ /**
+ * Add inputSourceMap property to coverage data
+ * @param coverageData - the __coverage__ object
+ * @returns {Object} a parsed source map object
+ */
+ addInputSourceMapsSync(coverageData) {
+ Object.entries(coverageData).forEach(([filePath, data]) => {
+ if (data.inputSourceMap) {
+ return;
+ }
+
+ const sourceMap = this.getSourceMapSync(filePath);
+ if (sourceMap) {
+ data.inputSourceMap = sourceMap;
+ /* This huge property is not needed. */
+ delete data.inputSourceMap.sourcesContent;
+ }
+ });
+ }
+
+ sourceFinder(filePath) {
+ const content = this.sourceStore.get(filePath);
+ if (content !== undefined) {
+ return content;
+ }
+
+ if (path.isAbsolute(filePath)) {
+ return fs.readFileSync(filePath, 'utf8');
+ }
+
+ return fs.readFileSync(
+ pathutils.asAbsolute(filePath, this.baseDir),
+ 'utf8'
+ );
+ }
+
+ /**
+ * Transforms the coverage map provided into one that refers to original
+ * sources when valid mappings have been registered with this store.
+ * @param {CoverageMap} coverageMap - the coverage map to transform
+ * @returns {Promise<CoverageMap>} the transformed coverage map
+ */
+ async transformCoverage(coverageMap) {
+ const hasInputSourceMaps = coverageMap
+ .files()
+ .some(
+ file => coverageMap.fileCoverageFor(file).data.inputSourceMap
+ );
+
+ if (!hasInputSourceMaps && Object.keys(this.data).length === 0) {
+ return coverageMap;
+ }
+
+ const transformer = new SourceMapTransformer(
+ async (filePath, coverage) => {
+ try {
+ const obj =
+ coverage.data.inputSourceMap ||
+ this.getSourceMapSync(filePath);
+ if (!obj) {
+ return null;
+ }
+
+ const smc = new SourceMapConsumer(obj);
+ smc.sources.forEach(s => {
+ const content = smc.sourceContentFor(s);
+ if (content) {
+ const sourceFilePath = pathutils.relativeTo(
+ s,
+ filePath
+ );
+ this.sourceStore.set(sourceFilePath, content);
+ }
+ });
+
+ return smc;
+ } catch (error) {
+ debug('Error returning source map for ' + filePath);
+ debug(error.stack);
+
+ return null;
+ }
+ }
+ );
+
+ return await transformer.transform(coverageMap);
+ }
+
+ /**
+ * Disposes temporary resources allocated by this map store
+ */
+ dispose() {
+ this.sourceStore.clear();
+ }
+}
+
+module.exports = { MapStore };
diff --git a/node_modules/istanbul-lib-source-maps/lib/mapped.js b/node_modules/istanbul-lib-source-maps/lib/mapped.js
new file mode 100644
index 0000000..73f256c
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/mapped.js
@@ -0,0 +1,113 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+const { FileCoverage } = require('istanbul-lib-coverage').classes;
+
+function locString(loc) {
+ return [
+ loc.start.line,
+ loc.start.column,
+ loc.end.line,
+ loc.end.column
+ ].join(':');
+}
+
+class MappedCoverage extends FileCoverage {
+ constructor(pathOrObj) {
+ super(pathOrObj);
+
+ this.meta = {
+ last: {
+ s: 0,
+ f: 0,
+ b: 0
+ },
+ seen: {}
+ };
+ }
+
+ addStatement(loc, hits) {
+ const key = 's:' + locString(loc);
+ const { meta } = this;
+ let index = meta.seen[key];
+
+ if (index === undefined) {
+ index = meta.last.s;
+ meta.last.s += 1;
+ meta.seen[key] = index;
+ this.statementMap[index] = this.cloneLocation(loc);
+ }
+
+ this.s[index] = this.s[index] || 0;
+ this.s[index] += hits;
+ return index;
+ }
+
+ addFunction(name, decl, loc, hits) {
+ const key = 'f:' + locString(decl);
+ const { meta } = this;
+ let index = meta.seen[key];
+
+ if (index === undefined) {
+ index = meta.last.f;
+ meta.last.f += 1;
+ meta.seen[key] = index;
+ name = name || `(unknown_${index})`;
+ this.fnMap[index] = {
+ name,
+ decl: this.cloneLocation(decl),
+ loc: this.cloneLocation(loc)
+ };
+ }
+
+ this.f[index] = this.f[index] || 0;
+ this.f[index] += hits;
+ return index;
+ }
+
+ addBranch(type, loc, branchLocations, hits) {
+ const key = ['b', ...branchLocations.map(l => locString(l))].join(':');
+ const { meta } = this;
+ let index = meta.seen[key];
+ if (index === undefined) {
+ index = meta.last.b;
+ meta.last.b += 1;
+ meta.seen[key] = index;
+ this.branchMap[index] = {
+ loc,
+ type,
+ locations: branchLocations.map(l => this.cloneLocation(l))
+ };
+ }
+
+ if (!this.b[index]) {
+ this.b[index] = branchLocations.map(() => 0);
+ }
+
+ hits.forEach((hit, i) => {
+ this.b[index][i] += hit;
+ });
+ return index;
+ }
+
+ /* Returns a clone of the location object with only the attributes of interest */
+ cloneLocation(loc) {
+ return {
+ start: {
+ line: loc.start.line,
+ column: loc.start.column
+ },
+ end: {
+ line: loc.end.line,
+ column: loc.end.column
+ }
+ };
+ }
+}
+
+module.exports = {
+ MappedCoverage
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/pathutils.js b/node_modules/istanbul-lib-source-maps/lib/pathutils.js
new file mode 100644
index 0000000..7dca05a
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/pathutils.js
@@ -0,0 +1,21 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+const path = require('path');
+
+module.exports = {
+ isAbsolute: path.isAbsolute,
+ asAbsolute(file, baseDir) {
+ return path.isAbsolute(file)
+ ? file
+ : path.resolve(baseDir || process.cwd(), file);
+ },
+ relativeTo(file, origFile) {
+ return path.isAbsolute(file)
+ ? file
+ : path.resolve(path.dirname(origFile), file);
+ }
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/transform-utils.js b/node_modules/istanbul-lib-source-maps/lib/transform-utils.js
new file mode 100644
index 0000000..0933093
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/transform-utils.js
@@ -0,0 +1,21 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+function getUniqueKey(pathname) {
+ return pathname.replace(/[\\/]/g, '_');
+}
+
+function getOutput(cache) {
+ return Object.values(cache).reduce(
+ (output, { file, mappedCoverage }) => ({
+ ...output,
+ [file]: mappedCoverage
+ }),
+ {}
+ );
+}
+
+module.exports = { getUniqueKey, getOutput };
diff --git a/node_modules/istanbul-lib-source-maps/lib/transformer.js b/node_modules/istanbul-lib-source-maps/lib/transformer.js
new file mode 100644
index 0000000..6f63538
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/transformer.js
@@ -0,0 +1,147 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+'use strict';
+
+const debug = require('debug')('istanbuljs');
+const libCoverage = require('istanbul-lib-coverage');
+const { MappedCoverage } = require('./mapped');
+const getMapping = require('./get-mapping');
+const { getUniqueKey, getOutput } = require('./transform-utils');
+
+class SourceMapTransformer {
+ constructor(finder, opts = {}) {
+ this.finder = finder;
+ this.baseDir = opts.baseDir || process.cwd();
+ this.resolveMapping = opts.getMapping || getMapping;
+ }
+
+ processFile(fc, sourceMap, coverageMapper) {
+ let changes = 0;
+
+ Object.entries(fc.statementMap).forEach(([s, loc]) => {
+ const hits = fc.s[s];
+ const mapping = this.resolveMapping(sourceMap, loc, fc.path);
+
+ if (mapping) {
+ changes += 1;
+ const mappedCoverage = coverageMapper(mapping.source);
+ mappedCoverage.addStatement(mapping.loc, hits);
+ }
+ });
+
+ Object.entries(fc.fnMap).forEach(([f, fnMeta]) => {
+ const hits = fc.f[f];
+ const mapping = this.resolveMapping(
+ sourceMap,
+ fnMeta.decl,
+ fc.path
+ );
+
+ const spanMapping = this.resolveMapping(
+ sourceMap,
+ fnMeta.loc,
+ fc.path
+ );
+
+ if (
+ mapping &&
+ spanMapping &&
+ mapping.source === spanMapping.source
+ ) {
+ changes += 1;
+ const mappedCoverage = coverageMapper(mapping.source);
+ mappedCoverage.addFunction(
+ fnMeta.name,
+ mapping.loc,
+ spanMapping.loc,
+ hits
+ );
+ }
+ });
+
+ Object.entries(fc.branchMap).forEach(([b, branchMeta]) => {
+ const hits = fc.b[b];
+ const locs = [];
+ const mappedHits = [];
+ let source;
+ let skip;
+
+ branchMeta.locations.forEach((loc, i) => {
+ const mapping = this.resolveMapping(sourceMap, loc, fc.path);
+ if (mapping) {
+ if (!source) {
+ source = mapping.source;
+ }
+
+ if (mapping.source !== source) {
+ skip = true;
+ }
+
+ locs.push(mapping.loc);
+ mappedHits.push(hits[i]);
+ }
+ });
+
+ const locMapping = branchMeta.loc
+ ? this.resolveMapping(sourceMap, branchMeta.loc, fc.path)
+ : null;
+
+ if (!skip && locs.length > 0) {
+ changes += 1;
+ const mappedCoverage = coverageMapper(source);
+ mappedCoverage.addBranch(
+ branchMeta.type,
+ locMapping ? locMapping.loc : locs[0],
+ locs,
+ mappedHits
+ );
+ }
+ });
+
+ return changes > 0;
+ }
+
+ async transform(coverageMap) {
+ const uniqueFiles = {};
+ const getMappedCoverage = file => {
+ const key = getUniqueKey(file);
+ if (!uniqueFiles[key]) {
+ uniqueFiles[key] = {
+ file,
+ mappedCoverage: new MappedCoverage(file)
+ };
+ }
+
+ return uniqueFiles[key].mappedCoverage;
+ };
+
+ for (const file of coverageMap.files()) {
+ const fc = coverageMap.fileCoverageFor(file);
+ const sourceMap = await this.finder(file, fc);
+
+ if (sourceMap) {
+ const changed = this.processFile(
+ fc,
+ sourceMap,
+ getMappedCoverage
+ );
+ if (!changed) {
+ debug(`File [${file}] ignored, nothing could be mapped`);
+ }
+ } else {
+ uniqueFiles[getUniqueKey(file)] = {
+ file,
+ mappedCoverage: new MappedCoverage(fc)
+ };
+ }
+ }
+
+ return libCoverage.createCoverageMap(getOutput(uniqueFiles));
+ }
+}
+
+module.exports = {
+ SourceMapTransformer
+};
diff --git a/node_modules/istanbul-lib-source-maps/package.json b/node_modules/istanbul-lib-source-maps/package.json
new file mode 100644
index 0000000..2798300
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "istanbul-lib-source-maps",
+ "version": "4.0.1",
+ "description": "Source maps support for istanbul",
+ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",
+ "main": "index.js",
+ "files": [
+ "lib",
+ "index.js"
+ ],
+ "scripts": {
+ "test": "nyc mocha"
+ },
+ "dependencies": {
+ "debug": "^4.1.1",
+ "istanbul-lib-coverage": "^3.0.0",
+ "source-map": "^0.6.1"
+ },
+ "devDependencies": {
+ "chai": "^4.2.0",
+ "mocha": "^6.2.2",
+ "nyc": "^15.0.0-beta.2",
+ "ts-node": "^8.5.4"
+ },
+ "license": "BSD-3-Clause",
+ "bugs": {
+ "url": "https://github.com/istanbuljs/istanbuljs/issues"
+ },
+ "homepage": "https://istanbul.js.org/",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/istanbuljs/istanbuljs.git",
+ "directory": "packages/istanbul-lib-source-maps"
+ },
+ "keywords": [
+ "istanbul",
+ "sourcemaps",
+ "sourcemap",
+ "source",
+ "maps"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+}