This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

22
node_modules/istanbul-lib-instrument/dist/constants.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MAGIC_VALUE = exports.MAGIC_KEY = exports.SHA = void 0;
var _crypto = require("crypto");
var _semver = require("semver");
var _package = require("../package.json");
// function to use for creating hashes
const SHA = 'sha1'; // name of coverage data magic key
exports.SHA = SHA;
const MAGIC_KEY = '_coverageSchema'; // name of coverage data magic value
exports.MAGIC_KEY = MAGIC_KEY;
const MAGIC_VALUE = (0, _crypto.createHash)(SHA).update(_package.name + '@' + (0, _semver.major)(_package.version)).digest('hex');
exports.MAGIC_VALUE = MAGIC_VALUE;

42
node_modules/istanbul-lib-instrument/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createInstrumenter = createInstrumenter;
Object.defineProperty(exports, "programVisitor", {
enumerable: true,
get: function () {
return _visitor.default;
}
});
Object.defineProperty(exports, "readInitialCoverage", {
enumerable: true,
get: function () {
return _readCoverage.default;
}
});
exports.defaultOpts = void 0;
var _schema = require("@istanbuljs/schema");
var _instrumenter = _interopRequireDefault(require("./instrumenter"));
var _visitor = _interopRequireDefault(require("./visitor"));
var _readCoverage = _interopRequireDefault(require("./read-coverage"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* createInstrumenter creates a new instrumenter with the
* supplied options.
* @param {Object} opts - instrumenter options. See the documentation
* for the Instrumenter class.
*/
function createInstrumenter(opts) {
return new _instrumenter.default(opts);
}
const defaultOpts = _schema.defaults.instrumenter;
exports.defaultOpts = defaultOpts;

View File

@@ -0,0 +1,182 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _core = require("@babel/core");
var _schema = require("@istanbuljs/schema");
var _visitor = _interopRequireDefault(require("./visitor"));
var _readCoverage = _interopRequireDefault(require("./read-coverage"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
/**
* Instrumenter is the public API for the instrument library.
* It is typically used for ES5 code. For ES6 code that you
* are already running under `babel` use the coverage plugin
* instead.
* @param {Object} opts optional.
* @param {string} [opts.coverageVariable=__coverage__] name of global coverage variable.
* @param {boolean} [opts.preserveComments=false] preserve comments in output
* @param {boolean} [opts.compact=true] generate compact code.
* @param {boolean} [opts.esModules=false] set to true to instrument ES6 modules.
* @param {boolean} [opts.autoWrap=false] set to true to allow `return` statements outside of functions.
* @param {boolean} [opts.produceSourceMap=false] set to true to produce a source map for the instrumented code.
* @param {Array} [opts.ignoreClassMethods=[]] set to array of class method names to ignore for coverage.
* @param {Function} [opts.sourceMapUrlCallback=null] a callback function that is called when a source map URL
* is found in the original code. This function is called with the source file name and the source map URL.
* @param {boolean} [opts.debug=false] - turn debugging on
* @param {array} [opts.parserPlugins] - set babel parser plugins, see @istanbuljs/schema for defaults.
*/
class Instrumenter {
constructor(opts = {}) {
this.opts = { ..._schema.defaults.instrumenter,
...opts
};
this.fileCoverage = null;
this.sourceMap = null;
}
/**
* instrument the supplied code and track coverage against the supplied
* filename. It throws if invalid code is passed to it. ES5 and ES6 syntax
* is supported. To instrument ES6 modules, make sure that you set the
* `esModules` property to `true` when creating the instrumenter.
*
* @param {string} code - the code to instrument
* @param {string} filename - the filename against which to track coverage.
* @param {object} [inputSourceMap] - the source map that maps the not instrumented code back to it's original form.
* Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the
* coverage to the untranspiled source.
* @returns {string} the instrumented code.
*/
instrumentSync(code, filename, inputSourceMap) {
if (typeof code !== 'string') {
throw new Error('Code must be a string');
}
filename = filename || String(new Date().getTime()) + '.js';
const {
opts
} = this;
let output = {};
const babelOpts = {
configFile: false,
babelrc: false,
ast: true,
filename: filename || String(new Date().getTime()) + '.js',
inputSourceMap,
sourceMaps: opts.produceSourceMap,
compact: opts.compact,
comments: opts.preserveComments,
parserOpts: {
allowReturnOutsideFunction: opts.autoWrap,
sourceType: opts.esModules ? 'module' : 'script',
plugins: opts.parserPlugins
},
plugins: [[({
types
}) => {
const ee = (0, _visitor.default)(types, filename, {
coverageVariable: opts.coverageVariable,
coverageGlobalScope: opts.coverageGlobalScope,
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc,
ignoreClassMethods: opts.ignoreClassMethods,
inputSourceMap
});
return {
visitor: {
Program: {
enter: ee.enter,
exit(path) {
output = ee.exit(path);
}
}
}
};
}]]
};
const codeMap = (0, _core.transformSync)(code, babelOpts);
if (!output || !output.fileCoverage) {
const initialCoverage = (0, _readCoverage.default)(codeMap.ast) ||
/* istanbul ignore next: paranoid check */
{};
this.fileCoverage = initialCoverage.coverageData;
this.sourceMap = inputSourceMap;
return code;
}
this.fileCoverage = output.fileCoverage;
this.sourceMap = codeMap.map;
const cb = this.opts.sourceMapUrlCallback;
if (cb && output.sourceMappingURL) {
cb(filename, output.sourceMappingURL);
}
return codeMap.code;
}
/**
* callback-style instrument method that calls back with an error
* as opposed to throwing one. Note that in the current implementation,
* the callback will be called in the same process tick and is not asynchronous.
*
* @param {string} code - the code to instrument
* @param {string} filename - the filename against which to track coverage.
* @param {Function} callback - the callback
* @param {Object} inputSourceMap - the source map that maps the not instrumented code back to it's original form.
* Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the
* coverage to the untranspiled source.
*/
instrument(code, filename, callback, inputSourceMap) {
if (!callback && typeof filename === 'function') {
callback = filename;
filename = null;
}
try {
const out = this.instrumentSync(code, filename, inputSourceMap);
callback(null, out);
} catch (ex) {
callback(ex);
}
}
/**
* returns the file coverage object for the last file instrumented.
* @returns {Object} the file coverage object.
*/
lastFileCoverage() {
return this.fileCoverage;
}
/**
* returns the source map produced for the last file instrumented.
* @returns {null|Object} the source map object.
*/
lastSourceMap() {
return this.sourceMap;
}
}
var _default = Instrumenter;
exports.default = _default;

View File

@@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = readInitialCoverage;
var _core = require("@babel/core");
var _schema = require("@istanbuljs/schema");
var _constants = require("./constants");
function getAst(code) {
if (typeof code === 'object' && typeof code.type === 'string') {
// Assume code is already a babel ast.
return code;
}
if (typeof code !== 'string') {
throw new Error('Code must be a string');
} // Parse as leniently as possible
return (0, _core.parseSync)(code, {
babelrc: false,
configFile: false,
parserOpts: {
allowImportExportEverywhere: true,
allowReturnOutsideFunction: true,
allowSuperOutsideMethod: true,
sourceType: 'script',
plugins: _schema.defaults.instrumenter.parserPlugins
}
});
}
function readInitialCoverage(code) {
const ast = getAst(code);
let covScope;
(0, _core.traverse)(ast, {
ObjectProperty(path) {
const {
node
} = path;
if (!node.computed && path.get('key').isIdentifier() && node.key.name === _constants.MAGIC_KEY) {
const magicValue = path.get('value').evaluate();
if (!magicValue.confident || magicValue.value !== _constants.MAGIC_VALUE) {
return;
}
covScope = path.scope.getFunctionParent() || path.scope.getProgramParent();
path.stop();
}
}
});
if (!covScope) {
return null;
}
const result = {};
for (const key of ['path', 'hash', 'gcv', 'coverageData']) {
const binding = covScope.getOwnBinding(key);
if (!binding) {
return null;
}
const valuePath = binding.path.get('init');
const value = valuePath.evaluate();
if (!value.confident) {
return null;
}
result[key] = value.value;
}
delete result.coverageData[_constants.MAGIC_KEY];
delete result.coverageData.hash;
return result;
}

View File

@@ -0,0 +1,121 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SourceCoverage = void 0;
var _istanbulLibCoverage = require("istanbul-lib-coverage");
function cloneLocation(loc) {
return {
start: {
line: loc && loc.start.line,
column: loc && loc.start.column
},
end: {
line: loc && loc.end.line,
column: loc && loc.end.column
}
};
}
/**
* SourceCoverage provides mutation methods to manipulate the structure of
* a file coverage object. Used by the instrumenter to create a full coverage
* object for a file incrementally.
*
* @private
* @param pathOrObj {String|Object} - see the argument for {@link FileCoverage}
* @extends FileCoverage
* @constructor
*/
class SourceCoverage extends _istanbulLibCoverage.classes.FileCoverage {
constructor(pathOrObj) {
super(pathOrObj);
this.meta = {
last: {
s: 0,
f: 0,
b: 0
}
};
}
newStatement(loc) {
const s = this.meta.last.s;
this.data.statementMap[s] = cloneLocation(loc);
this.data.s[s] = 0;
this.meta.last.s += 1;
return s;
}
newFunction(name, decl, loc) {
const f = this.meta.last.f;
name = name || '(anonymous_' + f + ')';
this.data.fnMap[f] = {
name,
decl: cloneLocation(decl),
loc: cloneLocation(loc),
// DEPRECATED: some legacy reports require this info.
line: loc && loc.start.line
};
this.data.f[f] = 0;
this.meta.last.f += 1;
return f;
}
newBranch(type, loc) {
const b = this.meta.last.b;
this.data.b[b] = [];
this.data.branchMap[b] = {
loc: cloneLocation(loc),
type,
locations: [],
// DEPRECATED: some legacy reports require this info.
line: loc && loc.start.line
};
this.meta.last.b += 1;
return b;
}
addBranchPath(name, location) {
const bMeta = this.data.branchMap[name];
const counts = this.data.b[name];
/* istanbul ignore if: paranoid check */
if (!bMeta) {
throw new Error('Invalid branch ' + name);
}
bMeta.locations.push(cloneLocation(location));
counts.push(0);
return counts.length - 1;
}
/**
* Assigns an input source map to the coverage that can be used
* to remap the coverage output to the original source
* @param sourceMap {object} the source map
*/
inputSourceMap(sourceMap) {
this.data.inputSourceMap = sourceMap;
}
freeze() {
// prune empty branches
const map = this.data.branchMap;
const branches = this.data.b;
Object.keys(map).forEach(b => {
if (map[b].locations.length === 0) {
delete map[b];
delete branches[b];
}
});
}
}
exports.SourceCoverage = SourceCoverage;

683
node_modules/istanbul-lib-instrument/dist/visitor.js generated vendored Normal file

File diff suppressed because it is too large Load Diff