From 731d4091da4be2b99325ed0b376bc34d65e3122f Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Wed, 8 Oct 2025 17:12:06 +0200 Subject: [PATCH 01/32] mvp --- pnpm-lock.yaml | 32 ++++++++ v-next/hardhat/package.json | 6 ++ .../coverage/coverage-manager.ts | 81 +++++++++++++++++++ 3 files changed, 119 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 21245c14f31..02b6c610df4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -161,6 +161,15 @@ importers: '@sentry/core': specifier: ^9.4.0 version: 9.46.0 + '@types/istanbul-lib-coverage': + specifier: ^2.0.6 + version: 2.0.6 + '@types/istanbul-lib-report': + specifier: ^3.0.3 + version: 3.0.3 + '@types/istanbul-reports': + specifier: ^3.0.4 + version: 3.0.4 adm-zip: specifier: ^0.4.16 version: 0.4.16 @@ -179,6 +188,15 @@ importers: ethereum-cryptography: specifier: ^2.2.1 version: 2.2.1 + istanbul-lib-coverage: + specifier: ^3.2.2 + version: 3.2.2 + istanbul-lib-report: + specifier: ^3.0.1 + version: 3.0.1 + istanbul-reports: + specifier: ^3.2.0 + version: 3.2.0 micro-eth-signer: specifier: ^0.14.0 version: 0.14.0 @@ -2847,6 +2865,12 @@ packages: '@types/istanbul-lib-coverage@2.0.6': resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} + '@types/istanbul-lib-report@3.0.3': + resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + + '@types/istanbul-reports@3.0.4': + resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -6772,6 +6796,14 @@ snapshots: '@types/istanbul-lib-coverage@2.0.6': {} + '@types/istanbul-lib-report@3.0.3': + dependencies: + '@types/istanbul-lib-coverage': 2.0.6 + + '@types/istanbul-reports@3.0.4': + dependencies: + '@types/istanbul-lib-report': 3.0.3 + '@types/json-schema@7.0.15': {} '@types/json5@0.0.29': {} diff --git a/v-next/hardhat/package.json b/v-next/hardhat/package.json index 928e0461edc..3c7beccb394 100644 --- a/v-next/hardhat/package.json +++ b/v-next/hardhat/package.json @@ -92,12 +92,18 @@ "@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.1", "@nomicfoundation/solidity-analyzer": "^0.1.1", "@sentry/core": "^9.4.0", + "@types/istanbul-lib-coverage": "^2.0.6", + "@types/istanbul-lib-report": "^3.0.3", + "@types/istanbul-reports": "^3.0.4", "adm-zip": "^0.4.16", "chalk": "^5.3.0", "chokidar": "^4.0.3", "debug": "^4.3.2", "enquirer": "^2.3.0", "ethereum-cryptography": "^2.2.1", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.2.0", "micro-eth-signer": "^0.14.0", "p-map": "^7.0.2", "resolve.exports": "^2.0.3", diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index 14f5a27325d..ce50d0b6c24 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -5,7 +5,9 @@ import type { Statement, Tag, } from "./types.js"; +import type { FileCoverageData } from "istanbul-lib-coverage"; +import fs from "node:fs"; import path from "node:path"; import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors"; @@ -18,6 +20,12 @@ import { writeUtf8File, } from "@nomicfoundation/hardhat-utils/fs"; import debug from "debug"; +// +// Report +// +import libCoverage from "istanbul-lib-coverage"; +import libReport from "istanbul-lib-report"; +import reports from "istanbul-reports"; const log = debug("hardhat:core:coverage:coverage-manager"); @@ -111,6 +119,79 @@ export class CoverageManagerImplementation implements CoverageManager { console.log(markdownReport); log("Printed markdown report"); + + await this.#lcovToHtml(report); + + // + // + // + } + + async #lcovToHtml(report: Report): Promise { + const reporter: "html" | "html-spa" = "html-spa"; + + const outDir = "coverage/html"; + const baseDir = process.cwd(); + const treatUnlisted = false; // treatUnlistedLinesAsUncovered + + const coverageMap = libCoverage.createCoverageMap({}); + + for (const [relativePath, file] of Object.entries(report)) { + const filePath = path.isAbsolute(relativePath) + ? relativePath + : path.join(baseDir, relativePath); + + // Optional: read source to set end columns to the actual line length + let lines: string[] = []; + try { + lines = fs.readFileSync(filePath, "utf8").split(/\r?\n/); + } catch { + // ok if the file is not available on disk; columns will be 0 + } + + // Build the set of line candidates we want to color + const candidates = new Set(); + for (const line of file.lineExecutionCounts.keys()) candidates.add(line); + for (const line of file.unexecutedLines) candidates.add(line); + if (treatUnlisted && lines.length > 0) { + for (let i = 1; i <= lines.length; i++) candidates.add(i); + } + + const statementMap: FileCoverageData["statementMap"] = {}; + const s: FileCoverageData["s"] = {}; + let sid = 0; + + for (const lineNo of [...candidates].sort((a, b) => a - b)) { + const id = String(++sid); + const endCol = lines[lineNo - 1]?.length ?? 0; + + // Make each source line a pseudo "statement" + statementMap[id] = { + start: { line: lineNo, column: 0 }, + end: { line: lineNo, column: endCol }, + }; + + const hits = file.lineExecutionCounts.get(lineNo) ?? 0; + s[id] = hits > 0 ? 1 : 0; // green if hit, red if not + } + + const fileCoverage: FileCoverageData = { + path: filePath, // you can also keep relativePath if you prefer + statementMap, + s, + fnMap: {}, + f: {}, + branchMap: {}, + b: {}, + }; + + coverageMap.addFileCoverage(fileCoverage); + } + + fs.mkdirSync(outDir, { recursive: true }); + const context = libReport.createContext({ dir: outDir, coverageMap }); + reports.create(reporter).execute(context); + console.log(`HTML report written to ${path.resolve(outDir)}`); } public enableReport(): void { From 4088b56fb2217cc7967a6d96e42eb27984149b6e Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 13 Oct 2025 16:27:51 +0200 Subject: [PATCH 02/32] istanbul libCoverage: copy original js file in root assets folder --- v-next/hardhat/assets/index.js | 2 + v-next/hardhat/assets/lib-coverage/index.cjs | 64 +++ .../assets/lib-coverage/lib/coverage-map.cjs | 134 ++++++ .../lib-coverage/lib/coverage-summary.cjs | 112 +++++ .../lib-coverage/lib/data-properties.cjs | 12 + .../assets/lib-coverage/lib/file-coverage.cjs | 442 ++++++++++++++++++ .../assets/lib-coverage/lib/percent.cjs | 15 + v-next/hardhat/package.json | 1 + .../coverage/coverage-manager.ts | 8 +- 9 files changed, 789 insertions(+), 1 deletion(-) create mode 100644 v-next/hardhat/assets/index.js create mode 100644 v-next/hardhat/assets/lib-coverage/index.cjs create mode 100644 v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs create mode 100644 v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs create mode 100644 v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs create mode 100644 v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs create mode 100644 v-next/hardhat/assets/lib-coverage/lib/percent.cjs diff --git a/v-next/hardhat/assets/index.js b/v-next/hardhat/assets/index.js new file mode 100644 index 00000000000..b77bdab0b75 --- /dev/null +++ b/v-next/hardhat/assets/index.js @@ -0,0 +1,2 @@ +import libCoverage from "./lib-coverage/index.cjs"; +export default libCoverage; diff --git a/v-next/hardhat/assets/lib-coverage/index.cjs b/v-next/hardhat/assets/lib-coverage/index.cjs new file mode 100644 index 00000000000..c6074ee2d56 --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/index.cjs @@ -0,0 +1,64 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * istanbul-lib-coverage exports an API that allows you to create and manipulate + * file coverage, coverage maps (a set of file coverage objects) and summary + * coverage objects. File coverage for the same file can be merged as can + * entire coverage maps. + * + * @module Exports + */ +const { FileCoverage } = require("./lib/file-coverage.cjs"); +const { CoverageMap } = require("./lib/coverage-map.cjs"); +const { CoverageSummary } = require("./lib/coverage-summary.cjs"); + +module.exports = { + /** + * creates a coverage summary object + * @param {Object} obj an argument with the same semantics + * as the one passed to the `CoverageSummary` constructor + * @returns {CoverageSummary} + */ + createCoverageSummary(obj) { + if (obj && obj instanceof CoverageSummary) { + return obj; + } + return new CoverageSummary(obj); + }, + /** + * creates a CoverageMap object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the CoverageMap constructor. + * @returns {CoverageMap} + */ + createCoverageMap(obj) { + if (obj && obj instanceof CoverageMap) { + return obj; + } + return new CoverageMap(obj); + }, + /** + * creates a FileCoverage object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the FileCoverage constructor. + * @returns {FileCoverage} + */ + createFileCoverage(obj) { + if (obj && obj instanceof FileCoverage) { + return obj; + } + return new FileCoverage(obj); + }, +}; + +/** classes exported for reuse */ +module.exports.classes = { + /** + * the file coverage constructor + */ + FileCoverage, +}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs new file mode 100644 index 00000000000..b3f80303341 --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs @@ -0,0 +1,134 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const { FileCoverage } = require("./file-coverage.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); + +function maybeConstruct(obj, klass) { + if (obj instanceof klass) { + return obj; + } + + return new klass(obj); +} + +function loadMap(source) { + const data = Object.create(null); + if (!source) { + return data; + } + + Object.entries(source).forEach(([k, cov]) => { + data[k] = maybeConstruct(cov, FileCoverage); + }); + + return data; +} + +/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ +class CoverageMap { + /** + * @constructor + * @param {Object} [obj=undefined] obj A coverage map from which to initialize this + * map's contents. This can be the raw global coverage object. + */ + constructor(obj) { + if (obj instanceof CoverageMap) { + this.data = obj.data; + } else { + this.data = loadMap(obj); + } + } + + /** + * merges a second coverage map into this one + * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged + * correctly for the same files and additional file coverage keys are created + * as needed. + */ + merge(obj) { + const other = maybeConstruct(obj, CoverageMap); + Object.values(other.data).forEach((fc) => { + this.addFileCoverage(fc); + }); + } + + /** + * filter the coveragemap based on the callback provided + * @param {Function (filename)} callback - Returns true if the path + * should be included in the coveragemap. False if it should be + * removed. + */ + filter(callback) { + Object.keys(this.data).forEach((k) => { + if (!callback(k)) { + delete this.data[k]; + } + }); + } + + /** + * returns a JSON-serializable POJO for this coverage map + * @returns {Object} + */ + toJSON() { + return this.data; + } + + /** + * returns an array for file paths for which this map has coverage + * @returns {Array{string}} - array of files + */ + files() { + return Object.keys(this.data); + } + + /** + * returns the file coverage for the specified file. + * @param {String} file + * @returns {FileCoverage} + */ + fileCoverageFor(file) { + const fc = this.data[file]; + if (!fc) { + throw new Error(`No file coverage available for: ${file}`); + } + return fc; + } + + /** + * adds a file coverage object to this map. If the path for the object, + * already exists in the map, it is merged with the existing coverage + * otherwise a new key is added to the map. + * @param {FileCoverage} fc the file coverage to add + */ + addFileCoverage(fc) { + const cov = new FileCoverage(fc); + const { path } = cov; + if (this.data[path]) { + this.data[path].merge(cov); + } else { + this.data[path] = cov; + } + } + + /** + * returns the coverage summary for all the file coverage objects in this map. + * @returns {CoverageSummary} + */ + getCoverageSummary() { + const ret = new CoverageSummary(); + Object.values(this.data).forEach((fc) => { + ret.merge(fc.toSummary()); + }); + + return ret; + } +} + +module.exports = { + CoverageMap, +}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs new file mode 100644 index 00000000000..1e6a9498936 --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs @@ -0,0 +1,112 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); + +function blankSummary() { + const empty = () => ({ + total: 0, + covered: 0, + skipped: 0, + pct: "Unknown", + }); + + return { + lines: empty(), + statements: empty(), + functions: empty(), + branches: empty(), + branchesTrue: empty(), + }; +} + +// asserts that a data object "looks like" a summary coverage object +function assertValidSummary(obj) { + const valid = + obj && obj.lines && obj.statements && obj.functions && obj.branches; + if (!valid) { + throw new Error( + "Invalid summary coverage object, missing keys, found:" + + Object.keys(obj).join(","), + ); + } +} + +/** + * CoverageSummary provides a summary of code coverage . It exposes 4 properties, + * `lines`, `statements`, `branches`, and `functions`. Each of these properties + * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. + * `pct` is a percentage number (0-100). + */ +class CoverageSummary { + /** + * @constructor + * @param {Object|CoverageSummary} [obj=undefined] an optional data object or + * another coverage summary to initialize this object with. + */ + constructor(obj) { + if (!obj) { + this.data = blankSummary(); + } else if (obj instanceof CoverageSummary) { + this.data = obj.data; + } else { + this.data = obj; + } + assertValidSummary(this.data); + } + + /** + * merges a second summary coverage object into this one + * @param {CoverageSummary} obj - another coverage summary object + */ + merge(obj) { + const keys = [ + "lines", + "statements", + "branches", + "functions", + "branchesTrue", + ]; + keys.forEach((key) => { + if (obj[key]) { + this[key].total += obj[key].total; + this[key].covered += obj[key].covered; + this[key].skipped += obj[key].skipped; + this[key].pct = percent(this[key].covered, this[key].total); + } + }); + + return this; + } + + /** + * returns a POJO that is JSON serializable. May be used to get the raw + * summary object. + */ + toJSON() { + return this.data; + } + + /** + * return true if summary has no lines of code + */ + isEmpty() { + return this.lines.total === 0; + } +} + +dataProperties(CoverageSummary, [ + "lines", + "statements", + "functions", + "branches", + "branchesTrue", +]); + +module.exports = { + CoverageSummary, +}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs b/v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs new file mode 100644 index 00000000000..ad6ac0e1453 --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs @@ -0,0 +1,12 @@ +"use strict"; + +module.exports = function dataProperties(klass, properties) { + properties.forEach((p) => { + Object.defineProperty(klass.prototype, p, { + enumerable: true, + get() { + return this.data[p]; + }, + }); + }); +}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs new file mode 100644 index 00000000000..47f45bbd63f --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs @@ -0,0 +1,442 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); + +// returns a data object that represents empty coverage +function emptyCoverage(filePath, reportLogic) { + const cov = { + path: filePath, + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {}, + }; + if (reportLogic) cov.bT = {}; + return cov; +} + +// asserts that a data object "looks like" a coverage object +function assertValidObject(obj) { + const valid = + obj && + obj.path && + obj.statementMap && + obj.fnMap && + obj.branchMap && + obj.s && + obj.f && + obj.b; + if (!valid) { + throw new Error( + "Invalid file coverage object, missing keys, found:" + + Object.keys(obj).join(","), + ); + } +} + +const keyFromLoc = ({ start, end }) => + `${start.line}|${start.column}|${end.line}|${end.column}`; + +const isObj = (o) => !!o && typeof o === "object"; +const isLineCol = (o) => + isObj(o) && typeof o.line === "number" && typeof o.column === "number"; +const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); +const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); + +// When merging, we can have a case where two ranges cover +// the same block of code with `hits=1`, and each carve out a +// different range with `hits=0` to indicate it's uncovered. +// Find the nearest container so that we can properly indicate +// that both sections are hit. +// Returns null if no containing item is found. +const findNearestContainer = (item, map) => { + const itemLoc = getLoc(item); + if (!itemLoc) return null; + // the B item is not an identified range in the A set, BUT + // it may be contained by an identified A range. If so, then + // any hit of that containing A range counts as a hit of this + // B range as well. We have to find the *narrowest* containing + // range to be accurate, since ranges can be hit and un-hit + // in a nested fashion. + let nearestContainingItem = null; + let containerDistance = null; + let containerKey = null; + for (const [i, mapItem] of Object.entries(map)) { + const mapLoc = getLoc(mapItem); + if (!mapLoc) continue; + // contained if all of line distances are > 0 + // or line distance is 0 and col dist is >= 0 + const distance = [ + itemLoc.start.line - mapLoc.start.line, + itemLoc.start.column - mapLoc.start.column, + mapLoc.end.line - itemLoc.end.line, + mapLoc.end.column - itemLoc.end.column, + ]; + if ( + distance[0] < 0 || + distance[2] < 0 || + (distance[0] === 0 && distance[1] < 0) || + (distance[2] === 0 && distance[3] < 0) + ) { + continue; + } + if (nearestContainingItem === null) { + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + continue; + } + // closer line more relevant than closer column + const closerBefore = + distance[0] < containerDistance[0] || + (distance[0] === 0 && distance[1] < containerDistance[1]); + const closerAfter = + distance[2] < containerDistance[2] || + (distance[2] === 0 && distance[3] < containerDistance[3]); + if (closerBefore || closerAfter) { + // closer + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + } + } + return containerKey; +}; + +// either add two numbers, or all matching entries in a number[] +const addHits = (aHits, bHits) => { + if (typeof aHits === "number" && typeof bHits === "number") { + return aHits + bHits; + } else if (Array.isArray(aHits) && Array.isArray(bHits)) { + return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); + } + return null; +}; + +const addNearestContainerHits = (item, itemHits, map, mapHits) => { + const container = findNearestContainer(item, map); + if (container) { + return addHits(itemHits, mapHits[container]); + } else { + return itemHits; + } +}; + +const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { + const aItems = {}; + for (const [key, itemHits] of Object.entries(aHits)) { + const item = aMap[key]; + aItems[itemKey(item)] = [itemHits, item]; + } + const bItems = {}; + for (const [key, itemHits] of Object.entries(bHits)) { + const item = bMap[key]; + bItems[itemKey(item)] = [itemHits, item]; + } + const mergedItems = {}; + for (const [key, aValue] of Object.entries(aItems)) { + let aItemHits = aValue[0]; + const aItem = aValue[1]; + const bValue = bItems[key]; + if (!bValue) { + // not an identified range in b, but might be contained by one + aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); + } else { + // is an identified range in b, so add the hits together + aItemHits = addHits(aItemHits, bValue[0]); + } + mergedItems[key] = [aItemHits, aItem]; + } + // now find the items in b that are not in a. already added matches. + for (const [key, bValue] of Object.entries(bItems)) { + let bItemHits = bValue[0]; + const bItem = bValue[1]; + if (mergedItems[key]) continue; + // not an identified range in b, but might be contained by one + bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); + mergedItems[key] = [bItemHits, bItem]; + } + + const hits = {}; + const map = {}; + + Object.values(mergedItems).forEach(([itemHits, item], i) => { + hits[i] = itemHits; + map[i] = item; + }); + + return [hits, map]; +}; + +/** + * provides a read-only view of coverage for a single file. + * The deep structure of this object is documented elsewhere. It has the following + * properties: + * + * * `path` - the file path for which coverage is being tracked + * * `statementMap` - map of statement locations keyed by statement index + * * `fnMap` - map of function metadata keyed by function index + * * `branchMap` - map of branch metadata keyed by branch index + * * `s` - hit counts for statements + * * `f` - hit count for functions + * * `b` - hit count for branches + */ +class FileCoverage { + /** + * @constructor + * @param {Object|FileCoverage|String} pathOrObj is a string that initializes + * and empty coverage object with the specified file path or a data object that + * has all the required properties for a file coverage object. + */ + constructor(pathOrObj, reportLogic = false) { + if (!pathOrObj) { + throw new Error("Coverage must be initialized with a path or an object"); + } + if (typeof pathOrObj === "string") { + this.data = emptyCoverage(pathOrObj, reportLogic); + } else if (pathOrObj instanceof FileCoverage) { + this.data = pathOrObj.data; + } else if (typeof pathOrObj === "object") { + this.data = pathOrObj; + } else { + throw new Error("Invalid argument to coverage constructor"); + } + assertValidObject(this.data); + } + + /** + * returns computed line coverage from statement coverage. + * This is a map of hits keyed by line number in the source. + */ + getLineCoverage() { + const statementMap = this.data.statementMap; + const statements = this.data.s; + const lineMap = Object.create(null); + + Object.entries(statements).forEach(([st, count]) => { + /* istanbul ignore if: is this even possible? */ + if (!statementMap[st]) { + return; + } + const { line } = statementMap[st].start; + const prevVal = lineMap[line]; + if (prevVal === undefined || prevVal < count) { + lineMap[line] = count; + } + }); + return lineMap; + } + + /** + * returns an array of uncovered line numbers. + * @returns {Array} an array of line numbers for which no hits have been + * collected. + */ + getUncoveredLines() { + const lc = this.getLineCoverage(); + const ret = []; + Object.entries(lc).forEach(([l, hits]) => { + if (hits === 0) { + ret.push(l); + } + }); + return ret; + } + + /** + * returns a map of branch coverage by source line number. + * @returns {Object} an object keyed by line number. Each object + * has a `covered`, `total` and `coverage` (percentage) property. + */ + getBranchCoverageByLine() { + const branchMap = this.branchMap; + const branches = this.b; + const ret = {}; + Object.entries(branchMap).forEach(([k, map]) => { + const line = map.line || map.loc.start.line; + const branchData = branches[k]; + ret[line] = ret[line] || []; + ret[line].push(...branchData); + }); + Object.entries(ret).forEach(([k, dataArray]) => { + const covered = dataArray.filter((item) => item > 0); + const coverage = (covered.length / dataArray.length) * 100; + ret[k] = { + covered: covered.length, + total: dataArray.length, + coverage, + }; + }); + return ret; + } + + /** + * return a JSON-serializable POJO for this file coverage object + */ + toJSON() { + return this.data; + } + + /** + * merges a second coverage object into this one, updating hit counts + * @param {FileCoverage} other - the coverage object to be merged into this one. + * Note that the other object should have the same structure as this one (same file). + */ + merge(other) { + if (other.all === true) { + return; + } + + if (this.all === true) { + this.data = other.data; + return; + } + + let [hits, map] = mergeProp( + this.s, + this.statementMap, + other.s, + other.statementMap, + ); + this.data.s = hits; + this.data.statementMap = map; + + const keyFromLocProp = (x) => keyFromLoc(x.loc); + const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); + + [hits, map] = mergeProp( + this.f, + this.fnMap, + other.f, + other.fnMap, + keyFromLocProp, + ); + this.data.f = hits; + this.data.fnMap = map; + + [hits, map] = mergeProp( + this.b, + this.branchMap, + other.b, + other.branchMap, + keyFromLocationsProp, + ); + this.data.b = hits; + this.data.branchMap = map; + + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT && other.bT) { + [hits, map] = mergeProp( + this.bT, + this.branchMap, + other.bT, + other.branchMap, + keyFromLocationsProp, + ); + this.data.bT = hits; + } + } + + computeSimpleTotals(property) { + let stats = this[property]; + + if (typeof stats === "function") { + stats = stats.call(this); + } + + const ret = { + total: Object.keys(stats).length, + covered: Object.values(stats).filter((v) => !!v).length, + skipped: 0, + }; + ret.pct = percent(ret.covered, ret.total); + return ret; + } + + computeBranchTotals(property) { + const stats = this[property]; + const ret = { total: 0, covered: 0, skipped: 0 }; + + Object.values(stats).forEach((branches) => { + ret.covered += branches.filter((hits) => hits > 0).length; + ret.total += branches.length; + }); + ret.pct = percent(ret.covered, ret.total); + return ret; + } + + /** + * resets hit counts for all statements, functions and branches + * in this coverage object resulting in zero coverage. + */ + resetHits() { + const statements = this.s; + const functions = this.f; + const branches = this.b; + const branchesTrue = this.bT; + Object.keys(statements).forEach((s) => { + statements[s] = 0; + }); + Object.keys(functions).forEach((f) => { + functions[f] = 0; + }); + Object.keys(branches).forEach((b) => { + branches[b].fill(0); + }); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (branchesTrue) { + Object.keys(branchesTrue).forEach((bT) => { + branchesTrue[bT].fill(0); + }); + } + } + + /** + * returns a CoverageSummary for this file coverage object + * @returns {CoverageSummary} + */ + toSummary() { + const ret = {}; + ret.lines = this.computeSimpleTotals("getLineCoverage"); + ret.functions = this.computeSimpleTotals("f", "fnMap"); + ret.statements = this.computeSimpleTotals("s", "statementMap"); + ret.branches = this.computeBranchTotals("b"); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT) { + ret.branchesTrue = this.computeBranchTotals("bT"); + } + return new CoverageSummary(ret); + } +} + +// expose coverage data attributes +dataProperties(FileCoverage, [ + "path", + "statementMap", + "fnMap", + "branchMap", + "s", + "f", + "b", + "bT", + "all", +]); + +module.exports = { + FileCoverage, + // exported for testing + findNearestContainer, + addHits, + addNearestContainerHits, +}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/percent.cjs b/v-next/hardhat/assets/lib-coverage/lib/percent.cjs new file mode 100644 index 00000000000..ecb468d56b9 --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/lib/percent.cjs @@ -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"; + +module.exports = function percent(covered, total) { + let tmp; + if (total > 0) { + tmp = (1000 * 100 * covered) / total; + return Math.floor(tmp / 10) / 100; + } else { + return 100.0; + } +}; diff --git a/v-next/hardhat/package.json b/v-next/hardhat/package.json index 3c7beccb394..02b332dffdd 100644 --- a/v-next/hardhat/package.json +++ b/v-next/hardhat/package.json @@ -63,6 +63,7 @@ "files": [ "dist/src/", "src/", + "assets/", "templates/", "console.sol", "coverage.sol", diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index ce50d0b6c24..e8cbe5b089f 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -19,11 +19,12 @@ import { writeJsonFile, writeUtf8File, } from "@nomicfoundation/hardhat-utils/fs"; +import { findClosestPackageRoot } from "@nomicfoundation/hardhat-utils/package"; import debug from "debug"; // // Report // -import libCoverage from "istanbul-lib-coverage"; +// import libCoverage from "istanbul-lib-coverage"; import libReport from "istanbul-lib-report"; import reports from "istanbul-reports"; @@ -134,6 +135,11 @@ export class CoverageManagerImplementation implements CoverageManager { const baseDir = process.cwd(); const treatUnlisted = false; // treatUnlistedLinesAsUncovered + const packageRoot = await findClosestPackageRoot(import.meta.url); + const { default: libCoverage } = await import( + path.join(packageRoot, "assets", "index.js") + ); + const coverageMap = libCoverage.createCoverageMap({}); for (const [relativePath, file] of Object.entries(report)) { From e3d52e350aeb7ab86a24cd28f2aacccd62cdc848 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:13:32 +0200 Subject: [PATCH 03/32] libReport --- v-next/hardhat/assets/index.js | 5 +- v-next/hardhat/assets/lib-report/index.cjs | 40 +++ .../hardhat/assets/lib-report/lib/context.cjs | 132 ++++++++ .../assets/lib-report/lib/file-writer.cjs | 189 ++++++++++++ v-next/hardhat/assets/lib-report/lib/path.cjs | 169 +++++++++++ .../assets/lib-report/lib/report-base.cjs | 16 + .../lib-report/lib/summarizer-factory.cjs | 284 ++++++++++++++++++ v-next/hardhat/assets/lib-report/lib/tree.cjs | 137 +++++++++ .../assets/lib-report/lib/watermarks.cjs | 15 + .../assets/lib-report/lib/xml-writer.cjs | 90 ++++++ .../coverage/coverage-manager.ts | 10 +- 11 files changed, 1084 insertions(+), 3 deletions(-) create mode 100644 v-next/hardhat/assets/lib-report/index.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/context.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/file-writer.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/path.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/report-base.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/tree.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/watermarks.cjs create mode 100644 v-next/hardhat/assets/lib-report/lib/xml-writer.cjs diff --git a/v-next/hardhat/assets/index.js b/v-next/hardhat/assets/index.js index b77bdab0b75..3a59ef0c6ad 100644 --- a/v-next/hardhat/assets/index.js +++ b/v-next/hardhat/assets/index.js @@ -1,2 +1,5 @@ import libCoverage from "./lib-coverage/index.cjs"; -export default libCoverage; +export { libCoverage }; + +import libReport from "./lib-report/index.cjs"; +export { libReport }; diff --git a/v-next/hardhat/assets/lib-report/index.cjs b/v-next/hardhat/assets/lib-report/index.cjs new file mode 100644 index 00000000000..f7aad0370c1 --- /dev/null +++ b/v-next/hardhat/assets/lib-report/index.cjs @@ -0,0 +1,40 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * @module Exports + */ + +const Context = require("./lib/context.cjs"); +const watermarks = require("./lib/watermarks.cjs"); +const ReportBase = require("./lib/report-base.cjs"); + +module.exports = { + /** + * returns a reporting context for the supplied options + * @param {Object} [opts=null] opts + * @returns {Context} + */ + createContext(opts) { + return new Context(opts); + }, + + /** + * returns the default watermarks that would be used when not + * overridden + * @returns {Object} an object with `statements`, `functions`, `branches`, + * and `line` keys. Each value is a 2 element array that has the low and + * high watermark as percentages. + */ + getDefaultWatermarks() { + return watermarks.getDefault(); + }, + + /** + * Base class for all reports + */ + ReportBase, +}; diff --git a/v-next/hardhat/assets/lib-report/lib/context.cjs b/v-next/hardhat/assets/lib-report/lib/context.cjs new file mode 100644 index 00000000000..34df8cf5ea2 --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/context.cjs @@ -0,0 +1,132 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("fs"); +const FileWriter = require("./file-writer.cjs"); +const XMLWriter = require("./xml-writer.cjs"); +const tree = require("./tree.cjs"); +const watermarks = require("./watermarks.cjs"); +const SummarizerFactory = require("./summarizer-factory.cjs"); + +function defaultSourceLookup(path) { + try { + return fs.readFileSync(path, "utf8"); + } catch (ex) { + throw new Error(`Unable to lookup source: ${path} (${ex.message})`); + } +} + +function normalizeWatermarks(specified = {}) { + Object.entries(watermarks.getDefault()).forEach(([k, value]) => { + const specValue = specified[k]; + if (!Array.isArray(specValue) || specValue.length !== 2) { + specified[k] = value; + } + }); + + return specified; +} + +/** + * A reporting context that is passed to report implementations + * @param {Object} [opts=null] opts options + * @param {String} [opts.dir='coverage'] opts.dir the reporting directory + * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for + * statements, lines, branches and functions + * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a + * function that returns source code given a file path. Defaults to + * filesystem lookups based on path. + * @constructor + */ +class Context { + constructor(opts) { + this.dir = opts.dir || "coverage"; + this.watermarks = normalizeWatermarks(opts.watermarks); + this.sourceFinder = opts.sourceFinder || defaultSourceLookup; + this._summarizerFactory = new SummarizerFactory( + opts.coverageMap, + opts.defaultSummarizer, + ); + this.data = {}; + } + + /** + * returns a FileWriter implementation for reporting use. Also available + * as the `writer` property on the context. + * @returns {Writer} + */ + getWriter() { + return this.writer; + } + + /** + * returns the source code for the specified file path or throws if + * the source could not be found. + * @param {String} filePath the file path as found in a file coverage object + * @returns {String} the source code + */ + getSource(filePath) { + return this.sourceFinder(filePath); + } + + /** + * returns the coverage class given a coverage + * types and a percentage value. + * @param {String} type - the coverage type, one of `statements`, `functions`, + * `branches`, or `lines` + * @param {Number} value - the percentage value + * @returns {String} one of `high`, `medium` or `low` + */ + classForPercent(type, value) { + const watermarks = this.watermarks[type]; + if (!watermarks) { + return "unknown"; + } + if (value < watermarks[0]) { + return "low"; + } + if (value >= watermarks[1]) { + return "high"; + } + return "medium"; + } + + /** + * returns an XML writer for the supplied content writer + * @param {ContentWriter} contentWriter the content writer to which the returned XML writer + * writes data + * @returns {XMLWriter} + */ + getXMLWriter(contentWriter) { + return new XMLWriter(contentWriter); + } + + /** + * returns a full visitor given a partial one. + * @param {Object} partialVisitor a partial visitor only having the functions of + * interest to the caller. These functions are called with a scope that is the + * supplied object. + * @returns {Visitor} + */ + getVisitor(partialVisitor) { + return new tree.Visitor(partialVisitor); + } + + getTree(name = "defaultSummarizer") { + return this._summarizerFactory[name]; + } +} + +Object.defineProperty(Context.prototype, "writer", { + enumerable: true, + get() { + if (!this.data.writer) { + this.data.writer = new FileWriter(this.dir); + } + return this.data.writer; + }, +}); + +module.exports = Context; diff --git a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs new file mode 100644 index 00000000000..45e594187ee --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs @@ -0,0 +1,189 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("path"); +const fs = require("fs"); +const mkdirp = require("make-dir"); +const supportsColor = require("supports-color"); + +/** + * Base class for writing content + * @class ContentWriter + * @constructor + */ +class ContentWriter { + /** + * returns the colorized version of a string. Typically, + * content writers that write to files will return the + * same string and ones writing to a tty will wrap it in + * appropriate escape sequences. + * @param {String} str the string to colorize + * @param {String} clazz one of `high`, `medium` or `low` + * @returns {String} the colorized form of the string + */ + colorize(str /*, clazz*/) { + return str; + } + + /** + * writes a string appended with a newline to the destination + * @param {String} str the string to write + */ + println(str) { + this.write(`${str}\n`); + } + + /** + * closes this content writer. Should be called after all writes are complete. + */ + close() {} +} + +/** + * a content writer that writes to a file + * @param {Number} fd - the file descriptor + * @extends ContentWriter + * @constructor + */ +class FileContentWriter extends ContentWriter { + constructor(fd) { + super(); + + this.fd = fd; + } + + write(str) { + fs.writeSync(this.fd, str); + } + + close() { + fs.closeSync(this.fd); + } +} + +// allow stdout to be captured for tests. +let capture = false; +let output = ""; + +/** + * a content writer that writes to the console + * @extends ContentWriter + * @constructor + */ +class ConsoleWriter extends ContentWriter { + write(str) { + if (capture) { + output += str; + } else { + process.stdout.write(str); + } + } + + colorize(str, clazz) { + const colors = { + low: "31;1", + medium: "33;1", + high: "32;1", + }; + + /* istanbul ignore next: different modes for CI and local */ + if (supportsColor.stdout && colors[clazz]) { + return `\u001b[${colors[clazz]}m${str}\u001b[0m`; + } + return str; + } +} + +/** + * utility for writing files under a specific directory + * @class FileWriter + * @param {String} baseDir the base directory under which files should be written + * @constructor + */ +class FileWriter { + constructor(baseDir) { + if (!baseDir) { + throw new Error("baseDir must be specified"); + } + this.baseDir = baseDir; + } + + /** + * static helpers for capturing stdout report output; + * super useful for tests! + */ + static startCapture() { + capture = true; + } + + static stopCapture() { + capture = false; + } + + static getOutput() { + return output; + } + + static resetOutput() { + output = ""; + } + + /** + * returns a FileWriter that is rooted at the supplied subdirectory + * @param {String} subdir the subdirectory under which to root the + * returned FileWriter + * @returns {FileWriter} + */ + writerForDir(subdir) { + if (path.isAbsolute(subdir)) { + throw new Error( + `Cannot create subdir writer for absolute path: ${subdir}`, + ); + } + return new FileWriter(`${this.baseDir}/${subdir}`); + } + + /** + * copies a file from a source directory to a destination name + * @param {String} source path to source file + * @param {String} dest relative path to destination file + * @param {String} [header=undefined] optional text to prepend to destination + * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) + */ + copyFile(source, dest, header) { + if (path.isAbsolute(dest)) { + throw new Error(`Cannot write to absolute path: ${dest}`); + } + dest = path.resolve(this.baseDir, dest); + mkdirp.sync(path.dirname(dest)); + let contents; + if (header) { + contents = header + fs.readFileSync(source, "utf8"); + } else { + contents = fs.readFileSync(source); + } + fs.writeFileSync(dest, contents); + } + + /** + * returns a content writer for writing content to the supplied file. + * @param {String|null} file the relative path to the file or the special + * values `"-"` or `null` for writing to the console + * @returns {ContentWriter} + */ + writeFile(file) { + if (file === null || file === "-") { + return new ConsoleWriter(); + } + if (path.isAbsolute(file)) { + throw new Error(`Cannot write to absolute path: ${file}`); + } + file = path.resolve(this.baseDir, file); + mkdirp.sync(path.dirname(file)); + return new FileContentWriter(fs.openSync(file, "w")); + } +} + +module.exports = FileWriter; diff --git a/v-next/hardhat/assets/lib-report/lib/path.cjs b/v-next/hardhat/assets/lib-report/lib/path.cjs new file mode 100644 index 00000000000..cec0606f764 --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/path.cjs @@ -0,0 +1,169 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const path = require("path"); +let parsePath = path.parse; +let SEP = path.sep; +const origParser = parsePath; +const origSep = SEP; + +function makeRelativeNormalizedPath(str, sep) { + const parsed = parsePath(str); + let root = parsed.root; + let dir; + let file = parsed.base; + let quoted; + let pos; + + // handle a weird windows case separately + if (sep === "\\") { + pos = root.indexOf(":\\"); + if (pos >= 0) { + root = root.substring(0, pos + 2); + } + } + dir = parsed.dir.substring(root.length); + + if (str === "") { + return []; + } + + if (sep !== "/") { + quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); + dir = dir.replace(quoted, "/"); + file = file.replace(quoted, "/"); // excessively paranoid? + } + + if (dir !== "") { + dir = `${dir}/${file}`; + } else { + dir = file; + } + if (dir.substring(0, 1) === "/") { + dir = dir.substring(1); + } + dir = dir.split(/\/+/); + return dir; +} + +class Path { + constructor(strOrArray) { + if (Array.isArray(strOrArray)) { + this.v = strOrArray; + } else if (typeof strOrArray === "string") { + this.v = makeRelativeNormalizedPath(strOrArray, SEP); + } else { + throw new Error( + `Invalid Path argument must be string or array:${strOrArray}`, + ); + } + } + + toString() { + return this.v.join("/"); + } + + hasParent() { + return this.v.length > 0; + } + + parent() { + if (!this.hasParent()) { + throw new Error("Unable to get parent for 0 elem path"); + } + const p = this.v.slice(); + p.pop(); + return new Path(p); + } + + elements() { + return this.v.slice(); + } + + name() { + return this.v.slice(-1)[0]; + } + + contains(other) { + let i; + if (other.length > this.length) { + return false; + } + for (i = 0; i < other.length; i += 1) { + if (this.v[i] !== other.v[i]) { + return false; + } + } + return true; + } + + ancestorOf(other) { + return other.contains(this) && other.length !== this.length; + } + + descendantOf(other) { + return this.contains(other) && other.length !== this.length; + } + + commonPrefixPath(other) { + const len = this.length > other.length ? other.length : this.length; + let i; + const ret = []; + + for (i = 0; i < len; i += 1) { + if (this.v[i] === other.v[i]) { + ret.push(this.v[i]); + } else { + break; + } + } + return new Path(ret); + } + + static compare(a, b) { + const al = a.length; + const bl = b.length; + + if (al < bl) { + return -1; + } + + if (al > bl) { + return 1; + } + + const astr = a.toString(); + const bstr = b.toString(); + return astr < bstr ? -1 : astr > bstr ? 1 : 0; + } +} + +["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { + Object.defineProperty(Path.prototype, fn, { + value(...args) { + return this.v[fn](...args); + }, + }); +}); + +Object.defineProperty(Path.prototype, "length", { + enumerable: true, + get() { + return this.v.length; + }, +}); + +module.exports = Path; +Path.tester = { + setParserAndSep(p, sep) { + parsePath = p; + SEP = sep; + }, + reset() { + parsePath = origParser; + SEP = origSep; + }, +}; diff --git a/v-next/hardhat/assets/lib-report/lib/report-base.cjs b/v-next/hardhat/assets/lib-report/lib/report-base.cjs new file mode 100644 index 00000000000..1575121b53b --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/report-base.cjs @@ -0,0 +1,16 @@ +"use strict"; + +// TODO: switch to class private field when targeting node.js 12 +const _summarizer = Symbol("ReportBase.#summarizer"); + +class ReportBase { + constructor(opts = {}) { + this[_summarizer] = opts.summarizer; + } + + execute(context) { + context.getTree(this[_summarizer]).visit(this, context); + } +} + +module.exports = ReportBase; diff --git a/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs new file mode 100644 index 00000000000..1128e0cdaf1 --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs @@ -0,0 +1,284 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const coverage = require("istanbul-lib-coverage"); +const Path = require("./path.cjs"); +const { BaseNode, BaseTree } = require("./tree.cjs"); + +class ReportNode extends BaseNode { + constructor(path, fileCoverage) { + super(); + + this.path = path; + this.parent = null; + this.fileCoverage = fileCoverage; + this.children = []; + } + + static createRoot(children) { + const root = new ReportNode(new Path([])); + + children.forEach((child) => { + root.addChild(child); + }); + + return root; + } + + addChild(child) { + child.parent = this; + this.children.push(child); + } + + asRelative(p) { + if (p.substring(0, 1) === "/") { + return p.substring(1); + } + return p; + } + + getQualifiedName() { + return this.asRelative(this.path.toString()); + } + + getRelativeName() { + const parent = this.getParent(); + const myPath = this.path; + let relPath; + let i; + const parentPath = parent ? parent.path : new Path([]); + if (parentPath.ancestorOf(myPath)) { + relPath = new Path(myPath.elements()); + for (i = 0; i < parentPath.length; i += 1) { + relPath.shift(); + } + return this.asRelative(relPath.toString()); + } + return this.asRelative(this.path.toString()); + } + + getParent() { + return this.parent; + } + + getChildren() { + return this.children; + } + + isSummary() { + return !this.fileCoverage; + } + + getFileCoverage() { + return this.fileCoverage; + } + + getCoverageSummary(filesOnly) { + const cacheProp = `c_${filesOnly ? "files" : "full"}`; + let summary; + + if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { + return this[cacheProp]; + } + + if (!this.isSummary()) { + summary = this.getFileCoverage().toSummary(); + } else { + let count = 0; + summary = coverage.createCoverageSummary(); + this.getChildren().forEach((child) => { + if (filesOnly && child.isSummary()) { + return; + } + count += 1; + summary.merge(child.getCoverageSummary(filesOnly)); + }); + if (count === 0 && filesOnly) { + summary = null; + } + } + this[cacheProp] = summary; + return summary; + } +} + +class ReportTree extends BaseTree { + constructor(root, childPrefix) { + super(root); + + const maybePrefix = (node) => { + if (childPrefix && !node.isRoot()) { + node.path.unshift(childPrefix); + } + }; + this.visit({ + onDetail: maybePrefix, + onSummary(node) { + maybePrefix(node); + node.children.sort((a, b) => { + const astr = a.path.toString(); + const bstr = b.path.toString(); + return astr < bstr + ? -1 + : astr > bstr + ? 1 + : /* istanbul ignore next */ 0; + }); + }, + }); + } +} + +function findCommonParent(paths) { + return paths.reduce( + (common, path) => common.commonPrefixPath(path), + paths[0] || new Path([]), + ); +} + +function findOrCreateParent(parentPath, nodeMap, created = () => {}) { + let parent = nodeMap[parentPath.toString()]; + + if (!parent) { + parent = new ReportNode(parentPath); + nodeMap[parentPath.toString()] = parent; + created(parentPath, parent); + } + + return parent; +} + +function toDirParents(list) { + const nodeMap = Object.create(null); + list.forEach((o) => { + const parent = findOrCreateParent(o.path.parent(), nodeMap); + parent.addChild(new ReportNode(o.path, o.fileCoverage)); + }); + + return Object.values(nodeMap); +} + +function addAllPaths(topPaths, nodeMap, path, node) { + const parent = findOrCreateParent( + path.parent(), + nodeMap, + (parentPath, parent) => { + if (parentPath.hasParent()) { + addAllPaths(topPaths, nodeMap, parentPath, parent); + } else { + topPaths.push(parent); + } + }, + ); + + parent.addChild(node); +} + +function foldIntoOneDir(node, parent) { + const { children } = node; + if (children.length === 1 && !children[0].fileCoverage) { + children[0].parent = parent; + return foldIntoOneDir(children[0], parent); + } + node.children = children.map((child) => foldIntoOneDir(child, node)); + return node; +} + +function pkgSummaryPrefix(dirParents, commonParent) { + if (!dirParents.some((dp) => dp.path.length === 0)) { + return; + } + + if (commonParent.length === 0) { + return "root"; + } + + return commonParent.name(); +} + +class SummarizerFactory { + constructor(coverageMap, defaultSummarizer = "pkg") { + this._coverageMap = coverageMap; + this._defaultSummarizer = defaultSummarizer; + this._initialList = coverageMap.files().map((filePath) => ({ + filePath, + path: new Path(filePath), + fileCoverage: coverageMap.fileCoverageFor(filePath), + })); + this._commonParent = findCommonParent( + this._initialList.map((o) => o.path.parent()), + ); + if (this._commonParent.length > 0) { + this._initialList.forEach((o) => { + o.path.splice(0, this._commonParent.length); + }); + } + } + + get defaultSummarizer() { + return this[this._defaultSummarizer]; + } + + get flat() { + if (!this._flat) { + this._flat = new ReportTree( + ReportNode.createRoot( + this._initialList.map( + (node) => new ReportNode(node.path, node.fileCoverage), + ), + ), + ); + } + + return this._flat; + } + + _createPkg() { + const dirParents = toDirParents(this._initialList); + if (dirParents.length === 1) { + return new ReportTree(dirParents[0]); + } + + return new ReportTree( + ReportNode.createRoot(dirParents), + pkgSummaryPrefix(dirParents, this._commonParent), + ); + } + + get pkg() { + if (!this._pkg) { + this._pkg = this._createPkg(); + } + + return this._pkg; + } + + _createNested() { + const nodeMap = Object.create(null); + const topPaths = []; + this._initialList.forEach((o) => { + const node = new ReportNode(o.path, o.fileCoverage); + addAllPaths(topPaths, nodeMap, o.path, node); + }); + + const topNodes = topPaths.map((node) => foldIntoOneDir(node)); + if (topNodes.length === 1) { + return new ReportTree(topNodes[0]); + } + + return new ReportTree(ReportNode.createRoot(topNodes)); + } + + get nested() { + if (!this._nested) { + this._nested = this._createNested(); + } + + return this._nested; + } +} + +module.exports = SummarizerFactory; diff --git a/v-next/hardhat/assets/lib-report/lib/tree.cjs b/v-next/hardhat/assets/lib-report/lib/tree.cjs new file mode 100644 index 00000000000..6bac8b98ea4 --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/tree.cjs @@ -0,0 +1,137 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * An object with methods that are called during the traversal of the coverage tree. + * A visitor has the following methods that are called during tree traversal. + * + * * `onStart(root, state)` - called before traversal begins + * * `onSummary(node, state)` - called for every summary node + * * `onDetail(node, state)` - called for every detail node + * * `onSummaryEnd(node, state)` - called after all children have been visited for + * a summary node. + * * `onEnd(root, state)` - called after traversal ends + * + * @param delegate - a partial visitor that only implements the methods of interest + * The visitor object supplies the missing methods as noops. For example, reports + * that only need the final coverage summary need implement `onStart` and nothing + * else. Reports that use only detailed coverage information need implement `onDetail` + * and nothing else. + * @constructor + */ +class Visitor { + constructor(delegate) { + this.delegate = delegate; + } +} + +["Start", "End", "Summary", "SummaryEnd", "Detail"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(Visitor.prototype, fn, { + writable: true, + value(node, state) { + if (typeof this.delegate[fn] === "function") { + this.delegate[fn](node, state); + } + }, + }); + }); + +class CompositeVisitor extends Visitor { + constructor(visitors) { + super(); + + if (!Array.isArray(visitors)) { + visitors = [visitors]; + } + this.visitors = visitors.map((v) => { + if (v instanceof Visitor) { + return v; + } + return new Visitor(v); + }); + } +} + +["Start", "Summary", "SummaryEnd", "Detail", "End"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(CompositeVisitor.prototype, fn, { + value(node, state) { + this.visitors.forEach((v) => { + v[fn](node, state); + }); + }, + }); + }); + +class BaseNode { + isRoot() { + return !this.getParent(); + } + + /** + * visit all nodes depth-first from this node down. Note that `onStart` + * and `onEnd` are never called on the visitor even if the current + * node is the root of the tree. + * @param visitor a full visitor that is called during tree traversal + * @param state optional state that is passed around + */ + visit(visitor, state) { + if (this.isSummary()) { + visitor.onSummary(this, state); + } else { + visitor.onDetail(this, state); + } + + this.getChildren().forEach((child) => { + child.visit(visitor, state); + }); + + if (this.isSummary()) { + visitor.onSummaryEnd(this, state); + } + } +} + +/** + * abstract base class for a coverage tree. + * @constructor + */ +class BaseTree { + constructor(root) { + this.root = root; + } + + /** + * returns the root node of the tree + */ + getRoot() { + return this.root; + } + + /** + * visits the tree depth-first with the supplied partial visitor + * @param visitor - a potentially partial visitor + * @param state - the state to be passed around during tree traversal + */ + visit(visitor, state) { + if (!(visitor instanceof Visitor)) { + visitor = new Visitor(visitor); + } + visitor.onStart(this.getRoot(), state); + this.getRoot().visit(visitor, state); + visitor.onEnd(this.getRoot(), state); + } +} + +module.exports = { + BaseTree, + BaseNode, + Visitor, + CompositeVisitor, +}; diff --git a/v-next/hardhat/assets/lib-report/lib/watermarks.cjs b/v-next/hardhat/assets/lib-report/lib/watermarks.cjs new file mode 100644 index 00000000000..0be610017a9 --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/watermarks.cjs @@ -0,0 +1,15 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +module.exports = { + getDefault() { + return { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], + }; + }, +}; diff --git a/v-next/hardhat/assets/lib-report/lib/xml-writer.cjs b/v-next/hardhat/assets/lib-report/lib/xml-writer.cjs new file mode 100644 index 00000000000..aea68a1b53f --- /dev/null +++ b/v-next/hardhat/assets/lib-report/lib/xml-writer.cjs @@ -0,0 +1,90 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const INDENT = " "; + +function attrString(attrs) { + return Object.entries(attrs || {}) + .map(([k, v]) => ` ${k}="${v}"`) + .join(""); +} + +/** + * a utility class to produce well-formed, indented XML + * @param {ContentWriter} contentWriter the content writer that this utility wraps + * @constructor + */ +class XMLWriter { + constructor(contentWriter) { + this.cw = contentWriter; + this.stack = []; + } + + indent(str) { + return this.stack.map(() => INDENT).join("") + str; + } + + /** + * writes the opening XML tag with the supplied attributes + * @param {String} name tag name + * @param {Object} [attrs=null] attrs attributes for the tag + */ + openTag(name, attrs) { + const str = this.indent(`<${name + attrString(attrs)}>`); + this.cw.println(str); + this.stack.push(name); + } + + /** + * closes an open XML tag. + * @param {String} name - tag name to close. This must match the writer's + * notion of the tag that is currently open. + */ + closeTag(name) { + if (this.stack.length === 0) { + throw new Error(`Attempt to close tag ${name} when not opened`); + } + const stashed = this.stack.pop(); + const str = ``; + + if (stashed !== name) { + throw new Error( + `Attempt to close tag ${name} when ${stashed} was the one open`, + ); + } + this.cw.println(this.indent(str)); + } + + /** + * writes a tag and its value opening and closing it at the same time + * @param {String} name tag name + * @param {Object} [attrs=null] attrs tag attributes + * @param {String} [content=null] content optional tag content + */ + inlineTag(name, attrs, content) { + let str = "<" + name + attrString(attrs); + if (content) { + str += `>${content}`; + } else { + str += "/>"; + } + str = this.indent(str); + this.cw.println(str); + } + + /** + * closes all open tags and ends the document + */ + closeAll() { + this.stack + .slice() + .reverse() + .forEach((name) => { + this.closeTag(name); + }); + } +} + +module.exports = XMLWriter; diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index e8cbe5b089f..82f34eb86c1 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -25,7 +25,7 @@ import debug from "debug"; // Report // // import libCoverage from "istanbul-lib-coverage"; -import libReport from "istanbul-lib-report"; +// import libReport from "istanbul-lib-report"; import reports from "istanbul-reports"; const log = debug("hardhat:core:coverage:coverage-manager"); @@ -136,7 +136,10 @@ export class CoverageManagerImplementation implements CoverageManager { const treatUnlisted = false; // treatUnlistedLinesAsUncovered const packageRoot = await findClosestPackageRoot(import.meta.url); - const { default: libCoverage } = await import( + const { libCoverage } = await import( + path.join(packageRoot, "assets", "index.js") + ); + const { libReport } = await import( path.join(packageRoot, "assets", "index.js") ); @@ -195,8 +198,11 @@ export class CoverageManagerImplementation implements CoverageManager { } fs.mkdirSync(outDir, { recursive: true }); + const context = libReport.createContext({ dir: outDir, coverageMap }); + reports.create(reporter).execute(context); + console.log(`HTML report written to ${path.resolve(outDir)}`); } From 4dae722705f8d7526515250fbf019937983406c7 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:17:50 +0200 Subject: [PATCH 04/32] report --- v-next/hardhat/assets/index.js | 3 + .../hardhat/assets/istanbul-reports/index.cjs | 24 + .../istanbul-reports/lib/html/annotator.cjs | 294 +++++++++++++ .../istanbul-reports/lib/html/assets/base.css | 224 ++++++++++ .../lib/html/assets/block-navigation.js | 86 ++++ .../lib/html/assets/favicon.png | Bin 0 -> 445 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../lib/html/assets/sorter.js | 209 +++++++++ .../lib/html/assets/vendor/prettify.css | 1 + .../lib/html/assets/vendor/prettify.js | 1 + .../istanbul-reports/lib/html/index.cjs | 409 ++++++++++++++++++ .../lib/html/insertion-text.cjs | 114 +++++ .../coverage/coverage-manager.ts | 7 +- 13 files changed, 1370 insertions(+), 2 deletions(-) create mode 100644 v-next/hardhat/assets/istanbul-reports/index.cjs create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/favicon.png create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/sort-arrow-sprite.png create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs create mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs diff --git a/v-next/hardhat/assets/index.js b/v-next/hardhat/assets/index.js index 3a59ef0c6ad..e77664e0c22 100644 --- a/v-next/hardhat/assets/index.js +++ b/v-next/hardhat/assets/index.js @@ -3,3 +3,6 @@ export { libCoverage }; import libReport from "./lib-report/index.cjs"; export { libReport }; + +import reports from "./istanbul-reports/index.cjs"; +export { reports }; diff --git a/v-next/hardhat/assets/istanbul-reports/index.cjs b/v-next/hardhat/assets/istanbul-reports/index.cjs new file mode 100644 index 00000000000..b3b8cb7d312 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/index.cjs @@ -0,0 +1,24 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("path"); + +module.exports = { + create(name, cfg) { + cfg = cfg || {}; + let Cons; + try { + Cons = require(path.join(__dirname, "lib", name, "index.cjs")); + } catch (e) { + if (e.code !== "MODULE_NOT_FOUND") { + throw e; + } + + Cons = require(name); + } + + return new Cons(cfg); + }, +}; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs new file mode 100644 index 00000000000..a9b47a7380a --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs @@ -0,0 +1,294 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const InsertionText = require("./insertion-text.cjs"); +const lt = "\u0001"; +const gt = "\u0002"; +const RE_LT = //g; +const RE_AMP = /&/g; + +var RE_lt = /\u0001/g; + +var RE_gt = /\u0002/g; + +function title(str) { + return ' title="' + str + '" '; +} + +function customEscape(text) { + text = String(text); + return text + .replace(RE_AMP, "&") + .replace(RE_LT, "<") + .replace(RE_GT, ">") + .replace(RE_lt, "<") + .replace(RE_gt, ">"); +} + +function annotateLines(fileCoverage, structuredText) { + const lineStats = fileCoverage.getLineCoverage(); + if (!lineStats) { + return; + } + Object.entries(lineStats).forEach(([lineNumber, count]) => { + if (structuredText[lineNumber]) { + structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; + structuredText[lineNumber].hits = count; + } + }); +} + +function annotateStatements(fileCoverage, structuredText) { + const statementStats = fileCoverage.s; + const statementMeta = fileCoverage.statementMap; + Object.entries(statementStats).forEach(([stName, count]) => { + const meta = statementMeta[stName]; + const type = count > 0 ? "yes" : "no"; + const startCol = meta.start.column; + let endCol = meta.end.column + 1; + const startLine = meta.start.line; + const endLine = meta.end.line; + const openSpan = + lt + + 'span class="' + + (meta.skip ? "cstat-skip" : "cstat-no") + + '"' + + title("statement not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + }); +} + +function annotateFunctions(fileCoverage, structuredText) { + const fnStats = fileCoverage.f; + const fnMeta = fileCoverage.fnMap; + if (!fnStats) { + return; + } + Object.entries(fnStats).forEach(([fName, count]) => { + const meta = fnMeta[fName]; + const type = count > 0 ? "yes" : "no"; + // Some versions of the instrumenter in the wild populate 'func' + // but not 'decl': + const decl = meta.decl || meta.loc; + const startCol = decl.start.column; + let endCol = decl.end.column + 1; + const startLine = decl.start.line; + const endLine = decl.end.line; + const openSpan = + lt + + 'span class="' + + (meta.skip ? "fstat-skip" : "fstat-no") + + '"' + + title("function not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + }); +} + +function annotateBranches(fileCoverage, structuredText) { + const branchStats = fileCoverage.b; + const branchMeta = fileCoverage.branchMap; + if (!branchStats) { + return; + } + + Object.entries(branchStats).forEach(([branchName, branchArray]) => { + const sumCount = branchArray.reduce((p, n) => p + n, 0); + const metaArray = branchMeta[branchName].locations; + let i; + let count; + let meta; + let startCol; + let endCol; + let startLine; + let endLine; + let openSpan; + let closeSpan; + let text; + + // only highlight if partial branches are missing or if there is a + // single uncovered branch. + if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { + // Need to recover the metaArray placeholder item to count an implicit else + if ( + // Check if the branch is a conditional if branch. + branchMeta[branchName].type === "if" && + // Check if the branch has an implicit else. + branchArray.length === 2 && + // Check if the implicit else branch is unaccounted for. + metaArray.length === 1 && + // Check if the implicit else branch is uncovered. + branchArray[1] === 0 + ) { + metaArray[1] = { + start: {}, + end: {}, + }; + } + + for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { + count = branchArray[i]; + meta = metaArray[i]; + startCol = meta.start.column; + endCol = meta.end.column + 1; + startLine = meta.start.line; + endLine = meta.end.line; + openSpan = + lt + + 'span class="branch-' + + i + + " " + + (meta.skip ? "cbranch-skip" : "cbranch-no") + + '"' + + title("branch not covered") + + gt; + closeSpan = lt + "/span" + gt; + + // If the branch is an implicit else from an if statement, + // then the coverage report won't show a statistic. + // Therefore, the previous branch will be used to report that + // there is no coverage on that implicit branch. + if ( + count === 0 && + startLine === undefined && + branchMeta[branchName].type === "if" + ) { + const prevMeta = metaArray[i - 1]; + startCol = prevMeta.start.column; + endCol = prevMeta.end.column + 1; + startLine = prevMeta.start.line; + endLine = prevMeta.end.line; + } + + if (count === 0 && structuredText[startLine]) { + //skip branches taken + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + if (branchMeta[branchName].type === "if") { + // 'if' is a special case + // since the else branch might not be visible, being nonexistent + text.insertAt( + startCol, + lt + + 'span class="' + + (meta.skip ? "skip-if-branch" : "missing-if-branch") + + '"' + + title((i === 0 ? "if" : "else") + " path not taken") + + gt + + (i === 0 ? "I" : "E") + + lt + + "/span" + + gt, + true, + false, + ); + } else { + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + } + } + } + }); +} + +function annotateSourceCode(fileCoverage, sourceStore) { + let codeArray; + let lineCoverageArray; + try { + const sourceText = sourceStore.getSource(fileCoverage.path); + const code = sourceText.split(/(?:\r?\n)|\r/); + let count = 0; + const structured = code.map((str) => { + count += 1; + return { + line: count, + covered: "neutral", + hits: 0, + text: new InsertionText(str, true), + }; + }); + structured.unshift({ + line: 0, + covered: null, + text: new InsertionText(""), + }); + annotateLines(fileCoverage, structured); + //note: order is important, since statements typically result in spanning the whole line and doing branches late + //causes mismatched tags + annotateBranches(fileCoverage, structured); + annotateFunctions(fileCoverage, structured); + annotateStatements(fileCoverage, structured); + structured.shift(); + + codeArray = structured.map( + (item) => customEscape(item.text.toString()) || " ", + ); + + lineCoverageArray = structured.map((item) => ({ + covered: item.covered, + hits: item.hits > 0 ? item.hits + "x" : " ", + })); + + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: structured.length, + }; + } catch (ex) { + codeArray = [ex.message]; + lineCoverageArray = [{ covered: "no", hits: 0 }]; + String(ex.stack || "") + .split(/\r?\n/) + .forEach((line) => { + codeArray.push(line); + lineCoverageArray.push({ covered: "no", hits: 0 }); + }); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: codeArray.length, + }; + } +} + +module.exports = annotateSourceCode; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css new file mode 100644 index 00000000000..f418035b469 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js new file mode 100644 index 00000000000..eb527848ee7 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js @@ -0,0 +1,86 @@ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js new file mode 100644 index 00000000000..83122f78ace --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js @@ -0,0 +1,209 @@ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css new file mode 100644 index 00000000000..b317a7cda31 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js new file mode 100644 index 00000000000..ef51e038668 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs new file mode 100644 index 00000000000..a1887b2ad35 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs @@ -0,0 +1,409 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("fs"); +const path = require("path"); +const html = require("html-escaper"); +const { ReportBase } = require("istanbul-lib-report"); +const annotator = require("./annotator.cjs"); + +function htmlHead(details) { + return ` + + Code coverage report for ${html.escape(details.entity)} + + + + + + + + `; +} + +function headerTemplate(details) { + function metricsTemplate({ pct, covered, total }, kind) { + return ` +
+ ${pct}% + ${kind} + ${covered}/${total} +
+ `; + } + + function skipTemplate(metrics) { + const statements = metrics.statements.skipped; + const branches = metrics.branches.skipped; + const functions = metrics.functions.skipped; + + const countLabel = (c, label, plural) => + c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; + const skips = [].concat( + countLabel(statements, "statement", "s"), + countLabel(functions, "function", "s"), + countLabel(branches, "branch", "es"), + ); + + if (skips.length === 0) { + return ""; + } + + return ` +
+ ${skips.join(", ")} + Ignored      +
+ `; + } + + return ` + + +${htmlHead(details)} + +
+
+

${details.pathHtml}

+
+ ${metricsTemplate(details.metrics.statements, "Statements")} + ${metricsTemplate(details.metrics.branches, "Branches")} + ${metricsTemplate(details.metrics.functions, "Functions")} + ${metricsTemplate(details.metrics.lines, "Lines")} + ${skipTemplate(details.metrics)} +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+ `; +} + +function footerTemplate(details) { + return ` +
+
+ + + + + + + + `; +} + +function detailTemplate(data) { + const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); + const lineLink = (num) => + `${num}`; + const lineCount = (line) => + `${line.hits}`; + + /* This is rendered in a `
`, need control of all whitespace. */
+  return [
+    "",
+    `${lineNumbers.map(lineLink).join("\n")}`,
+    `${data.lineCoverage
+      .map(lineCount)
+      .join("\n")}`,
+    `
${data.annotatedCode.join(
+      "\n",
+    )}
`, + "", + ].join(""); +} +const summaryTableHeader = [ + '
', + '', + "", + "", + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + "", + "", + "", +].join("\n"); + +function summaryLineTemplate(details) { + const { reportClasses, metrics, file, output } = details; + const percentGraph = (pct) => { + if (!isFinite(pct)) { + return ""; + } + + const cls = ["cover-fill"]; + if (pct === 100) { + cls.push("cover-full"); + } + + pct = Math.floor(pct); + return [ + `
`, + `
`, + ].join(""); + }; + const summaryType = (type, showGraph = false) => { + const info = metrics[type]; + const reportClass = reportClasses[type]; + const result = [ + ``, + ``, + ]; + if (showGraph) { + result.unshift( + ``, + ); + } + + return result; + }; + + return [] + .concat( + "", + ``, + summaryType("statements", true), + summaryType("branches"), + summaryType("functions"), + summaryType("lines"), + "\n", + ) + .join("\n\t"); +} + +const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, + `
${percentGraph(info.pct)}
`, + `
${html.escape(file)}
", "
"].join("\n"); +const emptyClasses = { + statements: "empty", + lines: "empty", + functions: "empty", + branches: "empty", +}; + +const standardLinkMapper = { + getPath(node) { + if (typeof node === "string") { + return node; + } + let filePath = node.getQualifiedName(); + if (node.isSummary()) { + if (filePath !== "") { + filePath += "/index.html"; + } else { + filePath = "index.html"; + } + } else { + filePath += ".html"; + } + return filePath; + }, + + relativePath(source, target) { + const targetPath = this.getPath(target); + const sourcePath = path.dirname(this.getPath(source)); + return path.posix.relative(sourcePath, targetPath); + }, + + assetPath(node, name) { + return this.relativePath(this.getPath(node), name); + }, +}; + +function fixPct(metrics) { + Object.keys(emptyClasses).forEach((key) => { + metrics[key].pct = 0; + }); + return metrics; +} + +class HtmlReport extends ReportBase { + constructor(opts) { + super(); + + this.verbose = opts.verbose; + this.linkMapper = opts.linkMapper || standardLinkMapper; + this.subdir = opts.subdir || ""; + this.date = new Date().toISOString(); + this.skipEmpty = opts.skipEmpty; + } + + getBreadcrumbHtml(node) { + let parent = node.getParent(); + const nodePath = []; + + while (parent) { + nodePath.push(parent); + parent = parent.getParent(); + } + + const linkPath = nodePath.map((ancestor) => { + const target = this.linkMapper.relativePath(node, ancestor); + const name = ancestor.getRelativeName() || "All files"; + return '' + name + ""; + }); + + linkPath.reverse(); + return linkPath.length > 0 + ? linkPath.join(" / ") + " " + node.getRelativeName() + : "All files"; + } + + fillTemplate(node, templateData, context) { + const linkMapper = this.linkMapper; + const summary = node.getCoverageSummary(); + templateData.entity = node.getQualifiedName() || "All files"; + templateData.metrics = summary; + templateData.reportClass = context.classForPercent( + "statements", + summary.statements.pct, + ); + templateData.pathHtml = this.getBreadcrumbHtml(node); + templateData.base = { + css: linkMapper.assetPath(node, "base.css"), + }; + templateData.sorter = { + js: linkMapper.assetPath(node, "sorter.js"), + image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), + }; + templateData.blockNavigation = { + js: linkMapper.assetPath(node, "block-navigation.js"), + }; + templateData.prettify = { + js: linkMapper.assetPath(node, "prettify.js"), + css: linkMapper.assetPath(node, "prettify.css"), + }; + templateData.favicon = linkMapper.assetPath(node, "favicon.png"); + } + + getTemplateData() { + return { datetime: this.date }; + } + + getWriter(context) { + if (!this.subdir) { + return context.writer; + } + return context.writer.writerForDir(this.subdir); + } + + onStart(root, context) { + const assetHeaders = { + ".js": "/* eslint-disable */\n", + }; + + [".", "vendor"].forEach((subdir) => { + const writer = this.getWriter(context); + const srcDir = path.resolve(__dirname, "assets", subdir); + fs.readdirSync(srcDir).forEach((f) => { + const resolvedSource = path.resolve(srcDir, f); + const resolvedDestination = "."; + const stat = fs.statSync(resolvedSource); + let dest; + + if (stat.isFile()) { + dest = resolvedDestination + "/" + f; + if (this.verbose) { + console.log("Write asset: " + dest); + } + writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); + } + }); + }); + } + + onSummary(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + const children = node.getChildren(); + const skipEmpty = this.skipEmpty; + + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write(summaryTableHeader); + children.forEach((child) => { + const metrics = child.getCoverageSummary(); + const isEmpty = metrics.isEmpty(); + if (skipEmpty && isEmpty) { + return; + } + const reportClasses = isEmpty + ? emptyClasses + : { + statements: context.classForPercent( + "statements", + metrics.statements.pct, + ), + lines: context.classForPercent("lines", metrics.lines.pct), + functions: context.classForPercent( + "functions", + metrics.functions.pct, + ), + branches: context.classForPercent("branches", metrics.branches.pct), + }; + const data = { + metrics: isEmpty ? fixPct(metrics) : metrics, + reportClasses, + file: child.getRelativeName(), + output: linkMapper.relativePath(node, child), + }; + cw.write(summaryLineTemplate(data) + "\n"); + }); + cw.write(summaryTableFooter); + cw.write(footerTemplate(templateData)); + cw.close(); + } + + onDetail(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write('
\n');
+    cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
+    cw.write("
\n"); + cw.write(footerTemplate(templateData)); + cw.close(); + } +} + +module.exports = HtmlReport; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs new file mode 100644 index 00000000000..6f8064245c2 --- /dev/null +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs @@ -0,0 +1,114 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +function InsertionText(text, consumeBlanks) { + this.text = text; + this.origLength = text.length; + this.offsets = []; + this.consumeBlanks = consumeBlanks; + this.startPos = this.findFirstNonBlank(); + this.endPos = this.findLastNonBlank(); +} + +const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; + +InsertionText.prototype = { + findFirstNonBlank() { + let pos = -1; + const text = this.text; + const len = text.length; + let i; + for (i = 0; i < len; i += 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + findLastNonBlank() { + const text = this.text; + const len = text.length; + let pos = text.length + 1; + let i; + for (i = len - 1; i >= 0; i -= 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + originalLength() { + return this.origLength; + }, + + insertAt(col, str, insertBefore, consumeBlanks) { + consumeBlanks = + typeof consumeBlanks === 'undefined' + ? this.consumeBlanks + : consumeBlanks; + col = col > this.originalLength() ? this.originalLength() : col; + col = col < 0 ? 0 : col; + + if (consumeBlanks) { + if (col <= this.startPos) { + col = 0; + } + if (col > this.endPos) { + col = this.origLength; + } + } + + const len = str.length; + const offset = this.findOffset(col, len, insertBefore); + const realPos = col + offset; + const text = this.text; + this.text = text.substring(0, realPos) + str + text.substring(realPos); + return this; + }, + + findOffset(pos, len, insertBefore) { + const offsets = this.offsets; + let offsetObj; + let cumulativeOffset = 0; + let i; + + for (i = 0; i < offsets.length; i += 1) { + offsetObj = offsets[i]; + if ( + offsetObj.pos < pos || + (offsetObj.pos === pos && !insertBefore) + ) { + cumulativeOffset += offsetObj.len; + } + if (offsetObj.pos >= pos) { + break; + } + } + if (offsetObj && offsetObj.pos === pos) { + offsetObj.len += len; + } else { + offsets.splice(i, 0, { pos, len }); + } + return cumulativeOffset; + }, + + wrap(startPos, startText, endPos, endText, consumeBlanks) { + this.insertAt(startPos, startText, true, consumeBlanks); + this.insertAt(endPos, endText, false, consumeBlanks); + return this; + }, + + wrapLine(startText, endText) { + this.wrap(0, startText, this.originalLength(), endText); + }, + + toString() { + return this.text; + } +}; + +module.exports = InsertionText; diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index 82f34eb86c1..75f6538d6b3 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -26,7 +26,7 @@ import debug from "debug"; // // import libCoverage from "istanbul-lib-coverage"; // import libReport from "istanbul-lib-report"; -import reports from "istanbul-reports"; +// import reports from "istanbul-reports"; const log = debug("hardhat:core:coverage:coverage-manager"); @@ -129,7 +129,7 @@ export class CoverageManagerImplementation implements CoverageManager { } async #lcovToHtml(report: Report): Promise { - const reporter: "html" | "html-spa" = "html-spa"; + const reporter: "html" | "html-spa" = "html"; const outDir = "coverage/html"; const baseDir = process.cwd(); @@ -142,6 +142,9 @@ export class CoverageManagerImplementation implements CoverageManager { const { libReport } = await import( path.join(packageRoot, "assets", "index.js") ); + const { reports } = await import( + path.join(packageRoot, "assets", "index.js") + ); const coverageMap = libCoverage.createCoverageMap({}); From d002919b10bc80e7f7fea803192a188591ff68b8 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:36:59 +0200 Subject: [PATCH 05/32] remove dependencies from istanbul in coverage-manager --- .../internal/builtin-plugins/coverage/coverage-manager.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index 75f6538d6b3..2b8e8d2888f 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -21,12 +21,6 @@ import { } from "@nomicfoundation/hardhat-utils/fs"; import { findClosestPackageRoot } from "@nomicfoundation/hardhat-utils/package"; import debug from "debug"; -// -// Report -// -// import libCoverage from "istanbul-lib-coverage"; -// import libReport from "istanbul-lib-report"; -// import reports from "istanbul-reports"; const log = debug("hardhat:core:coverage:coverage-manager"); @@ -129,7 +123,7 @@ export class CoverageManagerImplementation implements CoverageManager { } async #lcovToHtml(report: Report): Promise { - const reporter: "html" | "html-spa" = "html"; + const reporter: "html" = "html"; const outDir = "coverage/html"; const baseDir = process.cwd(); From 95f8d9ac6264867ed6af21739cebc8120de897ee Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:37:22 +0200 Subject: [PATCH 06/32] add 'node:' to imports --- v-next/hardhat/assets/istanbul-reports/index.cjs | 2 +- v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs | 4 ++-- v-next/hardhat/assets/lib-report/lib/context.cjs | 2 +- v-next/hardhat/assets/lib-report/lib/file-writer.cjs | 4 ++-- v-next/hardhat/assets/lib-report/lib/path.cjs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/v-next/hardhat/assets/istanbul-reports/index.cjs b/v-next/hardhat/assets/istanbul-reports/index.cjs index b3b8cb7d312..7db2b63fa9f 100644 --- a/v-next/hardhat/assets/istanbul-reports/index.cjs +++ b/v-next/hardhat/assets/istanbul-reports/index.cjs @@ -3,7 +3,7 @@ Copyright 2012-2015, Yahoo Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -const path = require("path"); +const path = require("node:path"); module.exports = { create(name, cfg) { diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs index a1887b2ad35..e0029172713 100644 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs @@ -3,8 +3,8 @@ Copyright 2012-2015, Yahoo Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -const fs = require("fs"); -const path = require("path"); +const fs = require("node:fs"); +const path = require("node:path"); const html = require("html-escaper"); const { ReportBase } = require("istanbul-lib-report"); const annotator = require("./annotator.cjs"); diff --git a/v-next/hardhat/assets/lib-report/lib/context.cjs b/v-next/hardhat/assets/lib-report/lib/context.cjs index 34df8cf5ea2..92ab1478486 100644 --- a/v-next/hardhat/assets/lib-report/lib/context.cjs +++ b/v-next/hardhat/assets/lib-report/lib/context.cjs @@ -3,7 +3,7 @@ Copyright 2012-2015, Yahoo Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -const fs = require("fs"); +const fs = require("node:fs"); const FileWriter = require("./file-writer.cjs"); const XMLWriter = require("./xml-writer.cjs"); const tree = require("./tree.cjs"); diff --git a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs index 45e594187ee..9cc593b8aa8 100644 --- a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs +++ b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs @@ -3,8 +3,8 @@ Copyright 2012-2015, Yahoo Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -const path = require("path"); -const fs = require("fs"); +const path = require("node:path"); +const fs = require("node:fs"); const mkdirp = require("make-dir"); const supportsColor = require("supports-color"); diff --git a/v-next/hardhat/assets/lib-report/lib/path.cjs b/v-next/hardhat/assets/lib-report/lib/path.cjs index cec0606f764..89f8033883b 100644 --- a/v-next/hardhat/assets/lib-report/lib/path.cjs +++ b/v-next/hardhat/assets/lib-report/lib/path.cjs @@ -4,7 +4,7 @@ */ "use strict"; -const path = require("path"); +const path = require("node:path"); let parsePath = path.parse; let SEP = path.sep; const origParser = parsePath; From f3e276fa622ab11b931b4f773cac598471477cab Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:25:47 +0200 Subject: [PATCH 07/32] replace import to istanbul with internal assets --- v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs | 2 +- v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs index e0029172713..5e8c13aab08 100644 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs @@ -6,7 +6,7 @@ const fs = require("node:fs"); const path = require("node:path"); const html = require("html-escaper"); -const { ReportBase } = require("istanbul-lib-report"); +const ReportBase = require("../../../lib-report/lib/report-base.cjs"); const annotator = require("./annotator.cjs"); function htmlHead(details) { diff --git a/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs index 1128e0cdaf1..cb2c429bc9a 100644 --- a/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs +++ b/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs @@ -4,7 +4,7 @@ */ "use strict"; -const coverage = require("istanbul-lib-coverage"); +const coverage = require("../../lib-coverage/index.cjs"); const Path = require("./path.cjs"); const { BaseNode, BaseTree } = require("./tree.cjs"); From c77eb8d1c65c13154054bd78968c8580e3fca949 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:26:08 +0200 Subject: [PATCH 08/32] remove unused library --- v-next/hardhat/assets/lib-report/lib/file-writer.cjs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs index 9cc593b8aa8..a1397c49e7f 100644 --- a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs +++ b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs @@ -6,7 +6,6 @@ const path = require("node:path"); const fs = require("node:fs"); const mkdirp = require("make-dir"); -const supportsColor = require("supports-color"); /** * Base class for writing content @@ -88,10 +87,6 @@ class ConsoleWriter extends ContentWriter { high: "32;1", }; - /* istanbul ignore next: different modes for CI and local */ - if (supportsColor.stdout && colors[clazz]) { - return `\u001b[${colors[clazz]}m${str}\u001b[0m`; - } return str; } } From 7771d9ff0c105fede325331e668827d0b19ccf9f Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:32:27 +0200 Subject: [PATCH 09/32] replace html escape package --- v-next/hardhat/assets/html-escaper/index.cjs | 24 +++++++++++++++++++ .../istanbul-reports/lib/html/index.cjs | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 v-next/hardhat/assets/html-escaper/index.cjs diff --git a/v-next/hardhat/assets/html-escaper/index.cjs b/v-next/hardhat/assets/html-escaper/index.cjs new file mode 100644 index 00000000000..d823b800faf --- /dev/null +++ b/v-next/hardhat/assets/html-escaper/index.cjs @@ -0,0 +1,24 @@ +const { replace } = ""; + +// escape +const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; +const ca = /[&<>'"]/g; + +const esca = { + "&": "&", + "<": "<", + ">": ">", + "'": "'", + '"': """, +}; +const pe = (m) => esca[m]; + +/** + * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. + * @param {string} es the input to safely escape + * @returns {string} the escaped input, and it **throws** an error if + * the input type is unexpected, except for boolean and numbers, + * converted as string. + */ +const escape = (es) => replace.call(es, ca, pe); +exports.escape = escape; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs index 5e8c13aab08..a958877e7f2 100644 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs +++ b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs @@ -5,7 +5,7 @@ */ const fs = require("node:fs"); const path = require("node:path"); -const html = require("html-escaper"); +const html = require("../../../html-escaper/index.cjs"); const ReportBase = require("../../../lib-report/lib/report-base.cjs"); const annotator = require("./annotator.cjs"); From 029bc262b5c03bfb34ba5b7e3dce81b0ae9c3137 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:38:08 +0200 Subject: [PATCH 10/32] replace make-dir with fs/promises --- v-next/hardhat/assets/lib-report/lib/file-writer.cjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs index a1397c49e7f..658de8f06f8 100644 --- a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs +++ b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs @@ -5,7 +5,7 @@ */ const path = require("node:path"); const fs = require("node:fs"); -const mkdirp = require("make-dir"); +const { mkdir } = require("node:fs/promises"); /** * Base class for writing content @@ -152,7 +152,7 @@ class FileWriter { throw new Error(`Cannot write to absolute path: ${dest}`); } dest = path.resolve(this.baseDir, dest); - mkdirp.sync(path.dirname(dest)); + mkdir(path.dirname(dest), { recursive: true }); let contents; if (header) { contents = header + fs.readFileSync(source, "utf8"); @@ -176,7 +176,7 @@ class FileWriter { throw new Error(`Cannot write to absolute path: ${file}`); } file = path.resolve(this.baseDir, file); - mkdirp.sync(path.dirname(file)); + mkdir(path.dirname(file), { recursive: true }); return new FileContentWriter(fs.openSync(file, "w")); } } From 9be67d555feb6811ed740a1daf10e95078fc8684 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:44:08 +0200 Subject: [PATCH 11/32] remove dependencies from istanbul npm packages --- pnpm-lock.yaml | 32 ------------------ v-next/hardhat/assets/lib-coverage/index.d.ts | 33 +++++++++++++++++++ v-next/hardhat/package.json | 6 ---- .../coverage/coverage-manager.ts | 2 +- 4 files changed, 34 insertions(+), 39 deletions(-) create mode 100644 v-next/hardhat/assets/lib-coverage/index.d.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02b6c610df4..21245c14f31 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -161,15 +161,6 @@ importers: '@sentry/core': specifier: ^9.4.0 version: 9.46.0 - '@types/istanbul-lib-coverage': - specifier: ^2.0.6 - version: 2.0.6 - '@types/istanbul-lib-report': - specifier: ^3.0.3 - version: 3.0.3 - '@types/istanbul-reports': - specifier: ^3.0.4 - version: 3.0.4 adm-zip: specifier: ^0.4.16 version: 0.4.16 @@ -188,15 +179,6 @@ importers: ethereum-cryptography: specifier: ^2.2.1 version: 2.2.1 - istanbul-lib-coverage: - specifier: ^3.2.2 - version: 3.2.2 - istanbul-lib-report: - specifier: ^3.0.1 - version: 3.0.1 - istanbul-reports: - specifier: ^3.2.0 - version: 3.2.0 micro-eth-signer: specifier: ^0.14.0 version: 0.14.0 @@ -2865,12 +2847,6 @@ packages: '@types/istanbul-lib-coverage@2.0.6': resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} - '@types/istanbul-lib-report@3.0.3': - resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} - - '@types/istanbul-reports@3.0.4': - resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} - '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -6796,14 +6772,6 @@ snapshots: '@types/istanbul-lib-coverage@2.0.6': {} - '@types/istanbul-lib-report@3.0.3': - dependencies: - '@types/istanbul-lib-coverage': 2.0.6 - - '@types/istanbul-reports@3.0.4': - dependencies: - '@types/istanbul-lib-report': 3.0.3 - '@types/json-schema@7.0.15': {} '@types/json5@0.0.29': {} diff --git a/v-next/hardhat/assets/lib-coverage/index.d.ts b/v-next/hardhat/assets/lib-coverage/index.d.ts new file mode 100644 index 00000000000..33e9f5b5655 --- /dev/null +++ b/v-next/hardhat/assets/lib-coverage/index.d.ts @@ -0,0 +1,33 @@ +export interface Location { + line: number; + column: number; +} + +export interface Range { + start: Location; + end: Location; +} + +export interface FunctionMapping { + name: string; + decl: Range; + loc: Range; + line: number; +} + +export interface BranchMapping { + loc: Range; + type: string; + locations: Range[]; + line: number; +} + +export interface FileCoverageData { + path: string; + statementMap: { [key: string]: Range }; + fnMap: { [key: string]: FunctionMapping }; + branchMap: { [key: string]: BranchMapping }; + s: { [key: string]: number }; + f: { [key: string]: number }; + b: { [key: string]: number[] }; +} diff --git a/v-next/hardhat/package.json b/v-next/hardhat/package.json index 02b332dffdd..7036f4a16a7 100644 --- a/v-next/hardhat/package.json +++ b/v-next/hardhat/package.json @@ -93,18 +93,12 @@ "@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.1", "@nomicfoundation/solidity-analyzer": "^0.1.1", "@sentry/core": "^9.4.0", - "@types/istanbul-lib-coverage": "^2.0.6", - "@types/istanbul-lib-report": "^3.0.3", - "@types/istanbul-reports": "^3.0.4", "adm-zip": "^0.4.16", "chalk": "^5.3.0", "chokidar": "^4.0.3", "debug": "^4.3.2", "enquirer": "^2.3.0", "ethereum-cryptography": "^2.2.1", - "istanbul-lib-coverage": "^3.2.2", - "istanbul-lib-report": "^3.0.1", - "istanbul-reports": "^3.2.0", "micro-eth-signer": "^0.14.0", "p-map": "^7.0.2", "resolve.exports": "^2.0.3", diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index 2b8e8d2888f..59e83b60998 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -5,7 +5,7 @@ import type { Statement, Tag, } from "./types.js"; -import type { FileCoverageData } from "istanbul-lib-coverage"; +import type { FileCoverageData } from "../../../../assets/lib-coverage/index.js"; import fs from "node:fs"; import path from "node:path"; From 3a5562852b091f56591370c0af8f0ba4ec777f26 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 17:06:10 +0200 Subject: [PATCH 12/32] base package --- pnpm-lock.yaml | 40 ++++++++++++++++++- v-next/hardhat-vendors/.gitignore | 14 +++++++ v-next/hardhat-vendors/.prettierignore | 6 +++ v-next/hardhat-vendors/CHANGELOG.md | 0 v-next/hardhat-vendors/LICENSE | 9 +++++ v-next/hardhat-vendors/README.md | 0 v-next/hardhat-vendors/eslint.config.js | 3 ++ v-next/hardhat-vendors/package.json | 53 +++++++++++++++++++++++++ v-next/hardhat-vendors/tsconfig.json | 4 ++ 9 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 v-next/hardhat-vendors/.gitignore create mode 100644 v-next/hardhat-vendors/.prettierignore create mode 100644 v-next/hardhat-vendors/CHANGELOG.md create mode 100644 v-next/hardhat-vendors/LICENSE create mode 100644 v-next/hardhat-vendors/README.md create mode 100644 v-next/hardhat-vendors/eslint.config.js create mode 100644 v-next/hardhat-vendors/package.json create mode 100644 v-next/hardhat-vendors/tsconfig.json diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 21245c14f31..e725826a531 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1377,6 +1377,42 @@ importers: specifier: ~5.8.0 version: 5.8.3 + v-next/hardhat-vendors: + devDependencies: + '@nomicfoundation/hardhat-node-test-reporter': + specifier: workspace:^3.0.0 + version: link:../hardhat-node-test-reporter + '@types/bn.js': + specifier: ^5.1.5 + version: 5.2.0 + '@types/debug': + specifier: ^4.1.7 + version: 4.1.12 + '@types/node': + specifier: ^20.14.9 + version: 20.19.18 + c8: + specifier: ^9.1.0 + version: 9.1.0 + eslint: + specifier: 9.25.1 + version: 9.25.1 + expect-type: + specifier: ^1.2.1 + version: 1.2.2 + prettier: + specifier: 3.2.5 + version: 3.2.5 + rimraf: + specifier: ^5.0.5 + version: 5.0.10 + tsx: + specifier: ^4.19.3 + version: 4.20.6 + typescript: + specifier: ~5.8.0 + version: 5.8.3 + v-next/hardhat-verify: dependencies: '@ethersproject/abi': @@ -6736,7 +6772,7 @@ snapshots: '@types/bn.js@5.2.0': dependencies: - '@types/node': 20.19.18 + '@types/node': 22.18.7 '@types/chai-as-promised@8.0.2': dependencies: @@ -6843,7 +6879,7 @@ snapshots: '@types/through@0.0.33': dependencies: - '@types/node': 20.19.18 + '@types/node': 22.18.7 '@types/unist@2.0.11': {} diff --git a/v-next/hardhat-vendors/.gitignore b/v-next/hardhat-vendors/.gitignore new file mode 100644 index 00000000000..0e1706cfcd7 --- /dev/null +++ b/v-next/hardhat-vendors/.gitignore @@ -0,0 +1,14 @@ +# Node modules +/node_modules + +# Compilation output +/dist + +# pnpm deploy output +/bundle + +# test coverage output +coverage + +# all the tmp folders in the fixture projects +/test/fixture-projects/tmp/ diff --git a/v-next/hardhat-vendors/.prettierignore b/v-next/hardhat-vendors/.prettierignore new file mode 100644 index 00000000000..f6ebd3c5cd2 --- /dev/null +++ b/v-next/hardhat-vendors/.prettierignore @@ -0,0 +1,6 @@ +/node_modules +/dist +/coverage +CHANGELOG.md +/test/fixture-projects/**/artifacts +/test/fixture-projects/**/cache diff --git a/v-next/hardhat-vendors/CHANGELOG.md b/v-next/hardhat-vendors/CHANGELOG.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/v-next/hardhat-vendors/LICENSE b/v-next/hardhat-vendors/LICENSE new file mode 100644 index 00000000000..cb1bfa147e2 --- /dev/null +++ b/v-next/hardhat-vendors/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 Nomic Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/v-next/hardhat-vendors/README.md b/v-next/hardhat-vendors/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/v-next/hardhat-vendors/eslint.config.js b/v-next/hardhat-vendors/eslint.config.js new file mode 100644 index 00000000000..cf3cdc16fae --- /dev/null +++ b/v-next/hardhat-vendors/eslint.config.js @@ -0,0 +1,3 @@ +import { createConfig } from "../config/eslint.config.js"; + +export default createConfig(import.meta.filename, { onlyHardhatError: false }); diff --git a/v-next/hardhat-vendors/package.json b/v-next/hardhat-vendors/package.json new file mode 100644 index 00000000000..70c31f7e7d1 --- /dev/null +++ b/v-next/hardhat-vendors/package.json @@ -0,0 +1,53 @@ +{ + "name": "@nomicfoundation/hardhat-vendors", + "version": "3.0.0", + "description": "Internal dependencies used by Hardhat that have been vendored to prevent bloating the main package", + "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-vendors", + "repository": { + "type": "git", + "url": "https://github.com/NomicFoundation/hardhat", + "directory": "v-next/hardhat-vendors" + }, + "author": "Nomic Foundation", + "license": "MIT", + "type": "module", + "exports": {}, + "keywords": [ + "hardhat" + ], + "scripts": { + "lint": "pnpm prettier --check && pnpm eslint", + "lint:fix": "pnpm prettier --write && pnpm eslint --fix", + "eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", + "prettier": "prettier \"**/*.{ts,js,md,json}\"", + "test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", + "test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", + "test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", + "pretest": "pnpm build", + "pretest:only": "pnpm build", + "build": "tsc --build .", + "prepublishOnly": "pnpm build", + "clean": "rimraf dist" + }, + "files": [ + "dist/src/", + "src/", + "CHANGELOG.md", + "LICENSE", + "README.md" + ], + "devDependencies": { + "@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0", + "@types/bn.js": "^5.1.5", + "@types/debug": "^4.1.7", + "@types/node": "^20.14.9", + "c8": "^9.1.0", + "eslint": "9.25.1", + "expect-type": "^1.2.1", + "prettier": "3.2.5", + "rimraf": "^5.0.5", + "tsx": "^4.19.3", + "typescript": "~5.8.0" + }, + "dependencies": {} +} diff --git a/v-next/hardhat-vendors/tsconfig.json b/v-next/hardhat-vendors/tsconfig.json new file mode 100644 index 00000000000..1bfe4cc4db1 --- /dev/null +++ b/v-next/hardhat-vendors/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../config/tsconfig.base.json", + "references": [] +} From cc5cb6a1c50a97ba19258f47b00f8a967ef9faf6 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Fri, 17 Oct 2025 17:06:50 +0200 Subject: [PATCH 13/32] move js istanbul libs in the new package --- pnpm-lock.yaml | 3 + v-next/hardhat/assets/html-escaper/index.cjs | 24 - v-next/hardhat/assets/index.js | 8 - .../hardhat/assets/istanbul-reports/index.cjs | 24 - .../istanbul-reports/lib/html/annotator.cjs | 294 ------------ .../istanbul-reports/lib/html/assets/base.css | 224 --------- .../lib/html/assets/block-navigation.js | 86 ---- .../lib/html/assets/favicon.png | Bin 445 -> 0 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 138 -> 0 bytes .../lib/html/assets/sorter.js | 209 --------- .../lib/html/assets/vendor/prettify.css | 1 - .../lib/html/assets/vendor/prettify.js | 1 - .../istanbul-reports/lib/html/index.cjs | 409 ---------------- .../lib/html/insertion-text.cjs | 114 ----- v-next/hardhat/assets/lib-coverage/index.cjs | 64 --- v-next/hardhat/assets/lib-coverage/index.d.ts | 33 -- .../assets/lib-coverage/lib/coverage-map.cjs | 134 ------ .../lib-coverage/lib/coverage-summary.cjs | 112 ----- .../lib-coverage/lib/data-properties.cjs | 12 - .../assets/lib-coverage/lib/file-coverage.cjs | 442 ------------------ .../assets/lib-coverage/lib/percent.cjs | 15 - v-next/hardhat/assets/lib-report/index.cjs | 40 -- .../hardhat/assets/lib-report/lib/context.cjs | 132 ------ .../assets/lib-report/lib/file-writer.cjs | 184 -------- v-next/hardhat/assets/lib-report/lib/path.cjs | 169 ------- .../assets/lib-report/lib/report-base.cjs | 16 - .../lib-report/lib/summarizer-factory.cjs | 284 ----------- v-next/hardhat/assets/lib-report/lib/tree.cjs | 137 ------ .../assets/lib-report/lib/watermarks.cjs | 15 - .../assets/lib-report/lib/xml-writer.cjs | 90 ---- v-next/hardhat/package.json | 1 + 31 files changed, 4 insertions(+), 3273 deletions(-) delete mode 100644 v-next/hardhat/assets/html-escaper/index.cjs delete mode 100644 v-next/hardhat/assets/index.js delete mode 100644 v-next/hardhat/assets/istanbul-reports/index.cjs delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/favicon.png delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/sort-arrow-sprite.png delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs delete mode 100644 v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs delete mode 100644 v-next/hardhat/assets/lib-coverage/index.cjs delete mode 100644 v-next/hardhat/assets/lib-coverage/index.d.ts delete mode 100644 v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs delete mode 100644 v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs delete mode 100644 v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs delete mode 100644 v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs delete mode 100644 v-next/hardhat/assets/lib-coverage/lib/percent.cjs delete mode 100644 v-next/hardhat/assets/lib-report/index.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/context.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/file-writer.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/path.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/report-base.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/tree.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/watermarks.cjs delete mode 100644 v-next/hardhat/assets/lib-report/lib/xml-writer.cjs diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e725826a531..df3ef48afd8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,6 +152,9 @@ importers: '@nomicfoundation/hardhat-utils': specifier: workspace:^3.0.2 version: link:../hardhat-utils + '@nomicfoundation/hardhat-vendors': + specifier: workspace:^3.0.0 + version: link:../hardhat-vendors '@nomicfoundation/hardhat-zod-utils': specifier: workspace:^3.0.1 version: link:../hardhat-zod-utils diff --git a/v-next/hardhat/assets/html-escaper/index.cjs b/v-next/hardhat/assets/html-escaper/index.cjs deleted file mode 100644 index d823b800faf..00000000000 --- a/v-next/hardhat/assets/html-escaper/index.cjs +++ /dev/null @@ -1,24 +0,0 @@ -const { replace } = ""; - -// escape -const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; -const ca = /[&<>'"]/g; - -const esca = { - "&": "&", - "<": "<", - ">": ">", - "'": "'", - '"': """, -}; -const pe = (m) => esca[m]; - -/** - * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. - * @param {string} es the input to safely escape - * @returns {string} the escaped input, and it **throws** an error if - * the input type is unexpected, except for boolean and numbers, - * converted as string. - */ -const escape = (es) => replace.call(es, ca, pe); -exports.escape = escape; diff --git a/v-next/hardhat/assets/index.js b/v-next/hardhat/assets/index.js deleted file mode 100644 index e77664e0c22..00000000000 --- a/v-next/hardhat/assets/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import libCoverage from "./lib-coverage/index.cjs"; -export { libCoverage }; - -import libReport from "./lib-report/index.cjs"; -export { libReport }; - -import reports from "./istanbul-reports/index.cjs"; -export { reports }; diff --git a/v-next/hardhat/assets/istanbul-reports/index.cjs b/v-next/hardhat/assets/istanbul-reports/index.cjs deleted file mode 100644 index 7db2b63fa9f..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/index.cjs +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); - -module.exports = { - create(name, cfg) { - cfg = cfg || {}; - let Cons; - try { - Cons = require(path.join(__dirname, "lib", name, "index.cjs")); - } catch (e) { - if (e.code !== "MODULE_NOT_FOUND") { - throw e; - } - - Cons = require(name); - } - - return new Cons(cfg); - }, -}; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs deleted file mode 100644 index a9b47a7380a..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/annotator.cjs +++ /dev/null @@ -1,294 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const InsertionText = require("./insertion-text.cjs"); -const lt = "\u0001"; -const gt = "\u0002"; -const RE_LT = //g; -const RE_AMP = /&/g; - -var RE_lt = /\u0001/g; - -var RE_gt = /\u0002/g; - -function title(str) { - return ' title="' + str + '" '; -} - -function customEscape(text) { - text = String(text); - return text - .replace(RE_AMP, "&") - .replace(RE_LT, "<") - .replace(RE_GT, ">") - .replace(RE_lt, "<") - .replace(RE_gt, ">"); -} - -function annotateLines(fileCoverage, structuredText) { - const lineStats = fileCoverage.getLineCoverage(); - if (!lineStats) { - return; - } - Object.entries(lineStats).forEach(([lineNumber, count]) => { - if (structuredText[lineNumber]) { - structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; - structuredText[lineNumber].hits = count; - } - }); -} - -function annotateStatements(fileCoverage, structuredText) { - const statementStats = fileCoverage.s; - const statementMeta = fileCoverage.statementMap; - Object.entries(statementStats).forEach(([stName, count]) => { - const meta = statementMeta[stName]; - const type = count > 0 ? "yes" : "no"; - const startCol = meta.start.column; - let endCol = meta.end.column + 1; - const startLine = meta.start.line; - const endLine = meta.end.line; - const openSpan = - lt + - 'span class="' + - (meta.skip ? "cstat-skip" : "cstat-no") + - '"' + - title("statement not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap( - startCol, - openSpan, - startCol < endCol ? endCol : text.originalLength(), - closeSpan, - ); - } - }); -} - -function annotateFunctions(fileCoverage, structuredText) { - const fnStats = fileCoverage.f; - const fnMeta = fileCoverage.fnMap; - if (!fnStats) { - return; - } - Object.entries(fnStats).forEach(([fName, count]) => { - const meta = fnMeta[fName]; - const type = count > 0 ? "yes" : "no"; - // Some versions of the instrumenter in the wild populate 'func' - // but not 'decl': - const decl = meta.decl || meta.loc; - const startCol = decl.start.column; - let endCol = decl.end.column + 1; - const startLine = decl.start.line; - const endLine = decl.end.line; - const openSpan = - lt + - 'span class="' + - (meta.skip ? "fstat-skip" : "fstat-no") + - '"' + - title("function not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap( - startCol, - openSpan, - startCol < endCol ? endCol : text.originalLength(), - closeSpan, - ); - } - }); -} - -function annotateBranches(fileCoverage, structuredText) { - const branchStats = fileCoverage.b; - const branchMeta = fileCoverage.branchMap; - if (!branchStats) { - return; - } - - Object.entries(branchStats).forEach(([branchName, branchArray]) => { - const sumCount = branchArray.reduce((p, n) => p + n, 0); - const metaArray = branchMeta[branchName].locations; - let i; - let count; - let meta; - let startCol; - let endCol; - let startLine; - let endLine; - let openSpan; - let closeSpan; - let text; - - // only highlight if partial branches are missing or if there is a - // single uncovered branch. - if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { - // Need to recover the metaArray placeholder item to count an implicit else - if ( - // Check if the branch is a conditional if branch. - branchMeta[branchName].type === "if" && - // Check if the branch has an implicit else. - branchArray.length === 2 && - // Check if the implicit else branch is unaccounted for. - metaArray.length === 1 && - // Check if the implicit else branch is uncovered. - branchArray[1] === 0 - ) { - metaArray[1] = { - start: {}, - end: {}, - }; - } - - for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { - count = branchArray[i]; - meta = metaArray[i]; - startCol = meta.start.column; - endCol = meta.end.column + 1; - startLine = meta.start.line; - endLine = meta.end.line; - openSpan = - lt + - 'span class="branch-' + - i + - " " + - (meta.skip ? "cbranch-skip" : "cbranch-no") + - '"' + - title("branch not covered") + - gt; - closeSpan = lt + "/span" + gt; - - // If the branch is an implicit else from an if statement, - // then the coverage report won't show a statistic. - // Therefore, the previous branch will be used to report that - // there is no coverage on that implicit branch. - if ( - count === 0 && - startLine === undefined && - branchMeta[branchName].type === "if" - ) { - const prevMeta = metaArray[i - 1]; - startCol = prevMeta.start.column; - endCol = prevMeta.end.column + 1; - startLine = prevMeta.start.line; - endLine = prevMeta.end.line; - } - - if (count === 0 && structuredText[startLine]) { - //skip branches taken - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - if (branchMeta[branchName].type === "if") { - // 'if' is a special case - // since the else branch might not be visible, being nonexistent - text.insertAt( - startCol, - lt + - 'span class="' + - (meta.skip ? "skip-if-branch" : "missing-if-branch") + - '"' + - title((i === 0 ? "if" : "else") + " path not taken") + - gt + - (i === 0 ? "I" : "E") + - lt + - "/span" + - gt, - true, - false, - ); - } else { - text.wrap( - startCol, - openSpan, - startCol < endCol ? endCol : text.originalLength(), - closeSpan, - ); - } - } - } - } - }); -} - -function annotateSourceCode(fileCoverage, sourceStore) { - let codeArray; - let lineCoverageArray; - try { - const sourceText = sourceStore.getSource(fileCoverage.path); - const code = sourceText.split(/(?:\r?\n)|\r/); - let count = 0; - const structured = code.map((str) => { - count += 1; - return { - line: count, - covered: "neutral", - hits: 0, - text: new InsertionText(str, true), - }; - }); - structured.unshift({ - line: 0, - covered: null, - text: new InsertionText(""), - }); - annotateLines(fileCoverage, structured); - //note: order is important, since statements typically result in spanning the whole line and doing branches late - //causes mismatched tags - annotateBranches(fileCoverage, structured); - annotateFunctions(fileCoverage, structured); - annotateStatements(fileCoverage, structured); - structured.shift(); - - codeArray = structured.map( - (item) => customEscape(item.text.toString()) || " ", - ); - - lineCoverageArray = structured.map((item) => ({ - covered: item.covered, - hits: item.hits > 0 ? item.hits + "x" : " ", - })); - - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: structured.length, - }; - } catch (ex) { - codeArray = [ex.message]; - lineCoverageArray = [{ covered: "no", hits: 0 }]; - String(ex.stack || "") - .split(/\r?\n/) - .forEach((line) => { - codeArray.push(line); - lineCoverageArray.push({ covered: "no", hits: 0 }); - }); - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: codeArray.length, - }; - } -} - -module.exports = annotateSourceCode; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css deleted file mode 100644 index f418035b469..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/base.css +++ /dev/null @@ -1,224 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* yellow */ -.cbranch-no { background: yellow !important; color: #111; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -.highlighted, -.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ - background: #C21F39 !important; -} -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -.medium .chart { border:1px solid #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } - -.coverage-summary td.empty { - opacity: .5; - padding-top: 4px; - padding-bottom: 4px; - line-height: 1; - color: #888; -} - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js deleted file mode 100644 index eb527848ee7..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/block-navigation.js +++ /dev/null @@ -1,86 +0,0 @@ -var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; - - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selector that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } - - makeCurrent(nextIndex); - } - - function goToNext() { - var nextIndex = 0; - - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } - - makeCurrent(nextIndex); - } - - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } - - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; -})(); -window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/favicon.png deleted file mode 100644 index c1525b811a167671e9de1fa78aab9f5c0b61cef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js deleted file mode 100644 index 83122f78ace..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/sorter.js +++ /dev/null @@ -1,209 +0,0 @@ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - - // Try to create a RegExp from the searchValue. If it fails (invalid regex), - // it will be treated as a plain text search - let searchRegex; - try { - searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive - } catch (error) { - searchRegex = null; - } - - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - let isMatch = false; - - if (searchRegex) { - // If a valid regex was created, use it for matching - isMatch = searchRegex.test(row.textContent); - } else { - // Otherwise, fall back to the original plain text search - isMatch = row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()); - } - - row.style.display = isMatch ? '' : 'none'; - } - } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css deleted file mode 100644 index b317a7cda31..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js deleted file mode 100644 index ef51e038668..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/assets/vendor/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs deleted file mode 100644 index a958877e7f2..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/index.cjs +++ /dev/null @@ -1,409 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const path = require("node:path"); -const html = require("../../../html-escaper/index.cjs"); -const ReportBase = require("../../../lib-report/lib/report-base.cjs"); -const annotator = require("./annotator.cjs"); - -function htmlHead(details) { - return ` - - Code coverage report for ${html.escape(details.entity)} - - - - - - - - `; -} - -function headerTemplate(details) { - function metricsTemplate({ pct, covered, total }, kind) { - return ` -
- ${pct}% - ${kind} - ${covered}/${total} -
- `; - } - - function skipTemplate(metrics) { - const statements = metrics.statements.skipped; - const branches = metrics.branches.skipped; - const functions = metrics.functions.skipped; - - const countLabel = (c, label, plural) => - c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; - const skips = [].concat( - countLabel(statements, "statement", "s"), - countLabel(functions, "function", "s"), - countLabel(branches, "branch", "es"), - ); - - if (skips.length === 0) { - return ""; - } - - return ` -
- ${skips.join(", ")} - Ignored      -
- `; - } - - return ` - - -${htmlHead(details)} - -
-
-

${details.pathHtml}

-
- ${metricsTemplate(details.metrics.statements, "Statements")} - ${metricsTemplate(details.metrics.branches, "Branches")} - ${metricsTemplate(details.metrics.functions, "Functions")} - ${metricsTemplate(details.metrics.lines, "Lines")} - ${skipTemplate(details.metrics)} -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
- `; -} - -function footerTemplate(details) { - return ` -
-
- - - - - - - - `; -} - -function detailTemplate(data) { - const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); - const lineLink = (num) => - `${num}`; - const lineCount = (line) => - `${line.hits}`; - - /* This is rendered in a `
`, need control of all whitespace. */
-  return [
-    "",
-    `${lineNumbers.map(lineLink).join("\n")}`,
-    `${data.lineCoverage
-      .map(lineCount)
-      .join("\n")}`,
-    `
${data.annotatedCode.join(
-      "\n",
-    )}
`, - "", - ].join(""); -} -const summaryTableHeader = [ - '
', - '', - "", - "", - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - "", - "", - "", -].join("\n"); - -function summaryLineTemplate(details) { - const { reportClasses, metrics, file, output } = details; - const percentGraph = (pct) => { - if (!isFinite(pct)) { - return ""; - } - - const cls = ["cover-fill"]; - if (pct === 100) { - cls.push("cover-full"); - } - - pct = Math.floor(pct); - return [ - `
`, - `
`, - ].join(""); - }; - const summaryType = (type, showGraph = false) => { - const info = metrics[type]; - const reportClass = reportClasses[type]; - const result = [ - ``, - ``, - ]; - if (showGraph) { - result.unshift( - ``, - ); - } - - return result; - }; - - return [] - .concat( - "", - ``, - summaryType("statements", true), - summaryType("branches"), - summaryType("functions"), - summaryType("lines"), - "\n", - ) - .join("\n\t"); -} - -const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, - `
${percentGraph(info.pct)}
`, - `
${html.escape(file)}
", "
"].join("\n"); -const emptyClasses = { - statements: "empty", - lines: "empty", - functions: "empty", - branches: "empty", -}; - -const standardLinkMapper = { - getPath(node) { - if (typeof node === "string") { - return node; - } - let filePath = node.getQualifiedName(); - if (node.isSummary()) { - if (filePath !== "") { - filePath += "/index.html"; - } else { - filePath = "index.html"; - } - } else { - filePath += ".html"; - } - return filePath; - }, - - relativePath(source, target) { - const targetPath = this.getPath(target); - const sourcePath = path.dirname(this.getPath(source)); - return path.posix.relative(sourcePath, targetPath); - }, - - assetPath(node, name) { - return this.relativePath(this.getPath(node), name); - }, -}; - -function fixPct(metrics) { - Object.keys(emptyClasses).forEach((key) => { - metrics[key].pct = 0; - }); - return metrics; -} - -class HtmlReport extends ReportBase { - constructor(opts) { - super(); - - this.verbose = opts.verbose; - this.linkMapper = opts.linkMapper || standardLinkMapper; - this.subdir = opts.subdir || ""; - this.date = new Date().toISOString(); - this.skipEmpty = opts.skipEmpty; - } - - getBreadcrumbHtml(node) { - let parent = node.getParent(); - const nodePath = []; - - while (parent) { - nodePath.push(parent); - parent = parent.getParent(); - } - - const linkPath = nodePath.map((ancestor) => { - const target = this.linkMapper.relativePath(node, ancestor); - const name = ancestor.getRelativeName() || "All files"; - return '' + name + ""; - }); - - linkPath.reverse(); - return linkPath.length > 0 - ? linkPath.join(" / ") + " " + node.getRelativeName() - : "All files"; - } - - fillTemplate(node, templateData, context) { - const linkMapper = this.linkMapper; - const summary = node.getCoverageSummary(); - templateData.entity = node.getQualifiedName() || "All files"; - templateData.metrics = summary; - templateData.reportClass = context.classForPercent( - "statements", - summary.statements.pct, - ); - templateData.pathHtml = this.getBreadcrumbHtml(node); - templateData.base = { - css: linkMapper.assetPath(node, "base.css"), - }; - templateData.sorter = { - js: linkMapper.assetPath(node, "sorter.js"), - image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), - }; - templateData.blockNavigation = { - js: linkMapper.assetPath(node, "block-navigation.js"), - }; - templateData.prettify = { - js: linkMapper.assetPath(node, "prettify.js"), - css: linkMapper.assetPath(node, "prettify.css"), - }; - templateData.favicon = linkMapper.assetPath(node, "favicon.png"); - } - - getTemplateData() { - return { datetime: this.date }; - } - - getWriter(context) { - if (!this.subdir) { - return context.writer; - } - return context.writer.writerForDir(this.subdir); - } - - onStart(root, context) { - const assetHeaders = { - ".js": "/* eslint-disable */\n", - }; - - [".", "vendor"].forEach((subdir) => { - const writer = this.getWriter(context); - const srcDir = path.resolve(__dirname, "assets", subdir); - fs.readdirSync(srcDir).forEach((f) => { - const resolvedSource = path.resolve(srcDir, f); - const resolvedDestination = "."; - const stat = fs.statSync(resolvedSource); - let dest; - - if (stat.isFile()) { - dest = resolvedDestination + "/" + f; - if (this.verbose) { - console.log("Write asset: " + dest); - } - writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); - } - }); - }); - } - - onSummary(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - const children = node.getChildren(); - const skipEmpty = this.skipEmpty; - - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write(summaryTableHeader); - children.forEach((child) => { - const metrics = child.getCoverageSummary(); - const isEmpty = metrics.isEmpty(); - if (skipEmpty && isEmpty) { - return; - } - const reportClasses = isEmpty - ? emptyClasses - : { - statements: context.classForPercent( - "statements", - metrics.statements.pct, - ), - lines: context.classForPercent("lines", metrics.lines.pct), - functions: context.classForPercent( - "functions", - metrics.functions.pct, - ), - branches: context.classForPercent("branches", metrics.branches.pct), - }; - const data = { - metrics: isEmpty ? fixPct(metrics) : metrics, - reportClasses, - file: child.getRelativeName(), - output: linkMapper.relativePath(node, child), - }; - cw.write(summaryLineTemplate(data) + "\n"); - }); - cw.write(summaryTableFooter); - cw.write(footerTemplate(templateData)); - cw.close(); - } - - onDetail(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write('
\n');
-    cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
-    cw.write("
\n"); - cw.write(footerTemplate(templateData)); - cw.close(); - } -} - -module.exports = HtmlReport; diff --git a/v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs deleted file mode 100644 index 6f8064245c2..00000000000 --- a/v-next/hardhat/assets/istanbul-reports/lib/html/insertion-text.cjs +++ /dev/null @@ -1,114 +0,0 @@ -'use strict'; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -function InsertionText(text, consumeBlanks) { - this.text = text; - this.origLength = text.length; - this.offsets = []; - this.consumeBlanks = consumeBlanks; - this.startPos = this.findFirstNonBlank(); - this.endPos = this.findLastNonBlank(); -} - -const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; - -InsertionText.prototype = { - findFirstNonBlank() { - let pos = -1; - const text = this.text; - const len = text.length; - let i; - for (i = 0; i < len; i += 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - findLastNonBlank() { - const text = this.text; - const len = text.length; - let pos = text.length + 1; - let i; - for (i = len - 1; i >= 0; i -= 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - originalLength() { - return this.origLength; - }, - - insertAt(col, str, insertBefore, consumeBlanks) { - consumeBlanks = - typeof consumeBlanks === 'undefined' - ? this.consumeBlanks - : consumeBlanks; - col = col > this.originalLength() ? this.originalLength() : col; - col = col < 0 ? 0 : col; - - if (consumeBlanks) { - if (col <= this.startPos) { - col = 0; - } - if (col > this.endPos) { - col = this.origLength; - } - } - - const len = str.length; - const offset = this.findOffset(col, len, insertBefore); - const realPos = col + offset; - const text = this.text; - this.text = text.substring(0, realPos) + str + text.substring(realPos); - return this; - }, - - findOffset(pos, len, insertBefore) { - const offsets = this.offsets; - let offsetObj; - let cumulativeOffset = 0; - let i; - - for (i = 0; i < offsets.length; i += 1) { - offsetObj = offsets[i]; - if ( - offsetObj.pos < pos || - (offsetObj.pos === pos && !insertBefore) - ) { - cumulativeOffset += offsetObj.len; - } - if (offsetObj.pos >= pos) { - break; - } - } - if (offsetObj && offsetObj.pos === pos) { - offsetObj.len += len; - } else { - offsets.splice(i, 0, { pos, len }); - } - return cumulativeOffset; - }, - - wrap(startPos, startText, endPos, endText, consumeBlanks) { - this.insertAt(startPos, startText, true, consumeBlanks); - this.insertAt(endPos, endText, false, consumeBlanks); - return this; - }, - - wrapLine(startText, endText) { - this.wrap(0, startText, this.originalLength(), endText); - }, - - toString() { - return this.text; - } -}; - -module.exports = InsertionText; diff --git a/v-next/hardhat/assets/lib-coverage/index.cjs b/v-next/hardhat/assets/lib-coverage/index.cjs deleted file mode 100644 index c6074ee2d56..00000000000 --- a/v-next/hardhat/assets/lib-coverage/index.cjs +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -/** - * istanbul-lib-coverage exports an API that allows you to create and manipulate - * file coverage, coverage maps (a set of file coverage objects) and summary - * coverage objects. File coverage for the same file can be merged as can - * entire coverage maps. - * - * @module Exports - */ -const { FileCoverage } = require("./lib/file-coverage.cjs"); -const { CoverageMap } = require("./lib/coverage-map.cjs"); -const { CoverageSummary } = require("./lib/coverage-summary.cjs"); - -module.exports = { - /** - * creates a coverage summary object - * @param {Object} obj an argument with the same semantics - * as the one passed to the `CoverageSummary` constructor - * @returns {CoverageSummary} - */ - createCoverageSummary(obj) { - if (obj && obj instanceof CoverageSummary) { - return obj; - } - return new CoverageSummary(obj); - }, - /** - * creates a CoverageMap object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the CoverageMap constructor. - * @returns {CoverageMap} - */ - createCoverageMap(obj) { - if (obj && obj instanceof CoverageMap) { - return obj; - } - return new CoverageMap(obj); - }, - /** - * creates a FileCoverage object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the FileCoverage constructor. - * @returns {FileCoverage} - */ - createFileCoverage(obj) { - if (obj && obj instanceof FileCoverage) { - return obj; - } - return new FileCoverage(obj); - }, -}; - -/** classes exported for reuse */ -module.exports.classes = { - /** - * the file coverage constructor - */ - FileCoverage, -}; diff --git a/v-next/hardhat/assets/lib-coverage/index.d.ts b/v-next/hardhat/assets/lib-coverage/index.d.ts deleted file mode 100644 index 33e9f5b5655..00000000000 --- a/v-next/hardhat/assets/lib-coverage/index.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -export interface Location { - line: number; - column: number; -} - -export interface Range { - start: Location; - end: Location; -} - -export interface FunctionMapping { - name: string; - decl: Range; - loc: Range; - line: number; -} - -export interface BranchMapping { - loc: Range; - type: string; - locations: Range[]; - line: number; -} - -export interface FileCoverageData { - path: string; - statementMap: { [key: string]: Range }; - fnMap: { [key: string]: FunctionMapping }; - branchMap: { [key: string]: BranchMapping }; - s: { [key: string]: number }; - f: { [key: string]: number }; - b: { [key: string]: number[] }; -} diff --git a/v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs deleted file mode 100644 index b3f80303341..00000000000 --- a/v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const { FileCoverage } = require("./file-coverage.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); - -function maybeConstruct(obj, klass) { - if (obj instanceof klass) { - return obj; - } - - return new klass(obj); -} - -function loadMap(source) { - const data = Object.create(null); - if (!source) { - return data; - } - - Object.entries(source).forEach(([k, cov]) => { - data[k] = maybeConstruct(cov, FileCoverage); - }); - - return data; -} - -/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ -class CoverageMap { - /** - * @constructor - * @param {Object} [obj=undefined] obj A coverage map from which to initialize this - * map's contents. This can be the raw global coverage object. - */ - constructor(obj) { - if (obj instanceof CoverageMap) { - this.data = obj.data; - } else { - this.data = loadMap(obj); - } - } - - /** - * merges a second coverage map into this one - * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged - * correctly for the same files and additional file coverage keys are created - * as needed. - */ - merge(obj) { - const other = maybeConstruct(obj, CoverageMap); - Object.values(other.data).forEach((fc) => { - this.addFileCoverage(fc); - }); - } - - /** - * filter the coveragemap based on the callback provided - * @param {Function (filename)} callback - Returns true if the path - * should be included in the coveragemap. False if it should be - * removed. - */ - filter(callback) { - Object.keys(this.data).forEach((k) => { - if (!callback(k)) { - delete this.data[k]; - } - }); - } - - /** - * returns a JSON-serializable POJO for this coverage map - * @returns {Object} - */ - toJSON() { - return this.data; - } - - /** - * returns an array for file paths for which this map has coverage - * @returns {Array{string}} - array of files - */ - files() { - return Object.keys(this.data); - } - - /** - * returns the file coverage for the specified file. - * @param {String} file - * @returns {FileCoverage} - */ - fileCoverageFor(file) { - const fc = this.data[file]; - if (!fc) { - throw new Error(`No file coverage available for: ${file}`); - } - return fc; - } - - /** - * adds a file coverage object to this map. If the path for the object, - * already exists in the map, it is merged with the existing coverage - * otherwise a new key is added to the map. - * @param {FileCoverage} fc the file coverage to add - */ - addFileCoverage(fc) { - const cov = new FileCoverage(fc); - const { path } = cov; - if (this.data[path]) { - this.data[path].merge(cov); - } else { - this.data[path] = cov; - } - } - - /** - * returns the coverage summary for all the file coverage objects in this map. - * @returns {CoverageSummary} - */ - getCoverageSummary() { - const ret = new CoverageSummary(); - Object.values(this.data).forEach((fc) => { - ret.merge(fc.toSummary()); - }); - - return ret; - } -} - -module.exports = { - CoverageMap, -}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs deleted file mode 100644 index 1e6a9498936..00000000000 --- a/v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); - -function blankSummary() { - const empty = () => ({ - total: 0, - covered: 0, - skipped: 0, - pct: "Unknown", - }); - - return { - lines: empty(), - statements: empty(), - functions: empty(), - branches: empty(), - branchesTrue: empty(), - }; -} - -// asserts that a data object "looks like" a summary coverage object -function assertValidSummary(obj) { - const valid = - obj && obj.lines && obj.statements && obj.functions && obj.branches; - if (!valid) { - throw new Error( - "Invalid summary coverage object, missing keys, found:" + - Object.keys(obj).join(","), - ); - } -} - -/** - * CoverageSummary provides a summary of code coverage . It exposes 4 properties, - * `lines`, `statements`, `branches`, and `functions`. Each of these properties - * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. - * `pct` is a percentage number (0-100). - */ -class CoverageSummary { - /** - * @constructor - * @param {Object|CoverageSummary} [obj=undefined] an optional data object or - * another coverage summary to initialize this object with. - */ - constructor(obj) { - if (!obj) { - this.data = blankSummary(); - } else if (obj instanceof CoverageSummary) { - this.data = obj.data; - } else { - this.data = obj; - } - assertValidSummary(this.data); - } - - /** - * merges a second summary coverage object into this one - * @param {CoverageSummary} obj - another coverage summary object - */ - merge(obj) { - const keys = [ - "lines", - "statements", - "branches", - "functions", - "branchesTrue", - ]; - keys.forEach((key) => { - if (obj[key]) { - this[key].total += obj[key].total; - this[key].covered += obj[key].covered; - this[key].skipped += obj[key].skipped; - this[key].pct = percent(this[key].covered, this[key].total); - } - }); - - return this; - } - - /** - * returns a POJO that is JSON serializable. May be used to get the raw - * summary object. - */ - toJSON() { - return this.data; - } - - /** - * return true if summary has no lines of code - */ - isEmpty() { - return this.lines.total === 0; - } -} - -dataProperties(CoverageSummary, [ - "lines", - "statements", - "functions", - "branches", - "branchesTrue", -]); - -module.exports = { - CoverageSummary, -}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs b/v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs deleted file mode 100644 index ad6ac0e1453..00000000000 --- a/v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -module.exports = function dataProperties(klass, properties) { - properties.forEach((p) => { - Object.defineProperty(klass.prototype, p, { - enumerable: true, - get() { - return this.data[p]; - }, - }); - }); -}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs deleted file mode 100644 index 47f45bbd63f..00000000000 --- a/v-next/hardhat/assets/lib-coverage/lib/file-coverage.cjs +++ /dev/null @@ -1,442 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); - -// returns a data object that represents empty coverage -function emptyCoverage(filePath, reportLogic) { - const cov = { - path: filePath, - statementMap: {}, - fnMap: {}, - branchMap: {}, - s: {}, - f: {}, - b: {}, - }; - if (reportLogic) cov.bT = {}; - return cov; -} - -// asserts that a data object "looks like" a coverage object -function assertValidObject(obj) { - const valid = - obj && - obj.path && - obj.statementMap && - obj.fnMap && - obj.branchMap && - obj.s && - obj.f && - obj.b; - if (!valid) { - throw new Error( - "Invalid file coverage object, missing keys, found:" + - Object.keys(obj).join(","), - ); - } -} - -const keyFromLoc = ({ start, end }) => - `${start.line}|${start.column}|${end.line}|${end.column}`; - -const isObj = (o) => !!o && typeof o === "object"; -const isLineCol = (o) => - isObj(o) && typeof o.line === "number" && typeof o.column === "number"; -const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); -const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); - -// When merging, we can have a case where two ranges cover -// the same block of code with `hits=1`, and each carve out a -// different range with `hits=0` to indicate it's uncovered. -// Find the nearest container so that we can properly indicate -// that both sections are hit. -// Returns null if no containing item is found. -const findNearestContainer = (item, map) => { - const itemLoc = getLoc(item); - if (!itemLoc) return null; - // the B item is not an identified range in the A set, BUT - // it may be contained by an identified A range. If so, then - // any hit of that containing A range counts as a hit of this - // B range as well. We have to find the *narrowest* containing - // range to be accurate, since ranges can be hit and un-hit - // in a nested fashion. - let nearestContainingItem = null; - let containerDistance = null; - let containerKey = null; - for (const [i, mapItem] of Object.entries(map)) { - const mapLoc = getLoc(mapItem); - if (!mapLoc) continue; - // contained if all of line distances are > 0 - // or line distance is 0 and col dist is >= 0 - const distance = [ - itemLoc.start.line - mapLoc.start.line, - itemLoc.start.column - mapLoc.start.column, - mapLoc.end.line - itemLoc.end.line, - mapLoc.end.column - itemLoc.end.column, - ]; - if ( - distance[0] < 0 || - distance[2] < 0 || - (distance[0] === 0 && distance[1] < 0) || - (distance[2] === 0 && distance[3] < 0) - ) { - continue; - } - if (nearestContainingItem === null) { - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - continue; - } - // closer line more relevant than closer column - const closerBefore = - distance[0] < containerDistance[0] || - (distance[0] === 0 && distance[1] < containerDistance[1]); - const closerAfter = - distance[2] < containerDistance[2] || - (distance[2] === 0 && distance[3] < containerDistance[3]); - if (closerBefore || closerAfter) { - // closer - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - } - } - return containerKey; -}; - -// either add two numbers, or all matching entries in a number[] -const addHits = (aHits, bHits) => { - if (typeof aHits === "number" && typeof bHits === "number") { - return aHits + bHits; - } else if (Array.isArray(aHits) && Array.isArray(bHits)) { - return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); - } - return null; -}; - -const addNearestContainerHits = (item, itemHits, map, mapHits) => { - const container = findNearestContainer(item, map); - if (container) { - return addHits(itemHits, mapHits[container]); - } else { - return itemHits; - } -}; - -const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { - const aItems = {}; - for (const [key, itemHits] of Object.entries(aHits)) { - const item = aMap[key]; - aItems[itemKey(item)] = [itemHits, item]; - } - const bItems = {}; - for (const [key, itemHits] of Object.entries(bHits)) { - const item = bMap[key]; - bItems[itemKey(item)] = [itemHits, item]; - } - const mergedItems = {}; - for (const [key, aValue] of Object.entries(aItems)) { - let aItemHits = aValue[0]; - const aItem = aValue[1]; - const bValue = bItems[key]; - if (!bValue) { - // not an identified range in b, but might be contained by one - aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); - } else { - // is an identified range in b, so add the hits together - aItemHits = addHits(aItemHits, bValue[0]); - } - mergedItems[key] = [aItemHits, aItem]; - } - // now find the items in b that are not in a. already added matches. - for (const [key, bValue] of Object.entries(bItems)) { - let bItemHits = bValue[0]; - const bItem = bValue[1]; - if (mergedItems[key]) continue; - // not an identified range in b, but might be contained by one - bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); - mergedItems[key] = [bItemHits, bItem]; - } - - const hits = {}; - const map = {}; - - Object.values(mergedItems).forEach(([itemHits, item], i) => { - hits[i] = itemHits; - map[i] = item; - }); - - return [hits, map]; -}; - -/** - * provides a read-only view of coverage for a single file. - * The deep structure of this object is documented elsewhere. It has the following - * properties: - * - * * `path` - the file path for which coverage is being tracked - * * `statementMap` - map of statement locations keyed by statement index - * * `fnMap` - map of function metadata keyed by function index - * * `branchMap` - map of branch metadata keyed by branch index - * * `s` - hit counts for statements - * * `f` - hit count for functions - * * `b` - hit count for branches - */ -class FileCoverage { - /** - * @constructor - * @param {Object|FileCoverage|String} pathOrObj is a string that initializes - * and empty coverage object with the specified file path or a data object that - * has all the required properties for a file coverage object. - */ - constructor(pathOrObj, reportLogic = false) { - if (!pathOrObj) { - throw new Error("Coverage must be initialized with a path or an object"); - } - if (typeof pathOrObj === "string") { - this.data = emptyCoverage(pathOrObj, reportLogic); - } else if (pathOrObj instanceof FileCoverage) { - this.data = pathOrObj.data; - } else if (typeof pathOrObj === "object") { - this.data = pathOrObj; - } else { - throw new Error("Invalid argument to coverage constructor"); - } - assertValidObject(this.data); - } - - /** - * returns computed line coverage from statement coverage. - * This is a map of hits keyed by line number in the source. - */ - getLineCoverage() { - const statementMap = this.data.statementMap; - const statements = this.data.s; - const lineMap = Object.create(null); - - Object.entries(statements).forEach(([st, count]) => { - /* istanbul ignore if: is this even possible? */ - if (!statementMap[st]) { - return; - } - const { line } = statementMap[st].start; - const prevVal = lineMap[line]; - if (prevVal === undefined || prevVal < count) { - lineMap[line] = count; - } - }); - return lineMap; - } - - /** - * returns an array of uncovered line numbers. - * @returns {Array} an array of line numbers for which no hits have been - * collected. - */ - getUncoveredLines() { - const lc = this.getLineCoverage(); - const ret = []; - Object.entries(lc).forEach(([l, hits]) => { - if (hits === 0) { - ret.push(l); - } - }); - return ret; - } - - /** - * returns a map of branch coverage by source line number. - * @returns {Object} an object keyed by line number. Each object - * has a `covered`, `total` and `coverage` (percentage) property. - */ - getBranchCoverageByLine() { - const branchMap = this.branchMap; - const branches = this.b; - const ret = {}; - Object.entries(branchMap).forEach(([k, map]) => { - const line = map.line || map.loc.start.line; - const branchData = branches[k]; - ret[line] = ret[line] || []; - ret[line].push(...branchData); - }); - Object.entries(ret).forEach(([k, dataArray]) => { - const covered = dataArray.filter((item) => item > 0); - const coverage = (covered.length / dataArray.length) * 100; - ret[k] = { - covered: covered.length, - total: dataArray.length, - coverage, - }; - }); - return ret; - } - - /** - * return a JSON-serializable POJO for this file coverage object - */ - toJSON() { - return this.data; - } - - /** - * merges a second coverage object into this one, updating hit counts - * @param {FileCoverage} other - the coverage object to be merged into this one. - * Note that the other object should have the same structure as this one (same file). - */ - merge(other) { - if (other.all === true) { - return; - } - - if (this.all === true) { - this.data = other.data; - return; - } - - let [hits, map] = mergeProp( - this.s, - this.statementMap, - other.s, - other.statementMap, - ); - this.data.s = hits; - this.data.statementMap = map; - - const keyFromLocProp = (x) => keyFromLoc(x.loc); - const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); - - [hits, map] = mergeProp( - this.f, - this.fnMap, - other.f, - other.fnMap, - keyFromLocProp, - ); - this.data.f = hits; - this.data.fnMap = map; - - [hits, map] = mergeProp( - this.b, - this.branchMap, - other.b, - other.branchMap, - keyFromLocationsProp, - ); - this.data.b = hits; - this.data.branchMap = map; - - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT && other.bT) { - [hits, map] = mergeProp( - this.bT, - this.branchMap, - other.bT, - other.branchMap, - keyFromLocationsProp, - ); - this.data.bT = hits; - } - } - - computeSimpleTotals(property) { - let stats = this[property]; - - if (typeof stats === "function") { - stats = stats.call(this); - } - - const ret = { - total: Object.keys(stats).length, - covered: Object.values(stats).filter((v) => !!v).length, - skipped: 0, - }; - ret.pct = percent(ret.covered, ret.total); - return ret; - } - - computeBranchTotals(property) { - const stats = this[property]; - const ret = { total: 0, covered: 0, skipped: 0 }; - - Object.values(stats).forEach((branches) => { - ret.covered += branches.filter((hits) => hits > 0).length; - ret.total += branches.length; - }); - ret.pct = percent(ret.covered, ret.total); - return ret; - } - - /** - * resets hit counts for all statements, functions and branches - * in this coverage object resulting in zero coverage. - */ - resetHits() { - const statements = this.s; - const functions = this.f; - const branches = this.b; - const branchesTrue = this.bT; - Object.keys(statements).forEach((s) => { - statements[s] = 0; - }); - Object.keys(functions).forEach((f) => { - functions[f] = 0; - }); - Object.keys(branches).forEach((b) => { - branches[b].fill(0); - }); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (branchesTrue) { - Object.keys(branchesTrue).forEach((bT) => { - branchesTrue[bT].fill(0); - }); - } - } - - /** - * returns a CoverageSummary for this file coverage object - * @returns {CoverageSummary} - */ - toSummary() { - const ret = {}; - ret.lines = this.computeSimpleTotals("getLineCoverage"); - ret.functions = this.computeSimpleTotals("f", "fnMap"); - ret.statements = this.computeSimpleTotals("s", "statementMap"); - ret.branches = this.computeBranchTotals("b"); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT) { - ret.branchesTrue = this.computeBranchTotals("bT"); - } - return new CoverageSummary(ret); - } -} - -// expose coverage data attributes -dataProperties(FileCoverage, [ - "path", - "statementMap", - "fnMap", - "branchMap", - "s", - "f", - "b", - "bT", - "all", -]); - -module.exports = { - FileCoverage, - // exported for testing - findNearestContainer, - addHits, - addNearestContainerHits, -}; diff --git a/v-next/hardhat/assets/lib-coverage/lib/percent.cjs b/v-next/hardhat/assets/lib-coverage/lib/percent.cjs deleted file mode 100644 index ecb468d56b9..00000000000 --- a/v-next/hardhat/assets/lib-coverage/lib/percent.cjs +++ /dev/null @@ -1,15 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -module.exports = function percent(covered, total) { - let tmp; - if (total > 0) { - tmp = (1000 * 100 * covered) / total; - return Math.floor(tmp / 10) / 100; - } else { - return 100.0; - } -}; diff --git a/v-next/hardhat/assets/lib-report/index.cjs b/v-next/hardhat/assets/lib-report/index.cjs deleted file mode 100644 index f7aad0370c1..00000000000 --- a/v-next/hardhat/assets/lib-report/index.cjs +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -/** - * @module Exports - */ - -const Context = require("./lib/context.cjs"); -const watermarks = require("./lib/watermarks.cjs"); -const ReportBase = require("./lib/report-base.cjs"); - -module.exports = { - /** - * returns a reporting context for the supplied options - * @param {Object} [opts=null] opts - * @returns {Context} - */ - createContext(opts) { - return new Context(opts); - }, - - /** - * returns the default watermarks that would be used when not - * overridden - * @returns {Object} an object with `statements`, `functions`, `branches`, - * and `line` keys. Each value is a 2 element array that has the low and - * high watermark as percentages. - */ - getDefaultWatermarks() { - return watermarks.getDefault(); - }, - - /** - * Base class for all reports - */ - ReportBase, -}; diff --git a/v-next/hardhat/assets/lib-report/lib/context.cjs b/v-next/hardhat/assets/lib-report/lib/context.cjs deleted file mode 100644 index 92ab1478486..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/context.cjs +++ /dev/null @@ -1,132 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const FileWriter = require("./file-writer.cjs"); -const XMLWriter = require("./xml-writer.cjs"); -const tree = require("./tree.cjs"); -const watermarks = require("./watermarks.cjs"); -const SummarizerFactory = require("./summarizer-factory.cjs"); - -function defaultSourceLookup(path) { - try { - return fs.readFileSync(path, "utf8"); - } catch (ex) { - throw new Error(`Unable to lookup source: ${path} (${ex.message})`); - } -} - -function normalizeWatermarks(specified = {}) { - Object.entries(watermarks.getDefault()).forEach(([k, value]) => { - const specValue = specified[k]; - if (!Array.isArray(specValue) || specValue.length !== 2) { - specified[k] = value; - } - }); - - return specified; -} - -/** - * A reporting context that is passed to report implementations - * @param {Object} [opts=null] opts options - * @param {String} [opts.dir='coverage'] opts.dir the reporting directory - * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for - * statements, lines, branches and functions - * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a - * function that returns source code given a file path. Defaults to - * filesystem lookups based on path. - * @constructor - */ -class Context { - constructor(opts) { - this.dir = opts.dir || "coverage"; - this.watermarks = normalizeWatermarks(opts.watermarks); - this.sourceFinder = opts.sourceFinder || defaultSourceLookup; - this._summarizerFactory = new SummarizerFactory( - opts.coverageMap, - opts.defaultSummarizer, - ); - this.data = {}; - } - - /** - * returns a FileWriter implementation for reporting use. Also available - * as the `writer` property on the context. - * @returns {Writer} - */ - getWriter() { - return this.writer; - } - - /** - * returns the source code for the specified file path or throws if - * the source could not be found. - * @param {String} filePath the file path as found in a file coverage object - * @returns {String} the source code - */ - getSource(filePath) { - return this.sourceFinder(filePath); - } - - /** - * returns the coverage class given a coverage - * types and a percentage value. - * @param {String} type - the coverage type, one of `statements`, `functions`, - * `branches`, or `lines` - * @param {Number} value - the percentage value - * @returns {String} one of `high`, `medium` or `low` - */ - classForPercent(type, value) { - const watermarks = this.watermarks[type]; - if (!watermarks) { - return "unknown"; - } - if (value < watermarks[0]) { - return "low"; - } - if (value >= watermarks[1]) { - return "high"; - } - return "medium"; - } - - /** - * returns an XML writer for the supplied content writer - * @param {ContentWriter} contentWriter the content writer to which the returned XML writer - * writes data - * @returns {XMLWriter} - */ - getXMLWriter(contentWriter) { - return new XMLWriter(contentWriter); - } - - /** - * returns a full visitor given a partial one. - * @param {Object} partialVisitor a partial visitor only having the functions of - * interest to the caller. These functions are called with a scope that is the - * supplied object. - * @returns {Visitor} - */ - getVisitor(partialVisitor) { - return new tree.Visitor(partialVisitor); - } - - getTree(name = "defaultSummarizer") { - return this._summarizerFactory[name]; - } -} - -Object.defineProperty(Context.prototype, "writer", { - enumerable: true, - get() { - if (!this.data.writer) { - this.data.writer = new FileWriter(this.dir); - } - return this.data.writer; - }, -}); - -module.exports = Context; diff --git a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs b/v-next/hardhat/assets/lib-report/lib/file-writer.cjs deleted file mode 100644 index 658de8f06f8..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/file-writer.cjs +++ /dev/null @@ -1,184 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); -const fs = require("node:fs"); -const { mkdir } = require("node:fs/promises"); - -/** - * Base class for writing content - * @class ContentWriter - * @constructor - */ -class ContentWriter { - /** - * returns the colorized version of a string. Typically, - * content writers that write to files will return the - * same string and ones writing to a tty will wrap it in - * appropriate escape sequences. - * @param {String} str the string to colorize - * @param {String} clazz one of `high`, `medium` or `low` - * @returns {String} the colorized form of the string - */ - colorize(str /*, clazz*/) { - return str; - } - - /** - * writes a string appended with a newline to the destination - * @param {String} str the string to write - */ - println(str) { - this.write(`${str}\n`); - } - - /** - * closes this content writer. Should be called after all writes are complete. - */ - close() {} -} - -/** - * a content writer that writes to a file - * @param {Number} fd - the file descriptor - * @extends ContentWriter - * @constructor - */ -class FileContentWriter extends ContentWriter { - constructor(fd) { - super(); - - this.fd = fd; - } - - write(str) { - fs.writeSync(this.fd, str); - } - - close() { - fs.closeSync(this.fd); - } -} - -// allow stdout to be captured for tests. -let capture = false; -let output = ""; - -/** - * a content writer that writes to the console - * @extends ContentWriter - * @constructor - */ -class ConsoleWriter extends ContentWriter { - write(str) { - if (capture) { - output += str; - } else { - process.stdout.write(str); - } - } - - colorize(str, clazz) { - const colors = { - low: "31;1", - medium: "33;1", - high: "32;1", - }; - - return str; - } -} - -/** - * utility for writing files under a specific directory - * @class FileWriter - * @param {String} baseDir the base directory under which files should be written - * @constructor - */ -class FileWriter { - constructor(baseDir) { - if (!baseDir) { - throw new Error("baseDir must be specified"); - } - this.baseDir = baseDir; - } - - /** - * static helpers for capturing stdout report output; - * super useful for tests! - */ - static startCapture() { - capture = true; - } - - static stopCapture() { - capture = false; - } - - static getOutput() { - return output; - } - - static resetOutput() { - output = ""; - } - - /** - * returns a FileWriter that is rooted at the supplied subdirectory - * @param {String} subdir the subdirectory under which to root the - * returned FileWriter - * @returns {FileWriter} - */ - writerForDir(subdir) { - if (path.isAbsolute(subdir)) { - throw new Error( - `Cannot create subdir writer for absolute path: ${subdir}`, - ); - } - return new FileWriter(`${this.baseDir}/${subdir}`); - } - - /** - * copies a file from a source directory to a destination name - * @param {String} source path to source file - * @param {String} dest relative path to destination file - * @param {String} [header=undefined] optional text to prepend to destination - * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) - */ - copyFile(source, dest, header) { - if (path.isAbsolute(dest)) { - throw new Error(`Cannot write to absolute path: ${dest}`); - } - dest = path.resolve(this.baseDir, dest); - mkdir(path.dirname(dest), { recursive: true }); - let contents; - if (header) { - contents = header + fs.readFileSync(source, "utf8"); - } else { - contents = fs.readFileSync(source); - } - fs.writeFileSync(dest, contents); - } - - /** - * returns a content writer for writing content to the supplied file. - * @param {String|null} file the relative path to the file or the special - * values `"-"` or `null` for writing to the console - * @returns {ContentWriter} - */ - writeFile(file) { - if (file === null || file === "-") { - return new ConsoleWriter(); - } - if (path.isAbsolute(file)) { - throw new Error(`Cannot write to absolute path: ${file}`); - } - file = path.resolve(this.baseDir, file); - mkdir(path.dirname(file), { recursive: true }); - return new FileContentWriter(fs.openSync(file, "w")); - } -} - -module.exports = FileWriter; diff --git a/v-next/hardhat/assets/lib-report/lib/path.cjs b/v-next/hardhat/assets/lib-report/lib/path.cjs deleted file mode 100644 index 89f8033883b..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/path.cjs +++ /dev/null @@ -1,169 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const path = require("node:path"); -let parsePath = path.parse; -let SEP = path.sep; -const origParser = parsePath; -const origSep = SEP; - -function makeRelativeNormalizedPath(str, sep) { - const parsed = parsePath(str); - let root = parsed.root; - let dir; - let file = parsed.base; - let quoted; - let pos; - - // handle a weird windows case separately - if (sep === "\\") { - pos = root.indexOf(":\\"); - if (pos >= 0) { - root = root.substring(0, pos + 2); - } - } - dir = parsed.dir.substring(root.length); - - if (str === "") { - return []; - } - - if (sep !== "/") { - quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); - dir = dir.replace(quoted, "/"); - file = file.replace(quoted, "/"); // excessively paranoid? - } - - if (dir !== "") { - dir = `${dir}/${file}`; - } else { - dir = file; - } - if (dir.substring(0, 1) === "/") { - dir = dir.substring(1); - } - dir = dir.split(/\/+/); - return dir; -} - -class Path { - constructor(strOrArray) { - if (Array.isArray(strOrArray)) { - this.v = strOrArray; - } else if (typeof strOrArray === "string") { - this.v = makeRelativeNormalizedPath(strOrArray, SEP); - } else { - throw new Error( - `Invalid Path argument must be string or array:${strOrArray}`, - ); - } - } - - toString() { - return this.v.join("/"); - } - - hasParent() { - return this.v.length > 0; - } - - parent() { - if (!this.hasParent()) { - throw new Error("Unable to get parent for 0 elem path"); - } - const p = this.v.slice(); - p.pop(); - return new Path(p); - } - - elements() { - return this.v.slice(); - } - - name() { - return this.v.slice(-1)[0]; - } - - contains(other) { - let i; - if (other.length > this.length) { - return false; - } - for (i = 0; i < other.length; i += 1) { - if (this.v[i] !== other.v[i]) { - return false; - } - } - return true; - } - - ancestorOf(other) { - return other.contains(this) && other.length !== this.length; - } - - descendantOf(other) { - return this.contains(other) && other.length !== this.length; - } - - commonPrefixPath(other) { - const len = this.length > other.length ? other.length : this.length; - let i; - const ret = []; - - for (i = 0; i < len; i += 1) { - if (this.v[i] === other.v[i]) { - ret.push(this.v[i]); - } else { - break; - } - } - return new Path(ret); - } - - static compare(a, b) { - const al = a.length; - const bl = b.length; - - if (al < bl) { - return -1; - } - - if (al > bl) { - return 1; - } - - const astr = a.toString(); - const bstr = b.toString(); - return astr < bstr ? -1 : astr > bstr ? 1 : 0; - } -} - -["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { - Object.defineProperty(Path.prototype, fn, { - value(...args) { - return this.v[fn](...args); - }, - }); -}); - -Object.defineProperty(Path.prototype, "length", { - enumerable: true, - get() { - return this.v.length; - }, -}); - -module.exports = Path; -Path.tester = { - setParserAndSep(p, sep) { - parsePath = p; - SEP = sep; - }, - reset() { - parsePath = origParser; - SEP = origSep; - }, -}; diff --git a/v-next/hardhat/assets/lib-report/lib/report-base.cjs b/v-next/hardhat/assets/lib-report/lib/report-base.cjs deleted file mode 100644 index 1575121b53b..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/report-base.cjs +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -// TODO: switch to class private field when targeting node.js 12 -const _summarizer = Symbol("ReportBase.#summarizer"); - -class ReportBase { - constructor(opts = {}) { - this[_summarizer] = opts.summarizer; - } - - execute(context) { - context.getTree(this[_summarizer]).visit(this, context); - } -} - -module.exports = ReportBase; diff --git a/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs deleted file mode 100644 index cb2c429bc9a..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/summarizer-factory.cjs +++ /dev/null @@ -1,284 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const coverage = require("../../lib-coverage/index.cjs"); -const Path = require("./path.cjs"); -const { BaseNode, BaseTree } = require("./tree.cjs"); - -class ReportNode extends BaseNode { - constructor(path, fileCoverage) { - super(); - - this.path = path; - this.parent = null; - this.fileCoverage = fileCoverage; - this.children = []; - } - - static createRoot(children) { - const root = new ReportNode(new Path([])); - - children.forEach((child) => { - root.addChild(child); - }); - - return root; - } - - addChild(child) { - child.parent = this; - this.children.push(child); - } - - asRelative(p) { - if (p.substring(0, 1) === "/") { - return p.substring(1); - } - return p; - } - - getQualifiedName() { - return this.asRelative(this.path.toString()); - } - - getRelativeName() { - const parent = this.getParent(); - const myPath = this.path; - let relPath; - let i; - const parentPath = parent ? parent.path : new Path([]); - if (parentPath.ancestorOf(myPath)) { - relPath = new Path(myPath.elements()); - for (i = 0; i < parentPath.length; i += 1) { - relPath.shift(); - } - return this.asRelative(relPath.toString()); - } - return this.asRelative(this.path.toString()); - } - - getParent() { - return this.parent; - } - - getChildren() { - return this.children; - } - - isSummary() { - return !this.fileCoverage; - } - - getFileCoverage() { - return this.fileCoverage; - } - - getCoverageSummary(filesOnly) { - const cacheProp = `c_${filesOnly ? "files" : "full"}`; - let summary; - - if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { - return this[cacheProp]; - } - - if (!this.isSummary()) { - summary = this.getFileCoverage().toSummary(); - } else { - let count = 0; - summary = coverage.createCoverageSummary(); - this.getChildren().forEach((child) => { - if (filesOnly && child.isSummary()) { - return; - } - count += 1; - summary.merge(child.getCoverageSummary(filesOnly)); - }); - if (count === 0 && filesOnly) { - summary = null; - } - } - this[cacheProp] = summary; - return summary; - } -} - -class ReportTree extends BaseTree { - constructor(root, childPrefix) { - super(root); - - const maybePrefix = (node) => { - if (childPrefix && !node.isRoot()) { - node.path.unshift(childPrefix); - } - }; - this.visit({ - onDetail: maybePrefix, - onSummary(node) { - maybePrefix(node); - node.children.sort((a, b) => { - const astr = a.path.toString(); - const bstr = b.path.toString(); - return astr < bstr - ? -1 - : astr > bstr - ? 1 - : /* istanbul ignore next */ 0; - }); - }, - }); - } -} - -function findCommonParent(paths) { - return paths.reduce( - (common, path) => common.commonPrefixPath(path), - paths[0] || new Path([]), - ); -} - -function findOrCreateParent(parentPath, nodeMap, created = () => {}) { - let parent = nodeMap[parentPath.toString()]; - - if (!parent) { - parent = new ReportNode(parentPath); - nodeMap[parentPath.toString()] = parent; - created(parentPath, parent); - } - - return parent; -} - -function toDirParents(list) { - const nodeMap = Object.create(null); - list.forEach((o) => { - const parent = findOrCreateParent(o.path.parent(), nodeMap); - parent.addChild(new ReportNode(o.path, o.fileCoverage)); - }); - - return Object.values(nodeMap); -} - -function addAllPaths(topPaths, nodeMap, path, node) { - const parent = findOrCreateParent( - path.parent(), - nodeMap, - (parentPath, parent) => { - if (parentPath.hasParent()) { - addAllPaths(topPaths, nodeMap, parentPath, parent); - } else { - topPaths.push(parent); - } - }, - ); - - parent.addChild(node); -} - -function foldIntoOneDir(node, parent) { - const { children } = node; - if (children.length === 1 && !children[0].fileCoverage) { - children[0].parent = parent; - return foldIntoOneDir(children[0], parent); - } - node.children = children.map((child) => foldIntoOneDir(child, node)); - return node; -} - -function pkgSummaryPrefix(dirParents, commonParent) { - if (!dirParents.some((dp) => dp.path.length === 0)) { - return; - } - - if (commonParent.length === 0) { - return "root"; - } - - return commonParent.name(); -} - -class SummarizerFactory { - constructor(coverageMap, defaultSummarizer = "pkg") { - this._coverageMap = coverageMap; - this._defaultSummarizer = defaultSummarizer; - this._initialList = coverageMap.files().map((filePath) => ({ - filePath, - path: new Path(filePath), - fileCoverage: coverageMap.fileCoverageFor(filePath), - })); - this._commonParent = findCommonParent( - this._initialList.map((o) => o.path.parent()), - ); - if (this._commonParent.length > 0) { - this._initialList.forEach((o) => { - o.path.splice(0, this._commonParent.length); - }); - } - } - - get defaultSummarizer() { - return this[this._defaultSummarizer]; - } - - get flat() { - if (!this._flat) { - this._flat = new ReportTree( - ReportNode.createRoot( - this._initialList.map( - (node) => new ReportNode(node.path, node.fileCoverage), - ), - ), - ); - } - - return this._flat; - } - - _createPkg() { - const dirParents = toDirParents(this._initialList); - if (dirParents.length === 1) { - return new ReportTree(dirParents[0]); - } - - return new ReportTree( - ReportNode.createRoot(dirParents), - pkgSummaryPrefix(dirParents, this._commonParent), - ); - } - - get pkg() { - if (!this._pkg) { - this._pkg = this._createPkg(); - } - - return this._pkg; - } - - _createNested() { - const nodeMap = Object.create(null); - const topPaths = []; - this._initialList.forEach((o) => { - const node = new ReportNode(o.path, o.fileCoverage); - addAllPaths(topPaths, nodeMap, o.path, node); - }); - - const topNodes = topPaths.map((node) => foldIntoOneDir(node)); - if (topNodes.length === 1) { - return new ReportTree(topNodes[0]); - } - - return new ReportTree(ReportNode.createRoot(topNodes)); - } - - get nested() { - if (!this._nested) { - this._nested = this._createNested(); - } - - return this._nested; - } -} - -module.exports = SummarizerFactory; diff --git a/v-next/hardhat/assets/lib-report/lib/tree.cjs b/v-next/hardhat/assets/lib-report/lib/tree.cjs deleted file mode 100644 index 6bac8b98ea4..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/tree.cjs +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -/** - * An object with methods that are called during the traversal of the coverage tree. - * A visitor has the following methods that are called during tree traversal. - * - * * `onStart(root, state)` - called before traversal begins - * * `onSummary(node, state)` - called for every summary node - * * `onDetail(node, state)` - called for every detail node - * * `onSummaryEnd(node, state)` - called after all children have been visited for - * a summary node. - * * `onEnd(root, state)` - called after traversal ends - * - * @param delegate - a partial visitor that only implements the methods of interest - * The visitor object supplies the missing methods as noops. For example, reports - * that only need the final coverage summary need implement `onStart` and nothing - * else. Reports that use only detailed coverage information need implement `onDetail` - * and nothing else. - * @constructor - */ -class Visitor { - constructor(delegate) { - this.delegate = delegate; - } -} - -["Start", "End", "Summary", "SummaryEnd", "Detail"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(Visitor.prototype, fn, { - writable: true, - value(node, state) { - if (typeof this.delegate[fn] === "function") { - this.delegate[fn](node, state); - } - }, - }); - }); - -class CompositeVisitor extends Visitor { - constructor(visitors) { - super(); - - if (!Array.isArray(visitors)) { - visitors = [visitors]; - } - this.visitors = visitors.map((v) => { - if (v instanceof Visitor) { - return v; - } - return new Visitor(v); - }); - } -} - -["Start", "Summary", "SummaryEnd", "Detail", "End"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(CompositeVisitor.prototype, fn, { - value(node, state) { - this.visitors.forEach((v) => { - v[fn](node, state); - }); - }, - }); - }); - -class BaseNode { - isRoot() { - return !this.getParent(); - } - - /** - * visit all nodes depth-first from this node down. Note that `onStart` - * and `onEnd` are never called on the visitor even if the current - * node is the root of the tree. - * @param visitor a full visitor that is called during tree traversal - * @param state optional state that is passed around - */ - visit(visitor, state) { - if (this.isSummary()) { - visitor.onSummary(this, state); - } else { - visitor.onDetail(this, state); - } - - this.getChildren().forEach((child) => { - child.visit(visitor, state); - }); - - if (this.isSummary()) { - visitor.onSummaryEnd(this, state); - } - } -} - -/** - * abstract base class for a coverage tree. - * @constructor - */ -class BaseTree { - constructor(root) { - this.root = root; - } - - /** - * returns the root node of the tree - */ - getRoot() { - return this.root; - } - - /** - * visits the tree depth-first with the supplied partial visitor - * @param visitor - a potentially partial visitor - * @param state - the state to be passed around during tree traversal - */ - visit(visitor, state) { - if (!(visitor instanceof Visitor)) { - visitor = new Visitor(visitor); - } - visitor.onStart(this.getRoot(), state); - this.getRoot().visit(visitor, state); - visitor.onEnd(this.getRoot(), state); - } -} - -module.exports = { - BaseTree, - BaseNode, - Visitor, - CompositeVisitor, -}; diff --git a/v-next/hardhat/assets/lib-report/lib/watermarks.cjs b/v-next/hardhat/assets/lib-report/lib/watermarks.cjs deleted file mode 100644 index 0be610017a9..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/watermarks.cjs +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -module.exports = { - getDefault() { - return { - statements: [50, 80], - functions: [50, 80], - branches: [50, 80], - lines: [50, 80], - }; - }, -}; diff --git a/v-next/hardhat/assets/lib-report/lib/xml-writer.cjs b/v-next/hardhat/assets/lib-report/lib/xml-writer.cjs deleted file mode 100644 index aea68a1b53f..00000000000 --- a/v-next/hardhat/assets/lib-report/lib/xml-writer.cjs +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const INDENT = " "; - -function attrString(attrs) { - return Object.entries(attrs || {}) - .map(([k, v]) => ` ${k}="${v}"`) - .join(""); -} - -/** - * a utility class to produce well-formed, indented XML - * @param {ContentWriter} contentWriter the content writer that this utility wraps - * @constructor - */ -class XMLWriter { - constructor(contentWriter) { - this.cw = contentWriter; - this.stack = []; - } - - indent(str) { - return this.stack.map(() => INDENT).join("") + str; - } - - /** - * writes the opening XML tag with the supplied attributes - * @param {String} name tag name - * @param {Object} [attrs=null] attrs attributes for the tag - */ - openTag(name, attrs) { - const str = this.indent(`<${name + attrString(attrs)}>`); - this.cw.println(str); - this.stack.push(name); - } - - /** - * closes an open XML tag. - * @param {String} name - tag name to close. This must match the writer's - * notion of the tag that is currently open. - */ - closeTag(name) { - if (this.stack.length === 0) { - throw new Error(`Attempt to close tag ${name} when not opened`); - } - const stashed = this.stack.pop(); - const str = ``; - - if (stashed !== name) { - throw new Error( - `Attempt to close tag ${name} when ${stashed} was the one open`, - ); - } - this.cw.println(this.indent(str)); - } - - /** - * writes a tag and its value opening and closing it at the same time - * @param {String} name tag name - * @param {Object} [attrs=null] attrs tag attributes - * @param {String} [content=null] content optional tag content - */ - inlineTag(name, attrs, content) { - let str = "<" + name + attrString(attrs); - if (content) { - str += `>${content}`; - } else { - str += "/>"; - } - str = this.indent(str); - this.cw.println(str); - } - - /** - * closes all open tags and ends the document - */ - closeAll() { - this.stack - .slice() - .reverse() - .forEach((name) => { - this.closeTag(name); - }); - } -} - -module.exports = XMLWriter; diff --git a/v-next/hardhat/package.json b/v-next/hardhat/package.json index 7036f4a16a7..c0603c6745a 100644 --- a/v-next/hardhat/package.json +++ b/v-next/hardhat/package.json @@ -90,6 +90,7 @@ "@nomicfoundation/edr": "0.12.0-next.7", "@nomicfoundation/hardhat-errors": "workspace:^3.0.2", "@nomicfoundation/hardhat-utils": "workspace:^3.0.2", + "@nomicfoundation/hardhat-vendors": "workspace:^3.0.0", "@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.1", "@nomicfoundation/solidity-analyzer": "^0.1.1", "@sentry/core": "^9.4.0", From 1856995b016d35664a1a23bd48a3154a7eadf8a7 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 23 Oct 2025 11:11:38 +0200 Subject: [PATCH 14/32] add postbuild script and re-organize coverage-manager --- v-next/hardhat-vendors/package.json | 6 +- v-next/hardhat-vendors/src/copy-assets.ts | 33 ++++ v-next/hardhat-vendors/tsconfig.json | 5 + .../coverage/coverage-manager.ts | 163 ++++++++---------- 4 files changed, 116 insertions(+), 91 deletions(-) create mode 100644 v-next/hardhat-vendors/src/copy-assets.ts diff --git a/v-next/hardhat-vendors/package.json b/v-next/hardhat-vendors/package.json index 70c31f7e7d1..2652066bd14 100644 --- a/v-next/hardhat-vendors/package.json +++ b/v-next/hardhat-vendors/package.json @@ -11,7 +11,10 @@ "author": "Nomic Foundation", "license": "MIT", "type": "module", - "exports": {}, + "exports": { + "./coverage": "./dist/src/coverage/index.js", + "./coverage/types": "./dist/src/coverage/types.js" + }, "keywords": [ "hardhat" ], @@ -26,6 +29,7 @@ "pretest": "pnpm build", "pretest:only": "pnpm build", "build": "tsc --build .", + "postbuild": "node dist/src/copy-assets.js", "prepublishOnly": "pnpm build", "clean": "rimraf dist" }, diff --git a/v-next/hardhat-vendors/src/copy-assets.ts b/v-next/hardhat-vendors/src/copy-assets.ts new file mode 100644 index 00000000000..d25dc2610ca --- /dev/null +++ b/v-next/hardhat-vendors/src/copy-assets.ts @@ -0,0 +1,33 @@ +import { cp } from "node:fs/promises"; +import path from "node:path"; + +async function copyFolder(from: string, to: string): Promise { + const src = path.resolve(from); + const dest = path.resolve(to); + + await cp(src, dest, { recursive: true, force: true }); + console.log(`Copied folder from ${src} -> ${dest}`); +} + +// eslint-disable-next-line no-restricted-syntax -- allow in this post build script +await copyFolder( + path.resolve( + process.cwd(), + "src", + "coverage", + "istanbul-reports", + "lib", + "html", + "assets", + ), + path.resolve( + process.cwd(), + "dist", + "src", + "coverage", + "istanbul-reports", + "lib", + "html", + "assets", + ), +); diff --git a/v-next/hardhat-vendors/tsconfig.json b/v-next/hardhat-vendors/tsconfig.json index 1bfe4cc4db1..bb8c328bb79 100644 --- a/v-next/hardhat-vendors/tsconfig.json +++ b/v-next/hardhat-vendors/tsconfig.json @@ -1,4 +1,9 @@ { "extends": "../config/tsconfig.base.json", + "compilerOptions": { + "isolatedDeclarations": false, + "allowJs": true + }, + "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts"], "references": [] } diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index 59e83b60998..28dbc6b5d6c 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -5,21 +5,26 @@ import type { Statement, Tag, } from "./types.js"; -import type { FileCoverageData } from "../../../../assets/lib-coverage/index.js"; +import type { FileCoverageData } from "@nomicfoundation/hardhat-vendors/coverage/types"; -import fs from "node:fs"; import path from "node:path"; import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors"; import { ensureDir, getAllFilesMatching, + mkdir, readJsonFile, + readUtf8File, remove, writeJsonFile, writeUtf8File, } from "@nomicfoundation/hardhat-utils/fs"; -import { findClosestPackageRoot } from "@nomicfoundation/hardhat-utils/package"; +import { + libCoverage, + libReport, + reports, +} from "@nomicfoundation/hardhat-vendors/coverage"; import debug from "debug"; const log = debug("hardhat:core:coverage:coverage-manager"); @@ -112,95 +117,12 @@ export class CoverageManagerImplementation implements CoverageManager { await writeUtf8File(lcovReportPath, lcovReport); log(`Saved lcov report to ${lcovReportPath}`); + const htmlReportPath = path.join(this.#coveragePath, "html"); + await this.#writeHtmlReport(report, htmlReportPath); + console.log(`Saved html report to ${htmlReportPath}`); + console.log(markdownReport); log("Printed markdown report"); - - await this.#lcovToHtml(report); - - // - // - // - } - - async #lcovToHtml(report: Report): Promise { - const reporter: "html" = "html"; - - const outDir = "coverage/html"; - const baseDir = process.cwd(); - const treatUnlisted = false; // treatUnlistedLinesAsUncovered - - const packageRoot = await findClosestPackageRoot(import.meta.url); - const { libCoverage } = await import( - path.join(packageRoot, "assets", "index.js") - ); - const { libReport } = await import( - path.join(packageRoot, "assets", "index.js") - ); - const { reports } = await import( - path.join(packageRoot, "assets", "index.js") - ); - - const coverageMap = libCoverage.createCoverageMap({}); - - for (const [relativePath, file] of Object.entries(report)) { - const filePath = path.isAbsolute(relativePath) - ? relativePath - : path.join(baseDir, relativePath); - - // Optional: read source to set end columns to the actual line length - let lines: string[] = []; - try { - lines = fs.readFileSync(filePath, "utf8").split(/\r?\n/); - } catch { - // ok if the file is not available on disk; columns will be 0 - } - - // Build the set of line candidates we want to color - const candidates = new Set(); - for (const line of file.lineExecutionCounts.keys()) candidates.add(line); - for (const line of file.unexecutedLines) candidates.add(line); - if (treatUnlisted && lines.length > 0) { - for (let i = 1; i <= lines.length; i++) candidates.add(i); - } - - const statementMap: FileCoverageData["statementMap"] = {}; - const s: FileCoverageData["s"] = {}; - let sid = 0; - - for (const lineNo of [...candidates].sort((a, b) => a - b)) { - const id = String(++sid); - const endCol = lines[lineNo - 1]?.length ?? 0; - - // Make each source line a pseudo "statement" - statementMap[id] = { - start: { line: lineNo, column: 0 }, - end: { line: lineNo, column: endCol }, - }; - - const hits = file.lineExecutionCounts.get(lineNo) ?? 0; - s[id] = hits > 0 ? 1 : 0; // green if hit, red if not - } - - const fileCoverage: FileCoverageData = { - path: filePath, // you can also keep relativePath if you prefer - statementMap, - s, - fnMap: {}, - f: {}, - branchMap: {}, - b: {}, - }; - - coverageMap.addFileCoverage(fileCoverage); - } - - fs.mkdirSync(outDir, { recursive: true }); - - const context = libReport.createContext({ dir: outDir, coverageMap }); - - reports.create(reporter).execute(context); - - console.log(`HTML report written to ${path.resolve(outDir)}`); } public enableReport(): void { @@ -638,4 +560,65 @@ export class CoverageManagerImplementation implements CoverageManager { return rows.map((row) => `| ${row.join(" | ")} |`).join("\n"); } + + async #writeHtmlReport( + report: Report, + htmlReportPath: string, + ): Promise { + const baseDir = process.cwd(); + const coverageMap = libCoverage.createCoverageMap({}); + + // Construct coverage data for each tested file, + // detailing whether each line was executed or not. + for (const [p, fileCoverageInput] of Object.entries(report)) { + const testedFilePath = path.isAbsolute(p) ? p : path.join(baseDir, p); + + const sourceLines = (await readUtf8File(testedFilePath)).split(/\r?\n/); + + // Build the set of line candidates we want to color + const linesToColor = Array.from( + new Set([ + ...fileCoverageInput.lineExecutionCounts.keys(), + ...fileCoverageInput.unexecutedLines, + ]), + ); + + const statementMap: FileCoverageData["statementMap"] = {}; + const s: FileCoverageData["s"] = {}; + + for (const lineNo of linesToColor) { + const id = `${lineNo}`; + const endCol = sourceLines[lineNo - 1]?.length ?? 0; + + statementMap[id] = { + start: { line: lineNo, column: 0 }, + end: { line: lineNo, column: endCol }, + }; + + const hits = fileCoverageInput.lineExecutionCounts.get(lineNo) ?? 0; + s[id] = hits > 0 ? 1 : 0; // green if hit, red if not + } + + const fileCoverage: FileCoverageData = { + path: testedFilePath, + statementMap, + s, + fnMap: {}, + f: {}, + branchMap: {}, + b: {}, + }; + + coverageMap.addFileCoverage(fileCoverage); + } + + await mkdir(htmlReportPath); + + const context = libReport.createContext({ + dir: htmlReportPath, + coverageMap, + }); + + reports.create("html", undefined).execute(context); + } } From e646399fdfa6641a54fe2442ff1054776cb5e3f3 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:04:14 +0100 Subject: [PATCH 15/32] exclude js, cjs, css, png from the gitignore --- .../hardhat-vendors/dist/src/copy-assets.js | 11 + .../dist/src/coverage/html-escaper/index.cjs | 23 + .../dist/src/coverage/index.js | 7 + .../src/coverage/istanbul-reports/index.cjs | 23 + .../istanbul-reports/lib/html/annotator.cjs | 249 ++++++++++ .../istanbul-reports/lib/html/assets/base.css | 224 +++++++++ .../lib/html/assets/block-navigation.js | 86 ++++ .../lib/html/assets/favicon.png | Bin 0 -> 445 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../lib/html/assets/sorter.js | 209 +++++++++ .../lib/html/assets/vendor/prettify.css | 1 + .../lib/html/assets/vendor/prettify.js | 1 + .../istanbul-reports/lib/html/index.cjs | 339 ++++++++++++++ .../lib/html/insertion-text.cjs | 103 ++++ .../dist/src/coverage/lib-coverage/index.cjs | 62 +++ .../lib-coverage/lib/coverage-map.cjs | 115 +++++ .../lib-coverage/lib/coverage-summary.cjs | 101 ++++ .../lib-coverage/lib/data-properties.cjs | 12 + .../lib-coverage/lib/file-coverage.cjs | 387 +++++++++++++++ .../src/coverage/lib-coverage/lib/percent.cjs | 16 + .../dist/src/coverage/lib-report/index.js | 37 ++ .../src/coverage/lib-report/lib/context.cjs | 119 +++++ .../coverage/lib-report/lib/file-writer.cjs | 165 +++++++ .../dist/src/coverage/lib-report/lib/path.cjs | 148 ++++++ .../coverage/lib-report/lib/report-base.cjs | 13 + .../lib-report/lib/summarizer-factory.cjs | 224 +++++++++ .../dist/src/coverage/lib-report/lib/tree.cjs | 126 +++++ .../coverage/lib-report/lib/watermarks.cjs | 16 + .../coverage/lib-report/lib/xml-writer.cjs | 81 ++++ .../dist/src/coverage/types.js | 2 + .../hardhat-vendors/node_modules/@types/bn.js | 1 + .../src/coverage/html-escaper/index.cjs | 24 + v-next/hardhat-vendors/src/coverage/index.js | 8 + .../src/coverage/istanbul-reports/index.cjs | 24 + .../istanbul-reports/lib/html/annotator.cjs | 294 ++++++++++++ .../istanbul-reports/lib/html/assets/base.css | 224 +++++++++ .../lib/html/assets/block-navigation.js | 86 ++++ .../lib/html/assets/favicon.png | Bin 0 -> 445 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../lib/html/assets/sorter.js | 209 +++++++++ .../lib/html/assets/vendor/prettify.css | 1 + .../lib/html/assets/vendor/prettify.js | 1 + .../istanbul-reports/lib/html/index.cjs | 409 ++++++++++++++++ .../lib/html/insertion-text.cjs | 114 +++++ .../src/coverage/lib-coverage/index.cjs | 64 +++ .../lib-coverage/lib/coverage-map.cjs | 128 +++++ .../lib-coverage/lib/coverage-summary.cjs | 112 +++++ .../lib-coverage/lib/data-properties.cjs | 12 + .../lib-coverage/lib/file-coverage.cjs | 442 ++++++++++++++++++ .../src/coverage/lib-coverage/lib/percent.cjs | 15 + .../src/coverage/lib-report/ciao.cjs | 0 .../src/coverage/lib-report/index.cjs | 40 ++ .../src/coverage/lib-report/lib/context.cjs | 132 ++++++ .../coverage/lib-report/lib/file-writer.cjs | 184 ++++++++ .../src/coverage/lib-report/lib/path.cjs | 169 +++++++ .../coverage/lib-report/lib/report-base.cjs | 16 + .../lib-report/lib/summarizer-factory.cjs | 284 +++++++++++ .../src/coverage/lib-report/lib/tree.cjs | 137 ++++++ .../coverage/lib-report/lib/watermarks.cjs | 15 + .../coverage/lib-report/lib/xml-writer.cjs | 90 ++++ 60 files changed, 6135 insertions(+) create mode 100644 v-next/hardhat-vendors/dist/src/copy-assets.js create mode 100644 v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/index.js create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs create mode 100644 v-next/hardhat-vendors/dist/src/coverage/types.js create mode 120000 v-next/hardhat-vendors/node_modules/@types/bn.js create mode 100644 v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/index.js create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/favicon.png create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/ciao.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/index.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs create mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs diff --git a/v-next/hardhat-vendors/dist/src/copy-assets.js b/v-next/hardhat-vendors/dist/src/copy-assets.js new file mode 100644 index 00000000000..af80157c693 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/copy-assets.js @@ -0,0 +1,11 @@ +import { cp } from "node:fs/promises"; +import path from "node:path"; +async function copyFolder(from, to) { + const src = path.resolve(from); + const dest = path.resolve(to); + await cp(src, dest, { recursive: true, force: true }); + console.log(`Copied folder from ${src} -> ${dest}`); +} +// eslint-disable-next-line no-restricted-syntax -- allow in this post build script +await copyFolder(path.resolve(process.cwd(), "src", "coverage", "istanbul-reports", "lib", "html", "assets"), path.resolve(process.cwd(), "dist", "src", "coverage", "istanbul-reports", "lib", "html", "assets")); +//# sourceMappingURL=copy-assets.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs new file mode 100644 index 00000000000..1f0f029ec88 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs @@ -0,0 +1,23 @@ +"use strict"; +const { replace } = ""; +// escape +const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; +const ca = /[&<>'"]/g; +const esca = { + "&": "&", + "<": "<", + ">": ">", + "'": "'", + '"': """, +}; +const pe = (m) => esca[m]; +/** + * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. + * @param {string} es the input to safely escape + * @returns {string} the escaped input, and it **throws** an error if + * the input type is unexpected, except for boolean and numbers, + * converted as string. + */ +const escape = (es) => replace.call(es, ca, pe); +exports.escape = escape; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/index.js b/v-next/hardhat-vendors/dist/src/coverage/index.js new file mode 100644 index 00000000000..ef05ce4b00b --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/index.js @@ -0,0 +1,7 @@ +import libCoverage from "./lib-coverage/index.cjs"; +export { libCoverage }; +import libReport from "./lib-report/index.js"; +export { libReport }; +import reports from "./istanbul-reports/index.cjs"; +export { reports }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs new file mode 100644 index 00000000000..ddfb1ef1c6d --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs @@ -0,0 +1,23 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); +module.exports = { + create(name, cfg) { + cfg = cfg || {}; + let Cons; + try { + Cons = require(path.join(__dirname, "lib", name, "index.cjs")); + } + catch (e) { + if (e.code !== "MODULE_NOT_FOUND") { + throw e; + } + Cons = require(name); + } + return new Cons(cfg); + }, +}; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs new file mode 100644 index 00000000000..cda3f88caf1 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs @@ -0,0 +1,249 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const InsertionText = require("./insertion-text.cjs"); +const lt = "\u0001"; +const gt = "\u0002"; +const RE_LT = //g; +const RE_AMP = /&/g; +var RE_lt = /\u0001/g; +var RE_gt = /\u0002/g; +function title(str) { + return ' title="' + str + '" '; +} +function customEscape(text) { + text = String(text); + return text + .replace(RE_AMP, "&") + .replace(RE_LT, "<") + .replace(RE_GT, ">") + .replace(RE_lt, "<") + .replace(RE_gt, ">"); +} +function annotateLines(fileCoverage, structuredText) { + const lineStats = fileCoverage.getLineCoverage(); + if (!lineStats) { + return; + } + Object.entries(lineStats).forEach(([lineNumber, count]) => { + if (structuredText[lineNumber]) { + structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; + structuredText[lineNumber].hits = count; + } + }); +} +function annotateStatements(fileCoverage, structuredText) { + const statementStats = fileCoverage.s; + const statementMeta = fileCoverage.statementMap; + Object.entries(statementStats).forEach(([stName, count]) => { + const meta = statementMeta[stName]; + const type = count > 0 ? "yes" : "no"; + const startCol = meta.start.column; + let endCol = meta.end.column + 1; + const startLine = meta.start.line; + const endLine = meta.end.line; + const openSpan = lt + + 'span class="' + + (meta.skip ? "cstat-skip" : "cstat-no") + + '"' + + title("statement not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); + } + }); +} +function annotateFunctions(fileCoverage, structuredText) { + const fnStats = fileCoverage.f; + const fnMeta = fileCoverage.fnMap; + if (!fnStats) { + return; + } + Object.entries(fnStats).forEach(([fName, count]) => { + const meta = fnMeta[fName]; + const type = count > 0 ? "yes" : "no"; + // Some versions of the instrumenter in the wild populate 'func' + // but not 'decl': + const decl = meta.decl || meta.loc; + const startCol = decl.start.column; + let endCol = decl.end.column + 1; + const startLine = decl.start.line; + const endLine = decl.end.line; + const openSpan = lt + + 'span class="' + + (meta.skip ? "fstat-skip" : "fstat-no") + + '"' + + title("function not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); + } + }); +} +function annotateBranches(fileCoverage, structuredText) { + const branchStats = fileCoverage.b; + const branchMeta = fileCoverage.branchMap; + if (!branchStats) { + return; + } + Object.entries(branchStats).forEach(([branchName, branchArray]) => { + const sumCount = branchArray.reduce((p, n) => p + n, 0); + const metaArray = branchMeta[branchName].locations; + let i; + let count; + let meta; + let startCol; + let endCol; + let startLine; + let endLine; + let openSpan; + let closeSpan; + let text; + // only highlight if partial branches are missing or if there is a + // single uncovered branch. + if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { + // Need to recover the metaArray placeholder item to count an implicit else + if ( + // Check if the branch is a conditional if branch. + branchMeta[branchName].type === "if" && + // Check if the branch has an implicit else. + branchArray.length === 2 && + // Check if the implicit else branch is unaccounted for. + metaArray.length === 1 && + // Check if the implicit else branch is uncovered. + branchArray[1] === 0) { + metaArray[1] = { + start: {}, + end: {}, + }; + } + for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { + count = branchArray[i]; + meta = metaArray[i]; + startCol = meta.start.column; + endCol = meta.end.column + 1; + startLine = meta.start.line; + endLine = meta.end.line; + openSpan = + lt + + 'span class="branch-' + + i + + " " + + (meta.skip ? "cbranch-skip" : "cbranch-no") + + '"' + + title("branch not covered") + + gt; + closeSpan = lt + "/span" + gt; + // If the branch is an implicit else from an if statement, + // then the coverage report won't show a statistic. + // Therefore, the previous branch will be used to report that + // there is no coverage on that implicit branch. + if (count === 0 && + startLine === undefined && + branchMeta[branchName].type === "if") { + const prevMeta = metaArray[i - 1]; + startCol = prevMeta.start.column; + endCol = prevMeta.end.column + 1; + startLine = prevMeta.start.line; + endLine = prevMeta.end.line; + } + if (count === 0 && structuredText[startLine]) { + //skip branches taken + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + if (branchMeta[branchName].type === "if") { + // 'if' is a special case + // since the else branch might not be visible, being nonexistent + text.insertAt(startCol, lt + + 'span class="' + + (meta.skip ? "skip-if-branch" : "missing-if-branch") + + '"' + + title((i === 0 ? "if" : "else") + " path not taken") + + gt + + (i === 0 ? "I" : "E") + + lt + + "/span" + + gt, true, false); + } + else { + text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); + } + } + } + } + }); +} +function annotateSourceCode(fileCoverage, sourceStore) { + let codeArray; + let lineCoverageArray; + try { + const sourceText = sourceStore.getSource(fileCoverage.path); + const code = sourceText.split(/(?:\r?\n)|\r/); + let count = 0; + const structured = code.map((str) => { + count += 1; + return { + line: count, + covered: "neutral", + hits: 0, + text: new InsertionText(str, true), + }; + }); + structured.unshift({ + line: 0, + covered: null, + text: new InsertionText(""), + }); + annotateLines(fileCoverage, structured); + //note: order is important, since statements typically result in spanning the whole line and doing branches late + //causes mismatched tags + annotateBranches(fileCoverage, structured); + annotateFunctions(fileCoverage, structured); + annotateStatements(fileCoverage, structured); + structured.shift(); + codeArray = structured.map((item) => customEscape(item.text.toString()) || " "); + lineCoverageArray = structured.map((item) => ({ + covered: item.covered, + hits: item.hits > 0 ? item.hits + "x" : " ", + })); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: structured.length, + }; + } + catch (ex) { + codeArray = [ex.message]; + lineCoverageArray = [{ covered: "no", hits: 0 }]; + String(ex.stack || "") + .split(/\r?\n/) + .forEach((line) => { + codeArray.push(line); + lineCoverageArray.push({ covered: "no", hits: 0 }); + }); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: codeArray.length, + }; + } +} +module.exports = annotateSourceCode; +//# sourceMappingURL=annotator.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css new file mode 100644 index 00000000000..f418035b469 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js new file mode 100644 index 00000000000..eb527848ee7 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js @@ -0,0 +1,86 @@ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js new file mode 100644 index 00000000000..83122f78ace --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js @@ -0,0 +1,209 @@ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css new file mode 100644 index 00000000000..b317a7cda31 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js new file mode 100644 index 00000000000..ef51e038668 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs new file mode 100644 index 00000000000..a2390d3ad04 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs @@ -0,0 +1,339 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const path = require("node:path"); +const html = require("../../../html-escaper/index.cjs"); +const ReportBase = require("../../../lib-report/lib/report-base.cjs"); +const annotator = require("./annotator.cjs"); +function htmlHead(details) { + return ` + + Code coverage report for ${html.escape(details.entity)} + + + + + + + + `; +} +function headerTemplate(details) { + function metricsTemplate({ pct, covered, total }, kind) { + return ` +
+ ${pct}% + ${kind} + ${covered}/${total} +
+ `; + } + function skipTemplate(metrics) { + const statements = metrics.statements.skipped; + const branches = metrics.branches.skipped; + const functions = metrics.functions.skipped; + const countLabel = (c, label, plural) => c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; + const skips = [].concat(countLabel(statements, "statement", "s"), countLabel(functions, "function", "s"), countLabel(branches, "branch", "es")); + if (skips.length === 0) { + return ""; + } + return ` +
+ ${skips.join(", ")} + Ignored      +
+ `; + } + return ` + + +${htmlHead(details)} + +
+
+

${details.pathHtml}

+
+ ${metricsTemplate(details.metrics.statements, "Statements")} + ${metricsTemplate(details.metrics.branches, "Branches")} + ${metricsTemplate(details.metrics.functions, "Functions")} + ${metricsTemplate(details.metrics.lines, "Lines")} + ${skipTemplate(details.metrics)} +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+ `; +} +function footerTemplate(details) { + return ` +
+
+ + + + + + + + `; +} +function detailTemplate(data) { + const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); + const lineLink = (num) => `${num}`; + const lineCount = (line) => `${line.hits}`; + /* This is rendered in a `
`, need control of all whitespace. */
+    return [
+        "",
+        `${lineNumbers.map(lineLink).join("\n")}`,
+        `${data.lineCoverage
+            .map(lineCount)
+            .join("\n")}`,
+        `
${data.annotatedCode.join("\n")}
`, + "", + ].join(""); +} +const summaryTableHeader = [ + '
', + '', + "", + "", + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + "", + "", + "", +].join("\n"); +function summaryLineTemplate(details) { + const { reportClasses, metrics, file, output } = details; + const percentGraph = (pct) => { + if (!isFinite(pct)) { + return ""; + } + const cls = ["cover-fill"]; + if (pct === 100) { + cls.push("cover-full"); + } + pct = Math.floor(pct); + return [ + `
`, + `
`, + ].join(""); + }; + const summaryType = (type, showGraph = false) => { + const info = metrics[type]; + const reportClass = reportClasses[type]; + const result = [ + ``, + ``, + ]; + if (showGraph) { + result.unshift(``); + } + return result; + }; + return [] + .concat("", ``, summaryType("statements", true), summaryType("branches"), summaryType("functions"), summaryType("lines"), "\n") + .join("\n\t"); +} +const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, `
${percentGraph(info.pct)}
`, `
${html.escape(file)}
", "
"].join("\n"); +const emptyClasses = { + statements: "empty", + lines: "empty", + functions: "empty", + branches: "empty", +}; +const standardLinkMapper = { + getPath(node) { + if (typeof node === "string") { + return node; + } + let filePath = node.getQualifiedName(); + if (node.isSummary()) { + if (filePath !== "") { + filePath += "/index.html"; + } + else { + filePath = "index.html"; + } + } + else { + filePath += ".html"; + } + return filePath; + }, + relativePath(source, target) { + const targetPath = this.getPath(target); + const sourcePath = path.dirname(this.getPath(source)); + return path.posix.relative(sourcePath, targetPath); + }, + assetPath(node, name) { + return this.relativePath(this.getPath(node), name); + }, +}; +function fixPct(metrics) { + Object.keys(emptyClasses).forEach((key) => { + metrics[key].pct = 0; + }); + return metrics; +} +class HtmlReport extends ReportBase { + constructor(opts) { + super(); + this.verbose = opts.verbose; + this.linkMapper = opts.linkMapper || standardLinkMapper; + this.subdir = opts.subdir || ""; + this.date = new Date().toISOString(); + this.skipEmpty = opts.skipEmpty; + } + getBreadcrumbHtml(node) { + let parent = node.getParent(); + const nodePath = []; + while (parent) { + nodePath.push(parent); + parent = parent.getParent(); + } + const linkPath = nodePath.map((ancestor) => { + const target = this.linkMapper.relativePath(node, ancestor); + const name = ancestor.getRelativeName() || "All files"; + return '' + name + ""; + }); + linkPath.reverse(); + return linkPath.length > 0 + ? linkPath.join(" / ") + " " + node.getRelativeName() + : "All files"; + } + fillTemplate(node, templateData, context) { + const linkMapper = this.linkMapper; + const summary = node.getCoverageSummary(); + templateData.entity = node.getQualifiedName() || "All files"; + templateData.metrics = summary; + templateData.reportClass = context.classForPercent("statements", summary.statements.pct); + templateData.pathHtml = this.getBreadcrumbHtml(node); + templateData.base = { + css: linkMapper.assetPath(node, "base.css"), + }; + templateData.sorter = { + js: linkMapper.assetPath(node, "sorter.js"), + image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), + }; + templateData.blockNavigation = { + js: linkMapper.assetPath(node, "block-navigation.js"), + }; + templateData.prettify = { + js: linkMapper.assetPath(node, "prettify.js"), + css: linkMapper.assetPath(node, "prettify.css"), + }; + templateData.favicon = linkMapper.assetPath(node, "favicon.png"); + } + getTemplateData() { + return { datetime: this.date }; + } + getWriter(context) { + if (!this.subdir) { + return context.writer; + } + return context.writer.writerForDir(this.subdir); + } + onStart(root, context) { + const assetHeaders = { + ".js": "/* eslint-disable */\n", + }; + [".", "vendor"].forEach((subdir) => { + const writer = this.getWriter(context); + const srcDir = path.resolve(__dirname, "assets", subdir); + fs.readdirSync(srcDir).forEach((f) => { + const resolvedSource = path.resolve(srcDir, f); + const resolvedDestination = "."; + const stat = fs.statSync(resolvedSource); + let dest; + if (stat.isFile()) { + dest = resolvedDestination + "/" + f; + if (this.verbose) { + console.log("Write asset: " + dest); + } + writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); + } + }); + }); + } + onSummary(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + const children = node.getChildren(); + const skipEmpty = this.skipEmpty; + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write(summaryTableHeader); + children.forEach((child) => { + const metrics = child.getCoverageSummary(); + const isEmpty = metrics.isEmpty(); + if (skipEmpty && isEmpty) { + return; + } + const reportClasses = isEmpty + ? emptyClasses + : { + statements: context.classForPercent("statements", metrics.statements.pct), + lines: context.classForPercent("lines", metrics.lines.pct), + functions: context.classForPercent("functions", metrics.functions.pct), + branches: context.classForPercent("branches", metrics.branches.pct), + }; + const data = { + metrics: isEmpty ? fixPct(metrics) : metrics, + reportClasses, + file: child.getRelativeName(), + output: linkMapper.relativePath(node, child), + }; + cw.write(summaryLineTemplate(data) + "\n"); + }); + cw.write(summaryTableFooter); + cw.write(footerTemplate(templateData)); + cw.close(); + } + onDetail(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write('
\n');
+        cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
+        cw.write("
\n"); + cw.write(footerTemplate(templateData)); + cw.close(); + } +} +module.exports = HtmlReport; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs new file mode 100644 index 00000000000..6cc92030ae8 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs @@ -0,0 +1,103 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +function InsertionText(text, consumeBlanks) { + this.text = text; + this.origLength = text.length; + this.offsets = []; + this.consumeBlanks = consumeBlanks; + this.startPos = this.findFirstNonBlank(); + this.endPos = this.findLastNonBlank(); +} +const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; +InsertionText.prototype = { + findFirstNonBlank() { + let pos = -1; + const text = this.text; + const len = text.length; + let i; + for (i = 0; i < len; i += 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + findLastNonBlank() { + const text = this.text; + const len = text.length; + let pos = text.length + 1; + let i; + for (i = len - 1; i >= 0; i -= 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + originalLength() { + return this.origLength; + }, + insertAt(col, str, insertBefore, consumeBlanks) { + consumeBlanks = + typeof consumeBlanks === 'undefined' + ? this.consumeBlanks + : consumeBlanks; + col = col > this.originalLength() ? this.originalLength() : col; + col = col < 0 ? 0 : col; + if (consumeBlanks) { + if (col <= this.startPos) { + col = 0; + } + if (col > this.endPos) { + col = this.origLength; + } + } + const len = str.length; + const offset = this.findOffset(col, len, insertBefore); + const realPos = col + offset; + const text = this.text; + this.text = text.substring(0, realPos) + str + text.substring(realPos); + return this; + }, + findOffset(pos, len, insertBefore) { + const offsets = this.offsets; + let offsetObj; + let cumulativeOffset = 0; + let i; + for (i = 0; i < offsets.length; i += 1) { + offsetObj = offsets[i]; + if (offsetObj.pos < pos || + (offsetObj.pos === pos && !insertBefore)) { + cumulativeOffset += offsetObj.len; + } + if (offsetObj.pos >= pos) { + break; + } + } + if (offsetObj && offsetObj.pos === pos) { + offsetObj.len += len; + } + else { + offsets.splice(i, 0, { pos, len }); + } + return cumulativeOffset; + }, + wrap(startPos, startText, endPos, endText, consumeBlanks) { + this.insertAt(startPos, startText, true, consumeBlanks); + this.insertAt(endPos, endText, false, consumeBlanks); + return this; + }, + wrapLine(startText, endText) { + this.wrap(0, startText, this.originalLength(), endText); + }, + toString() { + return this.text; + } +}; +module.exports = InsertionText; +//# sourceMappingURL=insertion-text.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs new file mode 100644 index 00000000000..86ee436a301 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs @@ -0,0 +1,62 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +/** + * istanbul-lib-coverage exports an API that allows you to create and manipulate + * file coverage, coverage maps (a set of file coverage objects) and summary + * coverage objects. File coverage for the same file can be merged as can + * entire coverage maps. + * + * @module Exports + */ +const { FileCoverage } = require("./lib/file-coverage.cjs"); +const { CoverageMap } = require("./lib/coverage-map.cjs"); +const { CoverageSummary } = require("./lib/coverage-summary.cjs"); +module.exports = { + /** + * creates a coverage summary object + * @param {Object} obj an argument with the same semantics + * as the one passed to the `CoverageSummary` constructor + * @returns {CoverageSummary} + */ + createCoverageSummary(obj) { + if (obj && obj instanceof CoverageSummary) { + return obj; + } + return new CoverageSummary(obj); + }, + /** + * creates a CoverageMap object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the CoverageMap constructor. + * @returns {CoverageMap} + */ + createCoverageMap(obj) { + if (obj && obj instanceof CoverageMap) { + return obj; + } + return new CoverageMap(obj); + }, + /** + * creates a FileCoverage object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the FileCoverage constructor. + * @returns {FileCoverage} + */ + createFileCoverage(obj) { + if (obj && obj instanceof FileCoverage) { + return obj; + } + return new FileCoverage(obj); + }, +}; +/** classes exported for reuse */ +module.exports.classes = { + /** + * the file coverage constructor + */ + FileCoverage, +}; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs new file mode 100644 index 00000000000..bad5422758a --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs @@ -0,0 +1,115 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const { FileCoverage } = require("./file-coverage.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); +function maybeConstruct(obj, klass) { + if (obj instanceof klass) { + return obj; + } + return new klass(obj); +} +function loadMap(source) { + const data = Object.create(null); + if (!source) { + return data; + } + Object.entries(source).forEach(([k, cov]) => { + data[k] = maybeConstruct(cov, FileCoverage); + }); + return data; +} +/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ +class CoverageMap { + /** + * @constructor + * @param {Object} [obj=undefined] obj A coverage map from which to initialize this + * map's contents. This can be the raw global coverage object. + */ + constructor(obj) { + if (obj instanceof CoverageMap) { + this.data = obj.data; + } + else { + this.data = loadMap(obj); + } + } + /** + * merges a second coverage map into this one + * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged + * correctly for the same files and additional file coverage keys are created + * as needed. + */ + merge(obj) { + const other = maybeConstruct(obj, CoverageMap); + Object.values(other.data).forEach((fc) => { + this.addFileCoverage(fc); + }); + } + /** + * filter the coveragemap based on the callback provided + * @param {Function (filename)} callback - Returns true if the path + * should be included in the coveragemap. False if it should be + * removed. + */ + filter(callback) { + Object.keys(this.data).forEach((k) => { + if (!callback(k)) { + delete this.data[k]; + } + }); + } + /** + * returns a JSON-serializable POJO for this coverage map + * @returns {Object} + */ + toJSON() { + return this.data; + } + /** + * returns an array for file paths for which this map has coverage + * @returns {Array{string}} - array of files + */ + files() { + return Object.keys(this.data); + } + /** + * returns the file coverage for the specified file. + * @param {String} file + * @returns {FileCoverage} + */ + fileCoverageFor(file) { + const fc = this.data[file]; + if (!fc) { + throw new Error(`No file coverage available for: ${file}`); + } + return fc; + } + addFileCoverage(fc) { + const cov = new FileCoverage(fc); + const { path } = cov; + if (this.data[path]) { + this.data[path].merge(cov); + } + else { + this.data[path] = cov; + } + } + /** + * returns the coverage summary for all the file coverage objects in this map. + * @returns {CoverageSummary} + */ + getCoverageSummary() { + const ret = new CoverageSummary(); + Object.values(this.data).forEach((fc) => { + ret.merge(fc.toSummary()); + }); + return ret; + } +} +module.exports = { + CoverageMap, +}; +//# sourceMappingURL=coverage-map.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs new file mode 100644 index 00000000000..8762aca9296 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs @@ -0,0 +1,101 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +function blankSummary() { + const empty = () => ({ + total: 0, + covered: 0, + skipped: 0, + pct: "Unknown", + }); + return { + lines: empty(), + statements: empty(), + functions: empty(), + branches: empty(), + branchesTrue: empty(), + }; +} +// asserts that a data object "looks like" a summary coverage object +function assertValidSummary(obj) { + const valid = obj && obj.lines && obj.statements && obj.functions && obj.branches; + if (!valid) { + throw new Error("Invalid summary coverage object, missing keys, found:" + + Object.keys(obj).join(",")); + } +} +/** + * CoverageSummary provides a summary of code coverage . It exposes 4 properties, + * `lines`, `statements`, `branches`, and `functions`. Each of these properties + * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. + * `pct` is a percentage number (0-100). + */ +class CoverageSummary { + /** + * @constructor + * @param {Object|CoverageSummary} [obj=undefined] an optional data object or + * another coverage summary to initialize this object with. + */ + constructor(obj) { + if (!obj) { + this.data = blankSummary(); + } + else if (obj instanceof CoverageSummary) { + this.data = obj.data; + } + else { + this.data = obj; + } + assertValidSummary(this.data); + } + /** + * merges a second summary coverage object into this one + * @param {CoverageSummary} obj - another coverage summary object + */ + merge(obj) { + const keys = [ + "lines", + "statements", + "branches", + "functions", + "branchesTrue", + ]; + keys.forEach((key) => { + if (obj[key]) { + this[key].total += obj[key].total; + this[key].covered += obj[key].covered; + this[key].skipped += obj[key].skipped; + this[key].pct = percent(this[key].covered, this[key].total); + } + }); + return this; + } + /** + * returns a POJO that is JSON serializable. May be used to get the raw + * summary object. + */ + toJSON() { + return this.data; + } + /** + * return true if summary has no lines of code + */ + isEmpty() { + return this.lines.total === 0; + } +} +dataProperties(CoverageSummary, [ + "lines", + "statements", + "functions", + "branches", + "branchesTrue", +]); +module.exports = { + CoverageSummary, +}; +//# sourceMappingURL=coverage-summary.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs new file mode 100644 index 00000000000..e8a22f8e598 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs @@ -0,0 +1,12 @@ +"use strict"; +module.exports = function dataProperties(klass, properties) { + properties.forEach((p) => { + Object.defineProperty(klass.prototype, p, { + enumerable: true, + get() { + return this.data[p]; + }, + }); + }); +}; +//# sourceMappingURL=data-properties.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs new file mode 100644 index 00000000000..72900a820ba --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs @@ -0,0 +1,387 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); +// returns a data object that represents empty coverage +function emptyCoverage(filePath, reportLogic) { + const cov = { + path: filePath, + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {}, + }; + if (reportLogic) + cov.bT = {}; + return cov; +} +// asserts that a data object "looks like" a coverage object +function assertValidObject(obj) { + const valid = obj && + obj.path && + obj.statementMap && + obj.fnMap && + obj.branchMap && + obj.s && + obj.f && + obj.b; + if (!valid) { + throw new Error("Invalid file coverage object, missing keys, found:" + + Object.keys(obj).join(",")); + } +} +const keyFromLoc = ({ start, end }) => `${start.line}|${start.column}|${end.line}|${end.column}`; +const isObj = (o) => !!o && typeof o === "object"; +const isLineCol = (o) => isObj(o) && typeof o.line === "number" && typeof o.column === "number"; +const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); +const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); +// When merging, we can have a case where two ranges cover +// the same block of code with `hits=1`, and each carve out a +// different range with `hits=0` to indicate it's uncovered. +// Find the nearest container so that we can properly indicate +// that both sections are hit. +// Returns null if no containing item is found. +const findNearestContainer = (item, map) => { + const itemLoc = getLoc(item); + if (!itemLoc) + return null; + // the B item is not an identified range in the A set, BUT + // it may be contained by an identified A range. If so, then + // any hit of that containing A range counts as a hit of this + // B range as well. We have to find the *narrowest* containing + // range to be accurate, since ranges can be hit and un-hit + // in a nested fashion. + let nearestContainingItem = null; + let containerDistance = null; + let containerKey = null; + for (const [i, mapItem] of Object.entries(map)) { + const mapLoc = getLoc(mapItem); + if (!mapLoc) + continue; + // contained if all of line distances are > 0 + // or line distance is 0 and col dist is >= 0 + const distance = [ + itemLoc.start.line - mapLoc.start.line, + itemLoc.start.column - mapLoc.start.column, + mapLoc.end.line - itemLoc.end.line, + mapLoc.end.column - itemLoc.end.column, + ]; + if (distance[0] < 0 || + distance[2] < 0 || + (distance[0] === 0 && distance[1] < 0) || + (distance[2] === 0 && distance[3] < 0)) { + continue; + } + if (nearestContainingItem === null) { + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + continue; + } + // closer line more relevant than closer column + const closerBefore = distance[0] < containerDistance[0] || + (distance[0] === 0 && distance[1] < containerDistance[1]); + const closerAfter = distance[2] < containerDistance[2] || + (distance[2] === 0 && distance[3] < containerDistance[3]); + if (closerBefore || closerAfter) { + // closer + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + } + } + return containerKey; +}; +// either add two numbers, or all matching entries in a number[] +const addHits = (aHits, bHits) => { + if (typeof aHits === "number" && typeof bHits === "number") { + return aHits + bHits; + } + else if (Array.isArray(aHits) && Array.isArray(bHits)) { + return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); + } + return null; +}; +const addNearestContainerHits = (item, itemHits, map, mapHits) => { + const container = findNearestContainer(item, map); + if (container) { + return addHits(itemHits, mapHits[container]); + } + else { + return itemHits; + } +}; +const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { + const aItems = {}; + for (const [key, itemHits] of Object.entries(aHits)) { + const item = aMap[key]; + aItems[itemKey(item)] = [itemHits, item]; + } + const bItems = {}; + for (const [key, itemHits] of Object.entries(bHits)) { + const item = bMap[key]; + bItems[itemKey(item)] = [itemHits, item]; + } + const mergedItems = {}; + for (const [key, aValue] of Object.entries(aItems)) { + let aItemHits = aValue[0]; + const aItem = aValue[1]; + const bValue = bItems[key]; + if (!bValue) { + // not an identified range in b, but might be contained by one + aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); + } + else { + // is an identified range in b, so add the hits together + aItemHits = addHits(aItemHits, bValue[0]); + } + mergedItems[key] = [aItemHits, aItem]; + } + // now find the items in b that are not in a. already added matches. + for (const [key, bValue] of Object.entries(bItems)) { + let bItemHits = bValue[0]; + const bItem = bValue[1]; + if (mergedItems[key]) + continue; + // not an identified range in b, but might be contained by one + bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); + mergedItems[key] = [bItemHits, bItem]; + } + const hits = {}; + const map = {}; + Object.values(mergedItems).forEach(([itemHits, item], i) => { + hits[i] = itemHits; + map[i] = item; + }); + return [hits, map]; +}; +/** + * provides a read-only view of coverage for a single file. + * The deep structure of this object is documented elsewhere. It has the following + * properties: + * + * * `path` - the file path for which coverage is being tracked + * * `statementMap` - map of statement locations keyed by statement index + * * `fnMap` - map of function metadata keyed by function index + * * `branchMap` - map of branch metadata keyed by branch index + * * `s` - hit counts for statements + * * `f` - hit count for functions + * * `b` - hit count for branches + */ +class FileCoverage { + /** + * @constructor + * @param {Object|FileCoverage|String} pathOrObj is a string that initializes + * and empty coverage object with the specified file path or a data object that + * has all the required properties for a file coverage object. + */ + constructor(pathOrObj, reportLogic = false) { + if (!pathOrObj) { + throw new Error("Coverage must be initialized with a path or an object"); + } + if (typeof pathOrObj === "string") { + this.data = emptyCoverage(pathOrObj, reportLogic); + } + else if (pathOrObj instanceof FileCoverage) { + this.data = pathOrObj.data; + } + else if (typeof pathOrObj === "object") { + this.data = pathOrObj; + } + else { + throw new Error("Invalid argument to coverage constructor"); + } + assertValidObject(this.data); + } + /** + * returns computed line coverage from statement coverage. + * This is a map of hits keyed by line number in the source. + */ + getLineCoverage() { + const statementMap = this.data.statementMap; + const statements = this.data.s; + const lineMap = Object.create(null); + Object.entries(statements).forEach(([st, count]) => { + /* istanbul ignore if: is this even possible? */ + if (!statementMap[st]) { + return; + } + const { line } = statementMap[st].start; + const prevVal = lineMap[line]; + if (prevVal === undefined || prevVal < count) { + lineMap[line] = count; + } + }); + return lineMap; + } + /** + * returns an array of uncovered line numbers. + * @returns {Array} an array of line numbers for which no hits have been + * collected. + */ + getUncoveredLines() { + const lc = this.getLineCoverage(); + const ret = []; + Object.entries(lc).forEach(([l, hits]) => { + if (hits === 0) { + ret.push(l); + } + }); + return ret; + } + /** + * returns a map of branch coverage by source line number. + * @returns {Object} an object keyed by line number. Each object + * has a `covered`, `total` and `coverage` (percentage) property. + */ + getBranchCoverageByLine() { + const branchMap = this.branchMap; + const branches = this.b; + const ret = {}; + Object.entries(branchMap).forEach(([k, map]) => { + const line = map.line || map.loc.start.line; + const branchData = branches[k]; + ret[line] = ret[line] || []; + ret[line].push(...branchData); + }); + Object.entries(ret).forEach(([k, dataArray]) => { + const covered = dataArray.filter((item) => item > 0); + const coverage = (covered.length / dataArray.length) * 100; + ret[k] = { + covered: covered.length, + total: dataArray.length, + coverage, + }; + }); + return ret; + } + /** + * return a JSON-serializable POJO for this file coverage object + */ + toJSON() { + return this.data; + } + /** + * merges a second coverage object into this one, updating hit counts + * @param {FileCoverage} other - the coverage object to be merged into this one. + * Note that the other object should have the same structure as this one (same file). + */ + merge(other) { + if (other.all === true) { + return; + } + if (this.all === true) { + this.data = other.data; + return; + } + let [hits, map] = mergeProp(this.s, this.statementMap, other.s, other.statementMap); + this.data.s = hits; + this.data.statementMap = map; + const keyFromLocProp = (x) => keyFromLoc(x.loc); + const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); + [hits, map] = mergeProp(this.f, this.fnMap, other.f, other.fnMap, keyFromLocProp); + this.data.f = hits; + this.data.fnMap = map; + [hits, map] = mergeProp(this.b, this.branchMap, other.b, other.branchMap, keyFromLocationsProp); + this.data.b = hits; + this.data.branchMap = map; + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT && other.bT) { + [hits, map] = mergeProp(this.bT, this.branchMap, other.bT, other.branchMap, keyFromLocationsProp); + this.data.bT = hits; + } + } + computeSimpleTotals(property) { + let stats = this[property]; + if (typeof stats === "function") { + stats = stats.call(this); + } + const ret = { + total: Object.keys(stats).length, + covered: Object.values(stats).filter((v) => !!v).length, + skipped: 0, + }; + ret.pct = percent(ret.covered, ret.total); + return ret; + } + computeBranchTotals(property) { + const stats = this[property]; + const ret = { total: 0, covered: 0, skipped: 0 }; + Object.values(stats).forEach((branches) => { + ret.covered += branches.filter((hits) => hits > 0).length; + ret.total += branches.length; + }); + ret.pct = percent(ret.covered, ret.total); + return ret; + } + /** + * resets hit counts for all statements, functions and branches + * in this coverage object resulting in zero coverage. + */ + resetHits() { + const statements = this.s; + const functions = this.f; + const branches = this.b; + const branchesTrue = this.bT; + Object.keys(statements).forEach((s) => { + statements[s] = 0; + }); + Object.keys(functions).forEach((f) => { + functions[f] = 0; + }); + Object.keys(branches).forEach((b) => { + branches[b].fill(0); + }); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (branchesTrue) { + Object.keys(branchesTrue).forEach((bT) => { + branchesTrue[bT].fill(0); + }); + } + } + /** + * returns a CoverageSummary for this file coverage object + * @returns {CoverageSummary} + */ + toSummary() { + const ret = {}; + ret.lines = this.computeSimpleTotals("getLineCoverage"); + ret.functions = this.computeSimpleTotals("f", "fnMap"); + ret.statements = this.computeSimpleTotals("s", "statementMap"); + ret.branches = this.computeBranchTotals("b"); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT) { + ret.branchesTrue = this.computeBranchTotals("bT"); + } + return new CoverageSummary(ret); + } +} +// expose coverage data attributes +dataProperties(FileCoverage, [ + "path", + "statementMap", + "fnMap", + "branchMap", + "s", + "f", + "b", + "bT", + "all", +]); +module.exports = { + FileCoverage, + // exported for testing + findNearestContainer, + addHits, + addNearestContainerHits, +}; +//# sourceMappingURL=file-coverage.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs new file mode 100644 index 00000000000..7e0b1ee99e0 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs @@ -0,0 +1,16 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +module.exports = function percent(covered, total) { + let tmp; + if (total > 0) { + tmp = (1000 * 100 * covered) / total; + return Math.floor(tmp / 10) / 100; + } + else { + return 100.0; + } +}; +//# sourceMappingURL=percent.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js b/v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js new file mode 100644 index 00000000000..65e53decb91 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js @@ -0,0 +1,37 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +/** + * @module Exports + */ +const Context = require("./lib/context.cjs"); +const watermarks = require("./lib/watermarks.cjs"); +const ReportBase = require("./lib/report-base.cjs"); +module.exports = { + /** + * returns a reporting context for the supplied options + * @param {Object} [opts=null] opts + * @returns {Context} + */ + createContext(opts) { + return new Context(opts); + }, + /** + * returns the default watermarks that would be used when not + * overridden + * @returns {Object} an object with `statements`, `functions`, `branches`, + * and `line` keys. Each value is a 2 element array that has the low and + * high watermark as percentages. + */ + getDefaultWatermarks() { + return watermarks.getDefault(); + }, + /** + * Base class for all reports + */ + ReportBase, +}; +export {}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs new file mode 100644 index 00000000000..5eb918c4098 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs @@ -0,0 +1,119 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const FileWriter = require("./file-writer.cjs"); +const XMLWriter = require("./xml-writer.cjs"); +const tree = require("./tree.cjs"); +const watermarks = require("./watermarks.cjs"); +const SummarizerFactory = require("./summarizer-factory.cjs"); +function defaultSourceLookup(path) { + try { + return fs.readFileSync(path, "utf8"); + } + catch (ex) { + throw new Error(`Unable to lookup source: ${path} (${ex.message})`); + } +} +function normalizeWatermarks(specified = {}) { + Object.entries(watermarks.getDefault()).forEach(([k, value]) => { + const specValue = specified[k]; + if (!Array.isArray(specValue) || specValue.length !== 2) { + specified[k] = value; + } + }); + return specified; +} +/** + * A reporting context that is passed to report implementations + * @param {Object} [opts=null] opts options + * @param {String} [opts.dir='coverage'] opts.dir the reporting directory + * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for + * statements, lines, branches and functions + * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a + * function that returns source code given a file path. Defaults to + * filesystem lookups based on path. + * @constructor + */ +class Context { + constructor(opts) { + this.dir = opts.dir || "coverage"; + this.watermarks = normalizeWatermarks(opts.watermarks); + this.sourceFinder = opts.sourceFinder || defaultSourceLookup; + this._summarizerFactory = new SummarizerFactory(opts.coverageMap, opts.defaultSummarizer); + this.data = {}; + } + /** + * returns a FileWriter implementation for reporting use. Also available + * as the `writer` property on the context. + * @returns {Writer} + */ + getWriter() { + return this.writer; + } + /** + * returns the source code for the specified file path or throws if + * the source could not be found. + * @param {String} filePath the file path as found in a file coverage object + * @returns {String} the source code + */ + getSource(filePath) { + return this.sourceFinder(filePath); + } + /** + * returns the coverage class given a coverage + * types and a percentage value. + * @param {String} type - the coverage type, one of `statements`, `functions`, + * `branches`, or `lines` + * @param {Number} value - the percentage value + * @returns {String} one of `high`, `medium` or `low` + */ + classForPercent(type, value) { + const watermarks = this.watermarks[type]; + if (!watermarks) { + return "unknown"; + } + if (value < watermarks[0]) { + return "low"; + } + if (value >= watermarks[1]) { + return "high"; + } + return "medium"; + } + /** + * returns an XML writer for the supplied content writer + * @param {ContentWriter} contentWriter the content writer to which the returned XML writer + * writes data + * @returns {XMLWriter} + */ + getXMLWriter(contentWriter) { + return new XMLWriter(contentWriter); + } + /** + * returns a full visitor given a partial one. + * @param {Object} partialVisitor a partial visitor only having the functions of + * interest to the caller. These functions are called with a scope that is the + * supplied object. + * @returns {Visitor} + */ + getVisitor(partialVisitor) { + return new tree.Visitor(partialVisitor); + } + getTree(name = "defaultSummarizer") { + return this._summarizerFactory[name]; + } +} +Object.defineProperty(Context.prototype, "writer", { + enumerable: true, + get() { + if (!this.data.writer) { + this.data.writer = new FileWriter(this.dir); + } + return this.data.writer; + }, +}); +module.exports = Context; +//# sourceMappingURL=context.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs new file mode 100644 index 00000000000..a79f541a0b6 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs @@ -0,0 +1,165 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); +const fs = require("node:fs"); +const { mkdir } = require("node:fs/promises"); +/** + * Base class for writing content + * @class ContentWriter + * @constructor + */ +class ContentWriter { + /** + * returns the colorized version of a string. Typically, + * content writers that write to files will return the + * same string and ones writing to a tty will wrap it in + * appropriate escape sequences. + * @param {String} str the string to colorize + * @param {String} clazz one of `high`, `medium` or `low` + * @returns {String} the colorized form of the string + */ + colorize(str /*, clazz*/) { + return str; + } + /** + * writes a string appended with a newline to the destination + * @param {String} str the string to write + */ + println(str) { + this.write(`${str}\n`); + } + /** + * closes this content writer. Should be called after all writes are complete. + */ + close() { } +} +/** + * a content writer that writes to a file + * @param {Number} fd - the file descriptor + * @extends ContentWriter + * @constructor + */ +class FileContentWriter extends ContentWriter { + constructor(fd) { + super(); + this.fd = fd; + } + write(str) { + fs.writeSync(this.fd, str); + } + close() { + fs.closeSync(this.fd); + } +} +// allow stdout to be captured for tests. +let capture = false; +let output = ""; +/** + * a content writer that writes to the console + * @extends ContentWriter + * @constructor + */ +class ConsoleWriter extends ContentWriter { + write(str) { + if (capture) { + output += str; + } + else { + process.stdout.write(str); + } + } + colorize(str, clazz) { + const colors = { + low: "31;1", + medium: "33;1", + high: "32;1", + }; + return str; + } +} +/** + * utility for writing files under a specific directory + * @class FileWriter + * @param {String} baseDir the base directory under which files should be written + * @constructor + */ +class FileWriter { + constructor(baseDir) { + if (!baseDir) { + throw new Error("baseDir must be specified"); + } + this.baseDir = baseDir; + } + /** + * static helpers for capturing stdout report output; + * super useful for tests! + */ + static startCapture() { + capture = true; + } + static stopCapture() { + capture = false; + } + static getOutput() { + return output; + } + static resetOutput() { + output = ""; + } + /** + * returns a FileWriter that is rooted at the supplied subdirectory + * @param {String} subdir the subdirectory under which to root the + * returned FileWriter + * @returns {FileWriter} + */ + writerForDir(subdir) { + if (path.isAbsolute(subdir)) { + throw new Error(`Cannot create subdir writer for absolute path: ${subdir}`); + } + return new FileWriter(`${this.baseDir}/${subdir}`); + } + /** + * copies a file from a source directory to a destination name + * @param {String} source path to source file + * @param {String} dest relative path to destination file + * @param {String} [header=undefined] optional text to prepend to destination + * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) + */ + copyFile(source, dest, header) { + if (path.isAbsolute(dest)) { + throw new Error(`Cannot write to absolute path: ${dest}`); + } + dest = path.resolve(this.baseDir, dest); + mkdir(path.dirname(dest), { recursive: true }); + let contents; + if (header) { + contents = header + fs.readFileSync(source, "utf8"); + } + else { + contents = fs.readFileSync(source); + } + fs.writeFileSync(dest, contents); + } + /** + * returns a content writer for writing content to the supplied file. + * @param {String|null} file the relative path to the file or the special + * values `"-"` or `null` for writing to the console + * @returns {ContentWriter} + */ + writeFile(file) { + if (file === null || file === "-") { + return new ConsoleWriter(); + } + if (path.isAbsolute(file)) { + throw new Error(`Cannot write to absolute path: ${file}`); + } + file = path.resolve(this.baseDir, file); + mkdir(path.dirname(file), { recursive: true }); + return new FileContentWriter(fs.openSync(file, "w")); + } +} +module.exports = FileWriter; +//# sourceMappingURL=file-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs new file mode 100644 index 00000000000..3bf30e53640 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs @@ -0,0 +1,148 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const path = require("node:path"); +let parsePath = path.parse; +let SEP = path.sep; +const origParser = parsePath; +const origSep = SEP; +function makeRelativeNormalizedPath(str, sep) { + const parsed = parsePath(str); + let root = parsed.root; + let dir; + let file = parsed.base; + let quoted; + let pos; + // handle a weird windows case separately + if (sep === "\\") { + pos = root.indexOf(":\\"); + if (pos >= 0) { + root = root.substring(0, pos + 2); + } + } + dir = parsed.dir.substring(root.length); + if (str === "") { + return []; + } + if (sep !== "/") { + quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); + dir = dir.replace(quoted, "/"); + file = file.replace(quoted, "/"); // excessively paranoid? + } + if (dir !== "") { + dir = `${dir}/${file}`; + } + else { + dir = file; + } + if (dir.substring(0, 1) === "/") { + dir = dir.substring(1); + } + dir = dir.split(/\/+/); + return dir; +} +class Path { + constructor(strOrArray) { + if (Array.isArray(strOrArray)) { + this.v = strOrArray; + } + else if (typeof strOrArray === "string") { + this.v = makeRelativeNormalizedPath(strOrArray, SEP); + } + else { + throw new Error(`Invalid Path argument must be string or array:${strOrArray}`); + } + } + toString() { + return this.v.join("/"); + } + hasParent() { + return this.v.length > 0; + } + parent() { + if (!this.hasParent()) { + throw new Error("Unable to get parent for 0 elem path"); + } + const p = this.v.slice(); + p.pop(); + return new Path(p); + } + elements() { + return this.v.slice(); + } + name() { + return this.v.slice(-1)[0]; + } + contains(other) { + let i; + if (other.length > this.length) { + return false; + } + for (i = 0; i < other.length; i += 1) { + if (this.v[i] !== other.v[i]) { + return false; + } + } + return true; + } + ancestorOf(other) { + return other.contains(this) && other.length !== this.length; + } + descendantOf(other) { + return this.contains(other) && other.length !== this.length; + } + commonPrefixPath(other) { + const len = this.length > other.length ? other.length : this.length; + let i; + const ret = []; + for (i = 0; i < len; i += 1) { + if (this.v[i] === other.v[i]) { + ret.push(this.v[i]); + } + else { + break; + } + } + return new Path(ret); + } + static compare(a, b) { + const al = a.length; + const bl = b.length; + if (al < bl) { + return -1; + } + if (al > bl) { + return 1; + } + const astr = a.toString(); + const bstr = b.toString(); + return astr < bstr ? -1 : astr > bstr ? 1 : 0; + } +} +["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { + Object.defineProperty(Path.prototype, fn, { + value(...args) { + return this.v[fn](...args); + }, + }); +}); +Object.defineProperty(Path.prototype, "length", { + enumerable: true, + get() { + return this.v.length; + }, +}); +module.exports = Path; +Path.tester = { + setParserAndSep(p, sep) { + parsePath = p; + SEP = sep; + }, + reset() { + parsePath = origParser; + SEP = origSep; + }, +}; +//# sourceMappingURL=path.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs new file mode 100644 index 00000000000..70ba85a2c68 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs @@ -0,0 +1,13 @@ +"use strict"; +// TODO: switch to class private field when targeting node.js 12 +const _summarizer = Symbol("ReportBase.#summarizer"); +class ReportBase { + constructor(opts = {}) { + this[_summarizer] = opts.summarizer; + } + execute(context) { + context.getTree(this[_summarizer]).visit(this, context); + } +} +module.exports = ReportBase; +//# sourceMappingURL=report-base.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs new file mode 100644 index 00000000000..795a0d73ee1 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs @@ -0,0 +1,224 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const coverage = require("../../lib-coverage/index.cjs"); +const Path = require("./path.cjs"); +const { BaseNode, BaseTree } = require("./tree.cjs"); +class ReportNode extends BaseNode { + constructor(path, fileCoverage) { + super(); + this.path = path; + this.parent = null; + this.fileCoverage = fileCoverage; + this.children = []; + } + static createRoot(children) { + const root = new ReportNode(new Path([])); + children.forEach((child) => { + root.addChild(child); + }); + return root; + } + addChild(child) { + child.parent = this; + this.children.push(child); + } + asRelative(p) { + if (p.substring(0, 1) === "/") { + return p.substring(1); + } + return p; + } + getQualifiedName() { + return this.asRelative(this.path.toString()); + } + getRelativeName() { + const parent = this.getParent(); + const myPath = this.path; + let relPath; + let i; + const parentPath = parent ? parent.path : new Path([]); + if (parentPath.ancestorOf(myPath)) { + relPath = new Path(myPath.elements()); + for (i = 0; i < parentPath.length; i += 1) { + relPath.shift(); + } + return this.asRelative(relPath.toString()); + } + return this.asRelative(this.path.toString()); + } + getParent() { + return this.parent; + } + getChildren() { + return this.children; + } + isSummary() { + return !this.fileCoverage; + } + getFileCoverage() { + return this.fileCoverage; + } + getCoverageSummary(filesOnly) { + const cacheProp = `c_${filesOnly ? "files" : "full"}`; + let summary; + if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { + return this[cacheProp]; + } + if (!this.isSummary()) { + summary = this.getFileCoverage().toSummary(); + } + else { + let count = 0; + summary = coverage.createCoverageSummary(); + this.getChildren().forEach((child) => { + if (filesOnly && child.isSummary()) { + return; + } + count += 1; + summary.merge(child.getCoverageSummary(filesOnly)); + }); + if (count === 0 && filesOnly) { + summary = null; + } + } + this[cacheProp] = summary; + return summary; + } +} +class ReportTree extends BaseTree { + constructor(root, childPrefix) { + super(root); + const maybePrefix = (node) => { + if (childPrefix && !node.isRoot()) { + node.path.unshift(childPrefix); + } + }; + this.visit({ + onDetail: maybePrefix, + onSummary(node) { + maybePrefix(node); + node.children.sort((a, b) => { + const astr = a.path.toString(); + const bstr = b.path.toString(); + return astr < bstr + ? -1 + : astr > bstr + ? 1 + : /* istanbul ignore next */ 0; + }); + }, + }); + } +} +function findCommonParent(paths) { + return paths.reduce((common, path) => common.commonPrefixPath(path), paths[0] || new Path([])); +} +function findOrCreateParent(parentPath, nodeMap, created = () => { }) { + let parent = nodeMap[parentPath.toString()]; + if (!parent) { + parent = new ReportNode(parentPath); + nodeMap[parentPath.toString()] = parent; + created(parentPath, parent); + } + return parent; +} +function toDirParents(list) { + const nodeMap = Object.create(null); + list.forEach((o) => { + const parent = findOrCreateParent(o.path.parent(), nodeMap); + parent.addChild(new ReportNode(o.path, o.fileCoverage)); + }); + return Object.values(nodeMap); +} +function addAllPaths(topPaths, nodeMap, path, node) { + const parent = findOrCreateParent(path.parent(), nodeMap, (parentPath, parent) => { + if (parentPath.hasParent()) { + addAllPaths(topPaths, nodeMap, parentPath, parent); + } + else { + topPaths.push(parent); + } + }); + parent.addChild(node); +} +function foldIntoOneDir(node, parent) { + const { children } = node; + if (children.length === 1 && !children[0].fileCoverage) { + children[0].parent = parent; + return foldIntoOneDir(children[0], parent); + } + node.children = children.map((child) => foldIntoOneDir(child, node)); + return node; +} +function pkgSummaryPrefix(dirParents, commonParent) { + if (!dirParents.some((dp) => dp.path.length === 0)) { + return; + } + if (commonParent.length === 0) { + return "root"; + } + return commonParent.name(); +} +class SummarizerFactory { + constructor(coverageMap, defaultSummarizer = "pkg") { + this._coverageMap = coverageMap; + this._defaultSummarizer = defaultSummarizer; + this._initialList = coverageMap.files().map((filePath) => ({ + filePath, + path: new Path(filePath), + fileCoverage: coverageMap.fileCoverageFor(filePath), + })); + this._commonParent = findCommonParent(this._initialList.map((o) => o.path.parent())); + if (this._commonParent.length > 0) { + this._initialList.forEach((o) => { + o.path.splice(0, this._commonParent.length); + }); + } + } + get defaultSummarizer() { + return this[this._defaultSummarizer]; + } + get flat() { + if (!this._flat) { + this._flat = new ReportTree(ReportNode.createRoot(this._initialList.map((node) => new ReportNode(node.path, node.fileCoverage)))); + } + return this._flat; + } + _createPkg() { + const dirParents = toDirParents(this._initialList); + if (dirParents.length === 1) { + return new ReportTree(dirParents[0]); + } + return new ReportTree(ReportNode.createRoot(dirParents), pkgSummaryPrefix(dirParents, this._commonParent)); + } + get pkg() { + if (!this._pkg) { + this._pkg = this._createPkg(); + } + return this._pkg; + } + _createNested() { + const nodeMap = Object.create(null); + const topPaths = []; + this._initialList.forEach((o) => { + const node = new ReportNode(o.path, o.fileCoverage); + addAllPaths(topPaths, nodeMap, o.path, node); + }); + const topNodes = topPaths.map((node) => foldIntoOneDir(node)); + if (topNodes.length === 1) { + return new ReportTree(topNodes[0]); + } + return new ReportTree(ReportNode.createRoot(topNodes)); + } + get nested() { + if (!this._nested) { + this._nested = this._createNested(); + } + return this._nested; + } +} +module.exports = SummarizerFactory; +//# sourceMappingURL=summarizer-factory.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs new file mode 100644 index 00000000000..784260e959c --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs @@ -0,0 +1,126 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +/** + * An object with methods that are called during the traversal of the coverage tree. + * A visitor has the following methods that are called during tree traversal. + * + * * `onStart(root, state)` - called before traversal begins + * * `onSummary(node, state)` - called for every summary node + * * `onDetail(node, state)` - called for every detail node + * * `onSummaryEnd(node, state)` - called after all children have been visited for + * a summary node. + * * `onEnd(root, state)` - called after traversal ends + * + * @param delegate - a partial visitor that only implements the methods of interest + * The visitor object supplies the missing methods as noops. For example, reports + * that only need the final coverage summary need implement `onStart` and nothing + * else. Reports that use only detailed coverage information need implement `onDetail` + * and nothing else. + * @constructor + */ +class Visitor { + constructor(delegate) { + this.delegate = delegate; + } +} +["Start", "End", "Summary", "SummaryEnd", "Detail"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(Visitor.prototype, fn, { + writable: true, + value(node, state) { + if (typeof this.delegate[fn] === "function") { + this.delegate[fn](node, state); + } + }, + }); +}); +class CompositeVisitor extends Visitor { + constructor(visitors) { + super(); + if (!Array.isArray(visitors)) { + visitors = [visitors]; + } + this.visitors = visitors.map((v) => { + if (v instanceof Visitor) { + return v; + } + return new Visitor(v); + }); + } +} +["Start", "Summary", "SummaryEnd", "Detail", "End"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(CompositeVisitor.prototype, fn, { + value(node, state) { + this.visitors.forEach((v) => { + v[fn](node, state); + }); + }, + }); +}); +class BaseNode { + isRoot() { + return !this.getParent(); + } + /** + * visit all nodes depth-first from this node down. Note that `onStart` + * and `onEnd` are never called on the visitor even if the current + * node is the root of the tree. + * @param visitor a full visitor that is called during tree traversal + * @param state optional state that is passed around + */ + visit(visitor, state) { + if (this.isSummary()) { + visitor.onSummary(this, state); + } + else { + visitor.onDetail(this, state); + } + this.getChildren().forEach((child) => { + child.visit(visitor, state); + }); + if (this.isSummary()) { + visitor.onSummaryEnd(this, state); + } + } +} +/** + * abstract base class for a coverage tree. + * @constructor + */ +class BaseTree { + constructor(root) { + this.root = root; + } + /** + * returns the root node of the tree + */ + getRoot() { + return this.root; + } + /** + * visits the tree depth-first with the supplied partial visitor + * @param visitor - a potentially partial visitor + * @param state - the state to be passed around during tree traversal + */ + visit(visitor, state) { + if (!(visitor instanceof Visitor)) { + visitor = new Visitor(visitor); + } + visitor.onStart(this.getRoot(), state); + this.getRoot().visit(visitor, state); + visitor.onEnd(this.getRoot(), state); + } +} +module.exports = { + BaseTree, + BaseNode, + Visitor, + CompositeVisitor, +}; +//# sourceMappingURL=tree.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs new file mode 100644 index 00000000000..6ba3cb2280a --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs @@ -0,0 +1,16 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +module.exports = { + getDefault() { + return { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], + }; + }, +}; +//# sourceMappingURL=watermarks.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs new file mode 100644 index 00000000000..ce0b0e0eb97 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs @@ -0,0 +1,81 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const INDENT = " "; +function attrString(attrs) { + return Object.entries(attrs || {}) + .map(([k, v]) => ` ${k}="${v}"`) + .join(""); +} +/** + * a utility class to produce well-formed, indented XML + * @param {ContentWriter} contentWriter the content writer that this utility wraps + * @constructor + */ +class XMLWriter { + constructor(contentWriter) { + this.cw = contentWriter; + this.stack = []; + } + indent(str) { + return this.stack.map(() => INDENT).join("") + str; + } + /** + * writes the opening XML tag with the supplied attributes + * @param {String} name tag name + * @param {Object} [attrs=null] attrs attributes for the tag + */ + openTag(name, attrs) { + const str = this.indent(`<${name + attrString(attrs)}>`); + this.cw.println(str); + this.stack.push(name); + } + /** + * closes an open XML tag. + * @param {String} name - tag name to close. This must match the writer's + * notion of the tag that is currently open. + */ + closeTag(name) { + if (this.stack.length === 0) { + throw new Error(`Attempt to close tag ${name} when not opened`); + } + const stashed = this.stack.pop(); + const str = ``; + if (stashed !== name) { + throw new Error(`Attempt to close tag ${name} when ${stashed} was the one open`); + } + this.cw.println(this.indent(str)); + } + /** + * writes a tag and its value opening and closing it at the same time + * @param {String} name tag name + * @param {Object} [attrs=null] attrs tag attributes + * @param {String} [content=null] content optional tag content + */ + inlineTag(name, attrs, content) { + let str = "<" + name + attrString(attrs); + if (content) { + str += `>${content}`; + } + else { + str += "/>"; + } + str = this.indent(str); + this.cw.println(str); + } + /** + * closes all open tags and ends the document + */ + closeAll() { + this.stack + .slice() + .reverse() + .forEach((name) => { + this.closeTag(name); + }); + } +} +module.exports = XMLWriter; +//# sourceMappingURL=xml-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/types.js b/v-next/hardhat-vendors/dist/src/coverage/types.js new file mode 100644 index 00000000000..718fd38ae40 --- /dev/null +++ b/v-next/hardhat-vendors/dist/src/coverage/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/node_modules/@types/bn.js b/v-next/hardhat-vendors/node_modules/@types/bn.js new file mode 120000 index 00000000000..112e2ea8381 --- /dev/null +++ b/v-next/hardhat-vendors/node_modules/@types/bn.js @@ -0,0 +1 @@ +../../../../node_modules/.pnpm/@types+bn.js@5.2.0/node_modules/@types/bn.js \ No newline at end of file diff --git a/v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs new file mode 100644 index 00000000000..d823b800faf --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs @@ -0,0 +1,24 @@ +const { replace } = ""; + +// escape +const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; +const ca = /[&<>'"]/g; + +const esca = { + "&": "&", + "<": "<", + ">": ">", + "'": "'", + '"': """, +}; +const pe = (m) => esca[m]; + +/** + * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. + * @param {string} es the input to safely escape + * @returns {string} the escaped input, and it **throws** an error if + * the input type is unexpected, except for boolean and numbers, + * converted as string. + */ +const escape = (es) => replace.call(es, ca, pe); +exports.escape = escape; diff --git a/v-next/hardhat-vendors/src/coverage/index.js b/v-next/hardhat-vendors/src/coverage/index.js new file mode 100644 index 00000000000..e77664e0c22 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/index.js @@ -0,0 +1,8 @@ +import libCoverage from "./lib-coverage/index.cjs"; +export { libCoverage }; + +import libReport from "./lib-report/index.cjs"; +export { libReport }; + +import reports from "./istanbul-reports/index.cjs"; +export { reports }; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs new file mode 100644 index 00000000000..7db2b63fa9f --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs @@ -0,0 +1,24 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); + +module.exports = { + create(name, cfg) { + cfg = cfg || {}; + let Cons; + try { + Cons = require(path.join(__dirname, "lib", name, "index.cjs")); + } catch (e) { + if (e.code !== "MODULE_NOT_FOUND") { + throw e; + } + + Cons = require(name); + } + + return new Cons(cfg); + }, +}; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs new file mode 100644 index 00000000000..a9b47a7380a --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs @@ -0,0 +1,294 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const InsertionText = require("./insertion-text.cjs"); +const lt = "\u0001"; +const gt = "\u0002"; +const RE_LT = //g; +const RE_AMP = /&/g; + +var RE_lt = /\u0001/g; + +var RE_gt = /\u0002/g; + +function title(str) { + return ' title="' + str + '" '; +} + +function customEscape(text) { + text = String(text); + return text + .replace(RE_AMP, "&") + .replace(RE_LT, "<") + .replace(RE_GT, ">") + .replace(RE_lt, "<") + .replace(RE_gt, ">"); +} + +function annotateLines(fileCoverage, structuredText) { + const lineStats = fileCoverage.getLineCoverage(); + if (!lineStats) { + return; + } + Object.entries(lineStats).forEach(([lineNumber, count]) => { + if (structuredText[lineNumber]) { + structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; + structuredText[lineNumber].hits = count; + } + }); +} + +function annotateStatements(fileCoverage, structuredText) { + const statementStats = fileCoverage.s; + const statementMeta = fileCoverage.statementMap; + Object.entries(statementStats).forEach(([stName, count]) => { + const meta = statementMeta[stName]; + const type = count > 0 ? "yes" : "no"; + const startCol = meta.start.column; + let endCol = meta.end.column + 1; + const startLine = meta.start.line; + const endLine = meta.end.line; + const openSpan = + lt + + 'span class="' + + (meta.skip ? "cstat-skip" : "cstat-no") + + '"' + + title("statement not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + }); +} + +function annotateFunctions(fileCoverage, structuredText) { + const fnStats = fileCoverage.f; + const fnMeta = fileCoverage.fnMap; + if (!fnStats) { + return; + } + Object.entries(fnStats).forEach(([fName, count]) => { + const meta = fnMeta[fName]; + const type = count > 0 ? "yes" : "no"; + // Some versions of the instrumenter in the wild populate 'func' + // but not 'decl': + const decl = meta.decl || meta.loc; + const startCol = decl.start.column; + let endCol = decl.end.column + 1; + const startLine = decl.start.line; + const endLine = decl.end.line; + const openSpan = + lt + + 'span class="' + + (meta.skip ? "fstat-skip" : "fstat-no") + + '"' + + title("function not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + }); +} + +function annotateBranches(fileCoverage, structuredText) { + const branchStats = fileCoverage.b; + const branchMeta = fileCoverage.branchMap; + if (!branchStats) { + return; + } + + Object.entries(branchStats).forEach(([branchName, branchArray]) => { + const sumCount = branchArray.reduce((p, n) => p + n, 0); + const metaArray = branchMeta[branchName].locations; + let i; + let count; + let meta; + let startCol; + let endCol; + let startLine; + let endLine; + let openSpan; + let closeSpan; + let text; + + // only highlight if partial branches are missing or if there is a + // single uncovered branch. + if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { + // Need to recover the metaArray placeholder item to count an implicit else + if ( + // Check if the branch is a conditional if branch. + branchMeta[branchName].type === "if" && + // Check if the branch has an implicit else. + branchArray.length === 2 && + // Check if the implicit else branch is unaccounted for. + metaArray.length === 1 && + // Check if the implicit else branch is uncovered. + branchArray[1] === 0 + ) { + metaArray[1] = { + start: {}, + end: {}, + }; + } + + for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { + count = branchArray[i]; + meta = metaArray[i]; + startCol = meta.start.column; + endCol = meta.end.column + 1; + startLine = meta.start.line; + endLine = meta.end.line; + openSpan = + lt + + 'span class="branch-' + + i + + " " + + (meta.skip ? "cbranch-skip" : "cbranch-no") + + '"' + + title("branch not covered") + + gt; + closeSpan = lt + "/span" + gt; + + // If the branch is an implicit else from an if statement, + // then the coverage report won't show a statistic. + // Therefore, the previous branch will be used to report that + // there is no coverage on that implicit branch. + if ( + count === 0 && + startLine === undefined && + branchMeta[branchName].type === "if" + ) { + const prevMeta = metaArray[i - 1]; + startCol = prevMeta.start.column; + endCol = prevMeta.end.column + 1; + startLine = prevMeta.start.line; + endLine = prevMeta.end.line; + } + + if (count === 0 && structuredText[startLine]) { + //skip branches taken + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + if (branchMeta[branchName].type === "if") { + // 'if' is a special case + // since the else branch might not be visible, being nonexistent + text.insertAt( + startCol, + lt + + 'span class="' + + (meta.skip ? "skip-if-branch" : "missing-if-branch") + + '"' + + title((i === 0 ? "if" : "else") + " path not taken") + + gt + + (i === 0 ? "I" : "E") + + lt + + "/span" + + gt, + true, + false, + ); + } else { + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + } + } + } + }); +} + +function annotateSourceCode(fileCoverage, sourceStore) { + let codeArray; + let lineCoverageArray; + try { + const sourceText = sourceStore.getSource(fileCoverage.path); + const code = sourceText.split(/(?:\r?\n)|\r/); + let count = 0; + const structured = code.map((str) => { + count += 1; + return { + line: count, + covered: "neutral", + hits: 0, + text: new InsertionText(str, true), + }; + }); + structured.unshift({ + line: 0, + covered: null, + text: new InsertionText(""), + }); + annotateLines(fileCoverage, structured); + //note: order is important, since statements typically result in spanning the whole line and doing branches late + //causes mismatched tags + annotateBranches(fileCoverage, structured); + annotateFunctions(fileCoverage, structured); + annotateStatements(fileCoverage, structured); + structured.shift(); + + codeArray = structured.map( + (item) => customEscape(item.text.toString()) || " ", + ); + + lineCoverageArray = structured.map((item) => ({ + covered: item.covered, + hits: item.hits > 0 ? item.hits + "x" : " ", + })); + + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: structured.length, + }; + } catch (ex) { + codeArray = [ex.message]; + lineCoverageArray = [{ covered: "no", hits: 0 }]; + String(ex.stack || "") + .split(/\r?\n/) + .forEach((line) => { + codeArray.push(line); + lineCoverageArray.push({ covered: "no", hits: 0 }); + }); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: codeArray.length, + }; + } +} + +module.exports = annotateSourceCode; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css new file mode 100644 index 00000000000..f418035b469 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js new file mode 100644 index 00000000000..eb527848ee7 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js @@ -0,0 +1,86 @@ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js new file mode 100644 index 00000000000..83122f78ace --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js @@ -0,0 +1,209 @@ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css new file mode 100644 index 00000000000..b317a7cda31 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js new file mode 100644 index 00000000000..ef51e038668 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs new file mode 100644 index 00000000000..a958877e7f2 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs @@ -0,0 +1,409 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const path = require("node:path"); +const html = require("../../../html-escaper/index.cjs"); +const ReportBase = require("../../../lib-report/lib/report-base.cjs"); +const annotator = require("./annotator.cjs"); + +function htmlHead(details) { + return ` + + Code coverage report for ${html.escape(details.entity)} + + + + + + + + `; +} + +function headerTemplate(details) { + function metricsTemplate({ pct, covered, total }, kind) { + return ` +
+ ${pct}% + ${kind} + ${covered}/${total} +
+ `; + } + + function skipTemplate(metrics) { + const statements = metrics.statements.skipped; + const branches = metrics.branches.skipped; + const functions = metrics.functions.skipped; + + const countLabel = (c, label, plural) => + c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; + const skips = [].concat( + countLabel(statements, "statement", "s"), + countLabel(functions, "function", "s"), + countLabel(branches, "branch", "es"), + ); + + if (skips.length === 0) { + return ""; + } + + return ` +
+ ${skips.join(", ")} + Ignored      +
+ `; + } + + return ` + + +${htmlHead(details)} + +
+
+

${details.pathHtml}

+
+ ${metricsTemplate(details.metrics.statements, "Statements")} + ${metricsTemplate(details.metrics.branches, "Branches")} + ${metricsTemplate(details.metrics.functions, "Functions")} + ${metricsTemplate(details.metrics.lines, "Lines")} + ${skipTemplate(details.metrics)} +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+ `; +} + +function footerTemplate(details) { + return ` +
+
+ + + + + + + + `; +} + +function detailTemplate(data) { + const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); + const lineLink = (num) => + `${num}`; + const lineCount = (line) => + `${line.hits}`; + + /* This is rendered in a `
`, need control of all whitespace. */
+  return [
+    "",
+    `${lineNumbers.map(lineLink).join("\n")}`,
+    `${data.lineCoverage
+      .map(lineCount)
+      .join("\n")}`,
+    `
${data.annotatedCode.join(
+      "\n",
+    )}
`, + "", + ].join(""); +} +const summaryTableHeader = [ + '
', + '', + "", + "", + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + "", + "", + "", +].join("\n"); + +function summaryLineTemplate(details) { + const { reportClasses, metrics, file, output } = details; + const percentGraph = (pct) => { + if (!isFinite(pct)) { + return ""; + } + + const cls = ["cover-fill"]; + if (pct === 100) { + cls.push("cover-full"); + } + + pct = Math.floor(pct); + return [ + `
`, + `
`, + ].join(""); + }; + const summaryType = (type, showGraph = false) => { + const info = metrics[type]; + const reportClass = reportClasses[type]; + const result = [ + ``, + ``, + ]; + if (showGraph) { + result.unshift( + ``, + ); + } + + return result; + }; + + return [] + .concat( + "", + ``, + summaryType("statements", true), + summaryType("branches"), + summaryType("functions"), + summaryType("lines"), + "\n", + ) + .join("\n\t"); +} + +const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, + `
${percentGraph(info.pct)}
`, + `
${html.escape(file)}
", "
"].join("\n"); +const emptyClasses = { + statements: "empty", + lines: "empty", + functions: "empty", + branches: "empty", +}; + +const standardLinkMapper = { + getPath(node) { + if (typeof node === "string") { + return node; + } + let filePath = node.getQualifiedName(); + if (node.isSummary()) { + if (filePath !== "") { + filePath += "/index.html"; + } else { + filePath = "index.html"; + } + } else { + filePath += ".html"; + } + return filePath; + }, + + relativePath(source, target) { + const targetPath = this.getPath(target); + const sourcePath = path.dirname(this.getPath(source)); + return path.posix.relative(sourcePath, targetPath); + }, + + assetPath(node, name) { + return this.relativePath(this.getPath(node), name); + }, +}; + +function fixPct(metrics) { + Object.keys(emptyClasses).forEach((key) => { + metrics[key].pct = 0; + }); + return metrics; +} + +class HtmlReport extends ReportBase { + constructor(opts) { + super(); + + this.verbose = opts.verbose; + this.linkMapper = opts.linkMapper || standardLinkMapper; + this.subdir = opts.subdir || ""; + this.date = new Date().toISOString(); + this.skipEmpty = opts.skipEmpty; + } + + getBreadcrumbHtml(node) { + let parent = node.getParent(); + const nodePath = []; + + while (parent) { + nodePath.push(parent); + parent = parent.getParent(); + } + + const linkPath = nodePath.map((ancestor) => { + const target = this.linkMapper.relativePath(node, ancestor); + const name = ancestor.getRelativeName() || "All files"; + return '' + name + ""; + }); + + linkPath.reverse(); + return linkPath.length > 0 + ? linkPath.join(" / ") + " " + node.getRelativeName() + : "All files"; + } + + fillTemplate(node, templateData, context) { + const linkMapper = this.linkMapper; + const summary = node.getCoverageSummary(); + templateData.entity = node.getQualifiedName() || "All files"; + templateData.metrics = summary; + templateData.reportClass = context.classForPercent( + "statements", + summary.statements.pct, + ); + templateData.pathHtml = this.getBreadcrumbHtml(node); + templateData.base = { + css: linkMapper.assetPath(node, "base.css"), + }; + templateData.sorter = { + js: linkMapper.assetPath(node, "sorter.js"), + image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), + }; + templateData.blockNavigation = { + js: linkMapper.assetPath(node, "block-navigation.js"), + }; + templateData.prettify = { + js: linkMapper.assetPath(node, "prettify.js"), + css: linkMapper.assetPath(node, "prettify.css"), + }; + templateData.favicon = linkMapper.assetPath(node, "favicon.png"); + } + + getTemplateData() { + return { datetime: this.date }; + } + + getWriter(context) { + if (!this.subdir) { + return context.writer; + } + return context.writer.writerForDir(this.subdir); + } + + onStart(root, context) { + const assetHeaders = { + ".js": "/* eslint-disable */\n", + }; + + [".", "vendor"].forEach((subdir) => { + const writer = this.getWriter(context); + const srcDir = path.resolve(__dirname, "assets", subdir); + fs.readdirSync(srcDir).forEach((f) => { + const resolvedSource = path.resolve(srcDir, f); + const resolvedDestination = "."; + const stat = fs.statSync(resolvedSource); + let dest; + + if (stat.isFile()) { + dest = resolvedDestination + "/" + f; + if (this.verbose) { + console.log("Write asset: " + dest); + } + writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); + } + }); + }); + } + + onSummary(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + const children = node.getChildren(); + const skipEmpty = this.skipEmpty; + + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write(summaryTableHeader); + children.forEach((child) => { + const metrics = child.getCoverageSummary(); + const isEmpty = metrics.isEmpty(); + if (skipEmpty && isEmpty) { + return; + } + const reportClasses = isEmpty + ? emptyClasses + : { + statements: context.classForPercent( + "statements", + metrics.statements.pct, + ), + lines: context.classForPercent("lines", metrics.lines.pct), + functions: context.classForPercent( + "functions", + metrics.functions.pct, + ), + branches: context.classForPercent("branches", metrics.branches.pct), + }; + const data = { + metrics: isEmpty ? fixPct(metrics) : metrics, + reportClasses, + file: child.getRelativeName(), + output: linkMapper.relativePath(node, child), + }; + cw.write(summaryLineTemplate(data) + "\n"); + }); + cw.write(summaryTableFooter); + cw.write(footerTemplate(templateData)); + cw.close(); + } + + onDetail(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write('
\n');
+    cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
+    cw.write("
\n"); + cw.write(footerTemplate(templateData)); + cw.close(); + } +} + +module.exports = HtmlReport; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs new file mode 100644 index 00000000000..6f8064245c2 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs @@ -0,0 +1,114 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +function InsertionText(text, consumeBlanks) { + this.text = text; + this.origLength = text.length; + this.offsets = []; + this.consumeBlanks = consumeBlanks; + this.startPos = this.findFirstNonBlank(); + this.endPos = this.findLastNonBlank(); +} + +const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; + +InsertionText.prototype = { + findFirstNonBlank() { + let pos = -1; + const text = this.text; + const len = text.length; + let i; + for (i = 0; i < len; i += 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + findLastNonBlank() { + const text = this.text; + const len = text.length; + let pos = text.length + 1; + let i; + for (i = len - 1; i >= 0; i -= 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + originalLength() { + return this.origLength; + }, + + insertAt(col, str, insertBefore, consumeBlanks) { + consumeBlanks = + typeof consumeBlanks === 'undefined' + ? this.consumeBlanks + : consumeBlanks; + col = col > this.originalLength() ? this.originalLength() : col; + col = col < 0 ? 0 : col; + + if (consumeBlanks) { + if (col <= this.startPos) { + col = 0; + } + if (col > this.endPos) { + col = this.origLength; + } + } + + const len = str.length; + const offset = this.findOffset(col, len, insertBefore); + const realPos = col + offset; + const text = this.text; + this.text = text.substring(0, realPos) + str + text.substring(realPos); + return this; + }, + + findOffset(pos, len, insertBefore) { + const offsets = this.offsets; + let offsetObj; + let cumulativeOffset = 0; + let i; + + for (i = 0; i < offsets.length; i += 1) { + offsetObj = offsets[i]; + if ( + offsetObj.pos < pos || + (offsetObj.pos === pos && !insertBefore) + ) { + cumulativeOffset += offsetObj.len; + } + if (offsetObj.pos >= pos) { + break; + } + } + if (offsetObj && offsetObj.pos === pos) { + offsetObj.len += len; + } else { + offsets.splice(i, 0, { pos, len }); + } + return cumulativeOffset; + }, + + wrap(startPos, startText, endPos, endText, consumeBlanks) { + this.insertAt(startPos, startText, true, consumeBlanks); + this.insertAt(endPos, endText, false, consumeBlanks); + return this; + }, + + wrapLine(startText, endText) { + this.wrap(0, startText, this.originalLength(), endText); + }, + + toString() { + return this.text; + } +}; + +module.exports = InsertionText; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs new file mode 100644 index 00000000000..c6074ee2d56 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs @@ -0,0 +1,64 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * istanbul-lib-coverage exports an API that allows you to create and manipulate + * file coverage, coverage maps (a set of file coverage objects) and summary + * coverage objects. File coverage for the same file can be merged as can + * entire coverage maps. + * + * @module Exports + */ +const { FileCoverage } = require("./lib/file-coverage.cjs"); +const { CoverageMap } = require("./lib/coverage-map.cjs"); +const { CoverageSummary } = require("./lib/coverage-summary.cjs"); + +module.exports = { + /** + * creates a coverage summary object + * @param {Object} obj an argument with the same semantics + * as the one passed to the `CoverageSummary` constructor + * @returns {CoverageSummary} + */ + createCoverageSummary(obj) { + if (obj && obj instanceof CoverageSummary) { + return obj; + } + return new CoverageSummary(obj); + }, + /** + * creates a CoverageMap object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the CoverageMap constructor. + * @returns {CoverageMap} + */ + createCoverageMap(obj) { + if (obj && obj instanceof CoverageMap) { + return obj; + } + return new CoverageMap(obj); + }, + /** + * creates a FileCoverage object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the FileCoverage constructor. + * @returns {FileCoverage} + */ + createFileCoverage(obj) { + if (obj && obj instanceof FileCoverage) { + return obj; + } + return new FileCoverage(obj); + }, +}; + +/** classes exported for reuse */ +module.exports.classes = { + /** + * the file coverage constructor + */ + FileCoverage, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs new file mode 100644 index 00000000000..d5820c2c740 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs @@ -0,0 +1,128 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const { FileCoverage } = require("./file-coverage.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); + +function maybeConstruct(obj, klass) { + if (obj instanceof klass) { + return obj; + } + + return new klass(obj); +} + +function loadMap(source) { + const data = Object.create(null); + if (!source) { + return data; + } + + Object.entries(source).forEach(([k, cov]) => { + data[k] = maybeConstruct(cov, FileCoverage); + }); + + return data; +} + +/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ +class CoverageMap { + /** + * @constructor + * @param {Object} [obj=undefined] obj A coverage map from which to initialize this + * map's contents. This can be the raw global coverage object. + */ + constructor(obj) { + if (obj instanceof CoverageMap) { + this.data = obj.data; + } else { + this.data = loadMap(obj); + } + } + + /** + * merges a second coverage map into this one + * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged + * correctly for the same files and additional file coverage keys are created + * as needed. + */ + merge(obj) { + const other = maybeConstruct(obj, CoverageMap); + Object.values(other.data).forEach((fc) => { + this.addFileCoverage(fc); + }); + } + + /** + * filter the coveragemap based on the callback provided + * @param {Function (filename)} callback - Returns true if the path + * should be included in the coveragemap. False if it should be + * removed. + */ + filter(callback) { + Object.keys(this.data).forEach((k) => { + if (!callback(k)) { + delete this.data[k]; + } + }); + } + + /** + * returns a JSON-serializable POJO for this coverage map + * @returns {Object} + */ + toJSON() { + return this.data; + } + + /** + * returns an array for file paths for which this map has coverage + * @returns {Array{string}} - array of files + */ + files() { + return Object.keys(this.data); + } + + /** + * returns the file coverage for the specified file. + * @param {String} file + * @returns {FileCoverage} + */ + fileCoverageFor(file) { + const fc = this.data[file]; + if (!fc) { + throw new Error(`No file coverage available for: ${file}`); + } + return fc; + } + + addFileCoverage(fc) { + const cov = new FileCoverage(fc); + const { path } = cov; + if (this.data[path]) { + this.data[path].merge(cov); + } else { + this.data[path] = cov; + } + } + + /** + * returns the coverage summary for all the file coverage objects in this map. + * @returns {CoverageSummary} + */ + getCoverageSummary() { + const ret = new CoverageSummary(); + Object.values(this.data).forEach((fc) => { + ret.merge(fc.toSummary()); + }); + + return ret; + } +} + +module.exports = { + CoverageMap, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs new file mode 100644 index 00000000000..1e6a9498936 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs @@ -0,0 +1,112 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); + +function blankSummary() { + const empty = () => ({ + total: 0, + covered: 0, + skipped: 0, + pct: "Unknown", + }); + + return { + lines: empty(), + statements: empty(), + functions: empty(), + branches: empty(), + branchesTrue: empty(), + }; +} + +// asserts that a data object "looks like" a summary coverage object +function assertValidSummary(obj) { + const valid = + obj && obj.lines && obj.statements && obj.functions && obj.branches; + if (!valid) { + throw new Error( + "Invalid summary coverage object, missing keys, found:" + + Object.keys(obj).join(","), + ); + } +} + +/** + * CoverageSummary provides a summary of code coverage . It exposes 4 properties, + * `lines`, `statements`, `branches`, and `functions`. Each of these properties + * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. + * `pct` is a percentage number (0-100). + */ +class CoverageSummary { + /** + * @constructor + * @param {Object|CoverageSummary} [obj=undefined] an optional data object or + * another coverage summary to initialize this object with. + */ + constructor(obj) { + if (!obj) { + this.data = blankSummary(); + } else if (obj instanceof CoverageSummary) { + this.data = obj.data; + } else { + this.data = obj; + } + assertValidSummary(this.data); + } + + /** + * merges a second summary coverage object into this one + * @param {CoverageSummary} obj - another coverage summary object + */ + merge(obj) { + const keys = [ + "lines", + "statements", + "branches", + "functions", + "branchesTrue", + ]; + keys.forEach((key) => { + if (obj[key]) { + this[key].total += obj[key].total; + this[key].covered += obj[key].covered; + this[key].skipped += obj[key].skipped; + this[key].pct = percent(this[key].covered, this[key].total); + } + }); + + return this; + } + + /** + * returns a POJO that is JSON serializable. May be used to get the raw + * summary object. + */ + toJSON() { + return this.data; + } + + /** + * return true if summary has no lines of code + */ + isEmpty() { + return this.lines.total === 0; + } +} + +dataProperties(CoverageSummary, [ + "lines", + "statements", + "functions", + "branches", + "branchesTrue", +]); + +module.exports = { + CoverageSummary, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs new file mode 100644 index 00000000000..ad6ac0e1453 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs @@ -0,0 +1,12 @@ +"use strict"; + +module.exports = function dataProperties(klass, properties) { + properties.forEach((p) => { + Object.defineProperty(klass.prototype, p, { + enumerable: true, + get() { + return this.data[p]; + }, + }); + }); +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs new file mode 100644 index 00000000000..47f45bbd63f --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs @@ -0,0 +1,442 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); + +// returns a data object that represents empty coverage +function emptyCoverage(filePath, reportLogic) { + const cov = { + path: filePath, + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {}, + }; + if (reportLogic) cov.bT = {}; + return cov; +} + +// asserts that a data object "looks like" a coverage object +function assertValidObject(obj) { + const valid = + obj && + obj.path && + obj.statementMap && + obj.fnMap && + obj.branchMap && + obj.s && + obj.f && + obj.b; + if (!valid) { + throw new Error( + "Invalid file coverage object, missing keys, found:" + + Object.keys(obj).join(","), + ); + } +} + +const keyFromLoc = ({ start, end }) => + `${start.line}|${start.column}|${end.line}|${end.column}`; + +const isObj = (o) => !!o && typeof o === "object"; +const isLineCol = (o) => + isObj(o) && typeof o.line === "number" && typeof o.column === "number"; +const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); +const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); + +// When merging, we can have a case where two ranges cover +// the same block of code with `hits=1`, and each carve out a +// different range with `hits=0` to indicate it's uncovered. +// Find the nearest container so that we can properly indicate +// that both sections are hit. +// Returns null if no containing item is found. +const findNearestContainer = (item, map) => { + const itemLoc = getLoc(item); + if (!itemLoc) return null; + // the B item is not an identified range in the A set, BUT + // it may be contained by an identified A range. If so, then + // any hit of that containing A range counts as a hit of this + // B range as well. We have to find the *narrowest* containing + // range to be accurate, since ranges can be hit and un-hit + // in a nested fashion. + let nearestContainingItem = null; + let containerDistance = null; + let containerKey = null; + for (const [i, mapItem] of Object.entries(map)) { + const mapLoc = getLoc(mapItem); + if (!mapLoc) continue; + // contained if all of line distances are > 0 + // or line distance is 0 and col dist is >= 0 + const distance = [ + itemLoc.start.line - mapLoc.start.line, + itemLoc.start.column - mapLoc.start.column, + mapLoc.end.line - itemLoc.end.line, + mapLoc.end.column - itemLoc.end.column, + ]; + if ( + distance[0] < 0 || + distance[2] < 0 || + (distance[0] === 0 && distance[1] < 0) || + (distance[2] === 0 && distance[3] < 0) + ) { + continue; + } + if (nearestContainingItem === null) { + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + continue; + } + // closer line more relevant than closer column + const closerBefore = + distance[0] < containerDistance[0] || + (distance[0] === 0 && distance[1] < containerDistance[1]); + const closerAfter = + distance[2] < containerDistance[2] || + (distance[2] === 0 && distance[3] < containerDistance[3]); + if (closerBefore || closerAfter) { + // closer + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + } + } + return containerKey; +}; + +// either add two numbers, or all matching entries in a number[] +const addHits = (aHits, bHits) => { + if (typeof aHits === "number" && typeof bHits === "number") { + return aHits + bHits; + } else if (Array.isArray(aHits) && Array.isArray(bHits)) { + return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); + } + return null; +}; + +const addNearestContainerHits = (item, itemHits, map, mapHits) => { + const container = findNearestContainer(item, map); + if (container) { + return addHits(itemHits, mapHits[container]); + } else { + return itemHits; + } +}; + +const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { + const aItems = {}; + for (const [key, itemHits] of Object.entries(aHits)) { + const item = aMap[key]; + aItems[itemKey(item)] = [itemHits, item]; + } + const bItems = {}; + for (const [key, itemHits] of Object.entries(bHits)) { + const item = bMap[key]; + bItems[itemKey(item)] = [itemHits, item]; + } + const mergedItems = {}; + for (const [key, aValue] of Object.entries(aItems)) { + let aItemHits = aValue[0]; + const aItem = aValue[1]; + const bValue = bItems[key]; + if (!bValue) { + // not an identified range in b, but might be contained by one + aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); + } else { + // is an identified range in b, so add the hits together + aItemHits = addHits(aItemHits, bValue[0]); + } + mergedItems[key] = [aItemHits, aItem]; + } + // now find the items in b that are not in a. already added matches. + for (const [key, bValue] of Object.entries(bItems)) { + let bItemHits = bValue[0]; + const bItem = bValue[1]; + if (mergedItems[key]) continue; + // not an identified range in b, but might be contained by one + bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); + mergedItems[key] = [bItemHits, bItem]; + } + + const hits = {}; + const map = {}; + + Object.values(mergedItems).forEach(([itemHits, item], i) => { + hits[i] = itemHits; + map[i] = item; + }); + + return [hits, map]; +}; + +/** + * provides a read-only view of coverage for a single file. + * The deep structure of this object is documented elsewhere. It has the following + * properties: + * + * * `path` - the file path for which coverage is being tracked + * * `statementMap` - map of statement locations keyed by statement index + * * `fnMap` - map of function metadata keyed by function index + * * `branchMap` - map of branch metadata keyed by branch index + * * `s` - hit counts for statements + * * `f` - hit count for functions + * * `b` - hit count for branches + */ +class FileCoverage { + /** + * @constructor + * @param {Object|FileCoverage|String} pathOrObj is a string that initializes + * and empty coverage object with the specified file path or a data object that + * has all the required properties for a file coverage object. + */ + constructor(pathOrObj, reportLogic = false) { + if (!pathOrObj) { + throw new Error("Coverage must be initialized with a path or an object"); + } + if (typeof pathOrObj === "string") { + this.data = emptyCoverage(pathOrObj, reportLogic); + } else if (pathOrObj instanceof FileCoverage) { + this.data = pathOrObj.data; + } else if (typeof pathOrObj === "object") { + this.data = pathOrObj; + } else { + throw new Error("Invalid argument to coverage constructor"); + } + assertValidObject(this.data); + } + + /** + * returns computed line coverage from statement coverage. + * This is a map of hits keyed by line number in the source. + */ + getLineCoverage() { + const statementMap = this.data.statementMap; + const statements = this.data.s; + const lineMap = Object.create(null); + + Object.entries(statements).forEach(([st, count]) => { + /* istanbul ignore if: is this even possible? */ + if (!statementMap[st]) { + return; + } + const { line } = statementMap[st].start; + const prevVal = lineMap[line]; + if (prevVal === undefined || prevVal < count) { + lineMap[line] = count; + } + }); + return lineMap; + } + + /** + * returns an array of uncovered line numbers. + * @returns {Array} an array of line numbers for which no hits have been + * collected. + */ + getUncoveredLines() { + const lc = this.getLineCoverage(); + const ret = []; + Object.entries(lc).forEach(([l, hits]) => { + if (hits === 0) { + ret.push(l); + } + }); + return ret; + } + + /** + * returns a map of branch coverage by source line number. + * @returns {Object} an object keyed by line number. Each object + * has a `covered`, `total` and `coverage` (percentage) property. + */ + getBranchCoverageByLine() { + const branchMap = this.branchMap; + const branches = this.b; + const ret = {}; + Object.entries(branchMap).forEach(([k, map]) => { + const line = map.line || map.loc.start.line; + const branchData = branches[k]; + ret[line] = ret[line] || []; + ret[line].push(...branchData); + }); + Object.entries(ret).forEach(([k, dataArray]) => { + const covered = dataArray.filter((item) => item > 0); + const coverage = (covered.length / dataArray.length) * 100; + ret[k] = { + covered: covered.length, + total: dataArray.length, + coverage, + }; + }); + return ret; + } + + /** + * return a JSON-serializable POJO for this file coverage object + */ + toJSON() { + return this.data; + } + + /** + * merges a second coverage object into this one, updating hit counts + * @param {FileCoverage} other - the coverage object to be merged into this one. + * Note that the other object should have the same structure as this one (same file). + */ + merge(other) { + if (other.all === true) { + return; + } + + if (this.all === true) { + this.data = other.data; + return; + } + + let [hits, map] = mergeProp( + this.s, + this.statementMap, + other.s, + other.statementMap, + ); + this.data.s = hits; + this.data.statementMap = map; + + const keyFromLocProp = (x) => keyFromLoc(x.loc); + const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); + + [hits, map] = mergeProp( + this.f, + this.fnMap, + other.f, + other.fnMap, + keyFromLocProp, + ); + this.data.f = hits; + this.data.fnMap = map; + + [hits, map] = mergeProp( + this.b, + this.branchMap, + other.b, + other.branchMap, + keyFromLocationsProp, + ); + this.data.b = hits; + this.data.branchMap = map; + + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT && other.bT) { + [hits, map] = mergeProp( + this.bT, + this.branchMap, + other.bT, + other.branchMap, + keyFromLocationsProp, + ); + this.data.bT = hits; + } + } + + computeSimpleTotals(property) { + let stats = this[property]; + + if (typeof stats === "function") { + stats = stats.call(this); + } + + const ret = { + total: Object.keys(stats).length, + covered: Object.values(stats).filter((v) => !!v).length, + skipped: 0, + }; + ret.pct = percent(ret.covered, ret.total); + return ret; + } + + computeBranchTotals(property) { + const stats = this[property]; + const ret = { total: 0, covered: 0, skipped: 0 }; + + Object.values(stats).forEach((branches) => { + ret.covered += branches.filter((hits) => hits > 0).length; + ret.total += branches.length; + }); + ret.pct = percent(ret.covered, ret.total); + return ret; + } + + /** + * resets hit counts for all statements, functions and branches + * in this coverage object resulting in zero coverage. + */ + resetHits() { + const statements = this.s; + const functions = this.f; + const branches = this.b; + const branchesTrue = this.bT; + Object.keys(statements).forEach((s) => { + statements[s] = 0; + }); + Object.keys(functions).forEach((f) => { + functions[f] = 0; + }); + Object.keys(branches).forEach((b) => { + branches[b].fill(0); + }); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (branchesTrue) { + Object.keys(branchesTrue).forEach((bT) => { + branchesTrue[bT].fill(0); + }); + } + } + + /** + * returns a CoverageSummary for this file coverage object + * @returns {CoverageSummary} + */ + toSummary() { + const ret = {}; + ret.lines = this.computeSimpleTotals("getLineCoverage"); + ret.functions = this.computeSimpleTotals("f", "fnMap"); + ret.statements = this.computeSimpleTotals("s", "statementMap"); + ret.branches = this.computeBranchTotals("b"); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT) { + ret.branchesTrue = this.computeBranchTotals("bT"); + } + return new CoverageSummary(ret); + } +} + +// expose coverage data attributes +dataProperties(FileCoverage, [ + "path", + "statementMap", + "fnMap", + "branchMap", + "s", + "f", + "b", + "bT", + "all", +]); + +module.exports = { + FileCoverage, + // exported for testing + findNearestContainer, + addHits, + addNearestContainerHits, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs new file mode 100644 index 00000000000..ecb468d56b9 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs @@ -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"; + +module.exports = function percent(covered, total) { + let tmp; + if (total > 0) { + tmp = (1000 * 100 * covered) / total; + return Math.floor(tmp / 10) / 100; + } else { + return 100.0; + } +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/ciao.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/ciao.cjs new file mode 100644 index 00000000000..e69de29bb2d diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/index.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/index.cjs new file mode 100644 index 00000000000..f7aad0370c1 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/index.cjs @@ -0,0 +1,40 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * @module Exports + */ + +const Context = require("./lib/context.cjs"); +const watermarks = require("./lib/watermarks.cjs"); +const ReportBase = require("./lib/report-base.cjs"); + +module.exports = { + /** + * returns a reporting context for the supplied options + * @param {Object} [opts=null] opts + * @returns {Context} + */ + createContext(opts) { + return new Context(opts); + }, + + /** + * returns the default watermarks that would be used when not + * overridden + * @returns {Object} an object with `statements`, `functions`, `branches`, + * and `line` keys. Each value is a 2 element array that has the low and + * high watermark as percentages. + */ + getDefaultWatermarks() { + return watermarks.getDefault(); + }, + + /** + * Base class for all reports + */ + ReportBase, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs new file mode 100644 index 00000000000..92ab1478486 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs @@ -0,0 +1,132 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const FileWriter = require("./file-writer.cjs"); +const XMLWriter = require("./xml-writer.cjs"); +const tree = require("./tree.cjs"); +const watermarks = require("./watermarks.cjs"); +const SummarizerFactory = require("./summarizer-factory.cjs"); + +function defaultSourceLookup(path) { + try { + return fs.readFileSync(path, "utf8"); + } catch (ex) { + throw new Error(`Unable to lookup source: ${path} (${ex.message})`); + } +} + +function normalizeWatermarks(specified = {}) { + Object.entries(watermarks.getDefault()).forEach(([k, value]) => { + const specValue = specified[k]; + if (!Array.isArray(specValue) || specValue.length !== 2) { + specified[k] = value; + } + }); + + return specified; +} + +/** + * A reporting context that is passed to report implementations + * @param {Object} [opts=null] opts options + * @param {String} [opts.dir='coverage'] opts.dir the reporting directory + * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for + * statements, lines, branches and functions + * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a + * function that returns source code given a file path. Defaults to + * filesystem lookups based on path. + * @constructor + */ +class Context { + constructor(opts) { + this.dir = opts.dir || "coverage"; + this.watermarks = normalizeWatermarks(opts.watermarks); + this.sourceFinder = opts.sourceFinder || defaultSourceLookup; + this._summarizerFactory = new SummarizerFactory( + opts.coverageMap, + opts.defaultSummarizer, + ); + this.data = {}; + } + + /** + * returns a FileWriter implementation for reporting use. Also available + * as the `writer` property on the context. + * @returns {Writer} + */ + getWriter() { + return this.writer; + } + + /** + * returns the source code for the specified file path or throws if + * the source could not be found. + * @param {String} filePath the file path as found in a file coverage object + * @returns {String} the source code + */ + getSource(filePath) { + return this.sourceFinder(filePath); + } + + /** + * returns the coverage class given a coverage + * types and a percentage value. + * @param {String} type - the coverage type, one of `statements`, `functions`, + * `branches`, or `lines` + * @param {Number} value - the percentage value + * @returns {String} one of `high`, `medium` or `low` + */ + classForPercent(type, value) { + const watermarks = this.watermarks[type]; + if (!watermarks) { + return "unknown"; + } + if (value < watermarks[0]) { + return "low"; + } + if (value >= watermarks[1]) { + return "high"; + } + return "medium"; + } + + /** + * returns an XML writer for the supplied content writer + * @param {ContentWriter} contentWriter the content writer to which the returned XML writer + * writes data + * @returns {XMLWriter} + */ + getXMLWriter(contentWriter) { + return new XMLWriter(contentWriter); + } + + /** + * returns a full visitor given a partial one. + * @param {Object} partialVisitor a partial visitor only having the functions of + * interest to the caller. These functions are called with a scope that is the + * supplied object. + * @returns {Visitor} + */ + getVisitor(partialVisitor) { + return new tree.Visitor(partialVisitor); + } + + getTree(name = "defaultSummarizer") { + return this._summarizerFactory[name]; + } +} + +Object.defineProperty(Context.prototype, "writer", { + enumerable: true, + get() { + if (!this.data.writer) { + this.data.writer = new FileWriter(this.dir); + } + return this.data.writer; + }, +}); + +module.exports = Context; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs new file mode 100644 index 00000000000..658de8f06f8 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs @@ -0,0 +1,184 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); +const fs = require("node:fs"); +const { mkdir } = require("node:fs/promises"); + +/** + * Base class for writing content + * @class ContentWriter + * @constructor + */ +class ContentWriter { + /** + * returns the colorized version of a string. Typically, + * content writers that write to files will return the + * same string and ones writing to a tty will wrap it in + * appropriate escape sequences. + * @param {String} str the string to colorize + * @param {String} clazz one of `high`, `medium` or `low` + * @returns {String} the colorized form of the string + */ + colorize(str /*, clazz*/) { + return str; + } + + /** + * writes a string appended with a newline to the destination + * @param {String} str the string to write + */ + println(str) { + this.write(`${str}\n`); + } + + /** + * closes this content writer. Should be called after all writes are complete. + */ + close() {} +} + +/** + * a content writer that writes to a file + * @param {Number} fd - the file descriptor + * @extends ContentWriter + * @constructor + */ +class FileContentWriter extends ContentWriter { + constructor(fd) { + super(); + + this.fd = fd; + } + + write(str) { + fs.writeSync(this.fd, str); + } + + close() { + fs.closeSync(this.fd); + } +} + +// allow stdout to be captured for tests. +let capture = false; +let output = ""; + +/** + * a content writer that writes to the console + * @extends ContentWriter + * @constructor + */ +class ConsoleWriter extends ContentWriter { + write(str) { + if (capture) { + output += str; + } else { + process.stdout.write(str); + } + } + + colorize(str, clazz) { + const colors = { + low: "31;1", + medium: "33;1", + high: "32;1", + }; + + return str; + } +} + +/** + * utility for writing files under a specific directory + * @class FileWriter + * @param {String} baseDir the base directory under which files should be written + * @constructor + */ +class FileWriter { + constructor(baseDir) { + if (!baseDir) { + throw new Error("baseDir must be specified"); + } + this.baseDir = baseDir; + } + + /** + * static helpers for capturing stdout report output; + * super useful for tests! + */ + static startCapture() { + capture = true; + } + + static stopCapture() { + capture = false; + } + + static getOutput() { + return output; + } + + static resetOutput() { + output = ""; + } + + /** + * returns a FileWriter that is rooted at the supplied subdirectory + * @param {String} subdir the subdirectory under which to root the + * returned FileWriter + * @returns {FileWriter} + */ + writerForDir(subdir) { + if (path.isAbsolute(subdir)) { + throw new Error( + `Cannot create subdir writer for absolute path: ${subdir}`, + ); + } + return new FileWriter(`${this.baseDir}/${subdir}`); + } + + /** + * copies a file from a source directory to a destination name + * @param {String} source path to source file + * @param {String} dest relative path to destination file + * @param {String} [header=undefined] optional text to prepend to destination + * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) + */ + copyFile(source, dest, header) { + if (path.isAbsolute(dest)) { + throw new Error(`Cannot write to absolute path: ${dest}`); + } + dest = path.resolve(this.baseDir, dest); + mkdir(path.dirname(dest), { recursive: true }); + let contents; + if (header) { + contents = header + fs.readFileSync(source, "utf8"); + } else { + contents = fs.readFileSync(source); + } + fs.writeFileSync(dest, contents); + } + + /** + * returns a content writer for writing content to the supplied file. + * @param {String|null} file the relative path to the file or the special + * values `"-"` or `null` for writing to the console + * @returns {ContentWriter} + */ + writeFile(file) { + if (file === null || file === "-") { + return new ConsoleWriter(); + } + if (path.isAbsolute(file)) { + throw new Error(`Cannot write to absolute path: ${file}`); + } + file = path.resolve(this.baseDir, file); + mkdir(path.dirname(file), { recursive: true }); + return new FileContentWriter(fs.openSync(file, "w")); + } +} + +module.exports = FileWriter; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs new file mode 100644 index 00000000000..89f8033883b --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs @@ -0,0 +1,169 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const path = require("node:path"); +let parsePath = path.parse; +let SEP = path.sep; +const origParser = parsePath; +const origSep = SEP; + +function makeRelativeNormalizedPath(str, sep) { + const parsed = parsePath(str); + let root = parsed.root; + let dir; + let file = parsed.base; + let quoted; + let pos; + + // handle a weird windows case separately + if (sep === "\\") { + pos = root.indexOf(":\\"); + if (pos >= 0) { + root = root.substring(0, pos + 2); + } + } + dir = parsed.dir.substring(root.length); + + if (str === "") { + return []; + } + + if (sep !== "/") { + quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); + dir = dir.replace(quoted, "/"); + file = file.replace(quoted, "/"); // excessively paranoid? + } + + if (dir !== "") { + dir = `${dir}/${file}`; + } else { + dir = file; + } + if (dir.substring(0, 1) === "/") { + dir = dir.substring(1); + } + dir = dir.split(/\/+/); + return dir; +} + +class Path { + constructor(strOrArray) { + if (Array.isArray(strOrArray)) { + this.v = strOrArray; + } else if (typeof strOrArray === "string") { + this.v = makeRelativeNormalizedPath(strOrArray, SEP); + } else { + throw new Error( + `Invalid Path argument must be string or array:${strOrArray}`, + ); + } + } + + toString() { + return this.v.join("/"); + } + + hasParent() { + return this.v.length > 0; + } + + parent() { + if (!this.hasParent()) { + throw new Error("Unable to get parent for 0 elem path"); + } + const p = this.v.slice(); + p.pop(); + return new Path(p); + } + + elements() { + return this.v.slice(); + } + + name() { + return this.v.slice(-1)[0]; + } + + contains(other) { + let i; + if (other.length > this.length) { + return false; + } + for (i = 0; i < other.length; i += 1) { + if (this.v[i] !== other.v[i]) { + return false; + } + } + return true; + } + + ancestorOf(other) { + return other.contains(this) && other.length !== this.length; + } + + descendantOf(other) { + return this.contains(other) && other.length !== this.length; + } + + commonPrefixPath(other) { + const len = this.length > other.length ? other.length : this.length; + let i; + const ret = []; + + for (i = 0; i < len; i += 1) { + if (this.v[i] === other.v[i]) { + ret.push(this.v[i]); + } else { + break; + } + } + return new Path(ret); + } + + static compare(a, b) { + const al = a.length; + const bl = b.length; + + if (al < bl) { + return -1; + } + + if (al > bl) { + return 1; + } + + const astr = a.toString(); + const bstr = b.toString(); + return astr < bstr ? -1 : astr > bstr ? 1 : 0; + } +} + +["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { + Object.defineProperty(Path.prototype, fn, { + value(...args) { + return this.v[fn](...args); + }, + }); +}); + +Object.defineProperty(Path.prototype, "length", { + enumerable: true, + get() { + return this.v.length; + }, +}); + +module.exports = Path; +Path.tester = { + setParserAndSep(p, sep) { + parsePath = p; + SEP = sep; + }, + reset() { + parsePath = origParser; + SEP = origSep; + }, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs new file mode 100644 index 00000000000..1575121b53b --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs @@ -0,0 +1,16 @@ +"use strict"; + +// TODO: switch to class private field when targeting node.js 12 +const _summarizer = Symbol("ReportBase.#summarizer"); + +class ReportBase { + constructor(opts = {}) { + this[_summarizer] = opts.summarizer; + } + + execute(context) { + context.getTree(this[_summarizer]).visit(this, context); + } +} + +module.exports = ReportBase; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs new file mode 100644 index 00000000000..cb2c429bc9a --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs @@ -0,0 +1,284 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const coverage = require("../../lib-coverage/index.cjs"); +const Path = require("./path.cjs"); +const { BaseNode, BaseTree } = require("./tree.cjs"); + +class ReportNode extends BaseNode { + constructor(path, fileCoverage) { + super(); + + this.path = path; + this.parent = null; + this.fileCoverage = fileCoverage; + this.children = []; + } + + static createRoot(children) { + const root = new ReportNode(new Path([])); + + children.forEach((child) => { + root.addChild(child); + }); + + return root; + } + + addChild(child) { + child.parent = this; + this.children.push(child); + } + + asRelative(p) { + if (p.substring(0, 1) === "/") { + return p.substring(1); + } + return p; + } + + getQualifiedName() { + return this.asRelative(this.path.toString()); + } + + getRelativeName() { + const parent = this.getParent(); + const myPath = this.path; + let relPath; + let i; + const parentPath = parent ? parent.path : new Path([]); + if (parentPath.ancestorOf(myPath)) { + relPath = new Path(myPath.elements()); + for (i = 0; i < parentPath.length; i += 1) { + relPath.shift(); + } + return this.asRelative(relPath.toString()); + } + return this.asRelative(this.path.toString()); + } + + getParent() { + return this.parent; + } + + getChildren() { + return this.children; + } + + isSummary() { + return !this.fileCoverage; + } + + getFileCoverage() { + return this.fileCoverage; + } + + getCoverageSummary(filesOnly) { + const cacheProp = `c_${filesOnly ? "files" : "full"}`; + let summary; + + if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { + return this[cacheProp]; + } + + if (!this.isSummary()) { + summary = this.getFileCoverage().toSummary(); + } else { + let count = 0; + summary = coverage.createCoverageSummary(); + this.getChildren().forEach((child) => { + if (filesOnly && child.isSummary()) { + return; + } + count += 1; + summary.merge(child.getCoverageSummary(filesOnly)); + }); + if (count === 0 && filesOnly) { + summary = null; + } + } + this[cacheProp] = summary; + return summary; + } +} + +class ReportTree extends BaseTree { + constructor(root, childPrefix) { + super(root); + + const maybePrefix = (node) => { + if (childPrefix && !node.isRoot()) { + node.path.unshift(childPrefix); + } + }; + this.visit({ + onDetail: maybePrefix, + onSummary(node) { + maybePrefix(node); + node.children.sort((a, b) => { + const astr = a.path.toString(); + const bstr = b.path.toString(); + return astr < bstr + ? -1 + : astr > bstr + ? 1 + : /* istanbul ignore next */ 0; + }); + }, + }); + } +} + +function findCommonParent(paths) { + return paths.reduce( + (common, path) => common.commonPrefixPath(path), + paths[0] || new Path([]), + ); +} + +function findOrCreateParent(parentPath, nodeMap, created = () => {}) { + let parent = nodeMap[parentPath.toString()]; + + if (!parent) { + parent = new ReportNode(parentPath); + nodeMap[parentPath.toString()] = parent; + created(parentPath, parent); + } + + return parent; +} + +function toDirParents(list) { + const nodeMap = Object.create(null); + list.forEach((o) => { + const parent = findOrCreateParent(o.path.parent(), nodeMap); + parent.addChild(new ReportNode(o.path, o.fileCoverage)); + }); + + return Object.values(nodeMap); +} + +function addAllPaths(topPaths, nodeMap, path, node) { + const parent = findOrCreateParent( + path.parent(), + nodeMap, + (parentPath, parent) => { + if (parentPath.hasParent()) { + addAllPaths(topPaths, nodeMap, parentPath, parent); + } else { + topPaths.push(parent); + } + }, + ); + + parent.addChild(node); +} + +function foldIntoOneDir(node, parent) { + const { children } = node; + if (children.length === 1 && !children[0].fileCoverage) { + children[0].parent = parent; + return foldIntoOneDir(children[0], parent); + } + node.children = children.map((child) => foldIntoOneDir(child, node)); + return node; +} + +function pkgSummaryPrefix(dirParents, commonParent) { + if (!dirParents.some((dp) => dp.path.length === 0)) { + return; + } + + if (commonParent.length === 0) { + return "root"; + } + + return commonParent.name(); +} + +class SummarizerFactory { + constructor(coverageMap, defaultSummarizer = "pkg") { + this._coverageMap = coverageMap; + this._defaultSummarizer = defaultSummarizer; + this._initialList = coverageMap.files().map((filePath) => ({ + filePath, + path: new Path(filePath), + fileCoverage: coverageMap.fileCoverageFor(filePath), + })); + this._commonParent = findCommonParent( + this._initialList.map((o) => o.path.parent()), + ); + if (this._commonParent.length > 0) { + this._initialList.forEach((o) => { + o.path.splice(0, this._commonParent.length); + }); + } + } + + get defaultSummarizer() { + return this[this._defaultSummarizer]; + } + + get flat() { + if (!this._flat) { + this._flat = new ReportTree( + ReportNode.createRoot( + this._initialList.map( + (node) => new ReportNode(node.path, node.fileCoverage), + ), + ), + ); + } + + return this._flat; + } + + _createPkg() { + const dirParents = toDirParents(this._initialList); + if (dirParents.length === 1) { + return new ReportTree(dirParents[0]); + } + + return new ReportTree( + ReportNode.createRoot(dirParents), + pkgSummaryPrefix(dirParents, this._commonParent), + ); + } + + get pkg() { + if (!this._pkg) { + this._pkg = this._createPkg(); + } + + return this._pkg; + } + + _createNested() { + const nodeMap = Object.create(null); + const topPaths = []; + this._initialList.forEach((o) => { + const node = new ReportNode(o.path, o.fileCoverage); + addAllPaths(topPaths, nodeMap, o.path, node); + }); + + const topNodes = topPaths.map((node) => foldIntoOneDir(node)); + if (topNodes.length === 1) { + return new ReportTree(topNodes[0]); + } + + return new ReportTree(ReportNode.createRoot(topNodes)); + } + + get nested() { + if (!this._nested) { + this._nested = this._createNested(); + } + + return this._nested; + } +} + +module.exports = SummarizerFactory; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs new file mode 100644 index 00000000000..6bac8b98ea4 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs @@ -0,0 +1,137 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * An object with methods that are called during the traversal of the coverage tree. + * A visitor has the following methods that are called during tree traversal. + * + * * `onStart(root, state)` - called before traversal begins + * * `onSummary(node, state)` - called for every summary node + * * `onDetail(node, state)` - called for every detail node + * * `onSummaryEnd(node, state)` - called after all children have been visited for + * a summary node. + * * `onEnd(root, state)` - called after traversal ends + * + * @param delegate - a partial visitor that only implements the methods of interest + * The visitor object supplies the missing methods as noops. For example, reports + * that only need the final coverage summary need implement `onStart` and nothing + * else. Reports that use only detailed coverage information need implement `onDetail` + * and nothing else. + * @constructor + */ +class Visitor { + constructor(delegate) { + this.delegate = delegate; + } +} + +["Start", "End", "Summary", "SummaryEnd", "Detail"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(Visitor.prototype, fn, { + writable: true, + value(node, state) { + if (typeof this.delegate[fn] === "function") { + this.delegate[fn](node, state); + } + }, + }); + }); + +class CompositeVisitor extends Visitor { + constructor(visitors) { + super(); + + if (!Array.isArray(visitors)) { + visitors = [visitors]; + } + this.visitors = visitors.map((v) => { + if (v instanceof Visitor) { + return v; + } + return new Visitor(v); + }); + } +} + +["Start", "Summary", "SummaryEnd", "Detail", "End"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(CompositeVisitor.prototype, fn, { + value(node, state) { + this.visitors.forEach((v) => { + v[fn](node, state); + }); + }, + }); + }); + +class BaseNode { + isRoot() { + return !this.getParent(); + } + + /** + * visit all nodes depth-first from this node down. Note that `onStart` + * and `onEnd` are never called on the visitor even if the current + * node is the root of the tree. + * @param visitor a full visitor that is called during tree traversal + * @param state optional state that is passed around + */ + visit(visitor, state) { + if (this.isSummary()) { + visitor.onSummary(this, state); + } else { + visitor.onDetail(this, state); + } + + this.getChildren().forEach((child) => { + child.visit(visitor, state); + }); + + if (this.isSummary()) { + visitor.onSummaryEnd(this, state); + } + } +} + +/** + * abstract base class for a coverage tree. + * @constructor + */ +class BaseTree { + constructor(root) { + this.root = root; + } + + /** + * returns the root node of the tree + */ + getRoot() { + return this.root; + } + + /** + * visits the tree depth-first with the supplied partial visitor + * @param visitor - a potentially partial visitor + * @param state - the state to be passed around during tree traversal + */ + visit(visitor, state) { + if (!(visitor instanceof Visitor)) { + visitor = new Visitor(visitor); + } + visitor.onStart(this.getRoot(), state); + this.getRoot().visit(visitor, state); + visitor.onEnd(this.getRoot(), state); + } +} + +module.exports = { + BaseTree, + BaseNode, + Visitor, + CompositeVisitor, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs new file mode 100644 index 00000000000..0be610017a9 --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs @@ -0,0 +1,15 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +module.exports = { + getDefault() { + return { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], + }; + }, +}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs new file mode 100644 index 00000000000..aea68a1b53f --- /dev/null +++ b/v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs @@ -0,0 +1,90 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const INDENT = " "; + +function attrString(attrs) { + return Object.entries(attrs || {}) + .map(([k, v]) => ` ${k}="${v}"`) + .join(""); +} + +/** + * a utility class to produce well-formed, indented XML + * @param {ContentWriter} contentWriter the content writer that this utility wraps + * @constructor + */ +class XMLWriter { + constructor(contentWriter) { + this.cw = contentWriter; + this.stack = []; + } + + indent(str) { + return this.stack.map(() => INDENT).join("") + str; + } + + /** + * writes the opening XML tag with the supplied attributes + * @param {String} name tag name + * @param {Object} [attrs=null] attrs attributes for the tag + */ + openTag(name, attrs) { + const str = this.indent(`<${name + attrString(attrs)}>`); + this.cw.println(str); + this.stack.push(name); + } + + /** + * closes an open XML tag. + * @param {String} name - tag name to close. This must match the writer's + * notion of the tag that is currently open. + */ + closeTag(name) { + if (this.stack.length === 0) { + throw new Error(`Attempt to close tag ${name} when not opened`); + } + const stashed = this.stack.pop(); + const str = ``; + + if (stashed !== name) { + throw new Error( + `Attempt to close tag ${name} when ${stashed} was the one open`, + ); + } + this.cw.println(this.indent(str)); + } + + /** + * writes a tag and its value opening and closing it at the same time + * @param {String} name tag name + * @param {Object} [attrs=null] attrs tag attributes + * @param {String} [content=null] content optional tag content + */ + inlineTag(name, attrs, content) { + let str = "<" + name + attrString(attrs); + if (content) { + str += `>${content}`; + } else { + str += "/>"; + } + str = this.indent(str); + this.cw.println(str); + } + + /** + * closes all open tags and ends the document + */ + closeAll() { + this.stack + .slice() + .reverse() + .forEach((name) => { + this.closeTag(name); + }); + } +} + +module.exports = XMLWriter; From 30474834824628b91d0e4313184b31aa18363129 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:06:30 +0100 Subject: [PATCH 16/32] rename to hardhat-vendored --- .../.gitignore | 5 + .../.prettierignore | 0 .../CHANGELOG.md | 0 .../LICENSE | 0 .../README.md | 0 .../eslint.config.js | 0 .../package.json | 0 .../src/copy-assets.ts | 0 .../tsconfig.json | 0 .../hardhat-vendors/dist/src/copy-assets.js | 11 - .../dist/src/coverage/html-escaper/index.cjs | 23 - .../dist/src/coverage/index.js | 7 - .../src/coverage/istanbul-reports/index.cjs | 23 - .../istanbul-reports/lib/html/annotator.cjs | 249 ---------- .../istanbul-reports/lib/html/assets/base.css | 224 --------- .../lib/html/assets/block-navigation.js | 86 ---- .../lib/html/assets/favicon.png | Bin 445 -> 0 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 138 -> 0 bytes .../lib/html/assets/sorter.js | 209 --------- .../lib/html/assets/vendor/prettify.css | 1 - .../lib/html/assets/vendor/prettify.js | 1 - .../istanbul-reports/lib/html/index.cjs | 339 -------------- .../lib/html/insertion-text.cjs | 103 ---- .../dist/src/coverage/lib-coverage/index.cjs | 62 --- .../lib-coverage/lib/coverage-map.cjs | 115 ----- .../lib-coverage/lib/coverage-summary.cjs | 101 ---- .../lib-coverage/lib/data-properties.cjs | 12 - .../lib-coverage/lib/file-coverage.cjs | 387 --------------- .../src/coverage/lib-coverage/lib/percent.cjs | 16 - .../dist/src/coverage/lib-report/index.js | 37 -- .../src/coverage/lib-report/lib/context.cjs | 119 ----- .../coverage/lib-report/lib/file-writer.cjs | 165 ------- .../dist/src/coverage/lib-report/lib/path.cjs | 148 ------ .../coverage/lib-report/lib/report-base.cjs | 13 - .../lib-report/lib/summarizer-factory.cjs | 224 --------- .../dist/src/coverage/lib-report/lib/tree.cjs | 126 ----- .../coverage/lib-report/lib/watermarks.cjs | 16 - .../coverage/lib-report/lib/xml-writer.cjs | 81 ---- .../dist/src/coverage/types.js | 2 - .../hardhat-vendors/node_modules/@types/bn.js | 1 - .../src/coverage/html-escaper/index.cjs | 24 - v-next/hardhat-vendors/src/coverage/index.js | 8 - .../src/coverage/istanbul-reports/index.cjs | 24 - .../istanbul-reports/lib/html/annotator.cjs | 294 ------------ .../istanbul-reports/lib/html/assets/base.css | 224 --------- .../lib/html/assets/block-navigation.js | 86 ---- .../lib/html/assets/favicon.png | Bin 445 -> 0 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 138 -> 0 bytes .../lib/html/assets/sorter.js | 209 --------- .../lib/html/assets/vendor/prettify.css | 1 - .../lib/html/assets/vendor/prettify.js | 1 - .../istanbul-reports/lib/html/index.cjs | 409 ---------------- .../lib/html/insertion-text.cjs | 114 ----- .../src/coverage/lib-coverage/index.cjs | 64 --- .../lib-coverage/lib/coverage-map.cjs | 128 ----- .../lib-coverage/lib/coverage-summary.cjs | 112 ----- .../lib-coverage/lib/data-properties.cjs | 12 - .../lib-coverage/lib/file-coverage.cjs | 442 ------------------ .../src/coverage/lib-coverage/lib/percent.cjs | 15 - .../src/coverage/lib-report/ciao.cjs | 0 .../src/coverage/lib-report/index.cjs | 40 -- .../src/coverage/lib-report/lib/context.cjs | 132 ------ .../coverage/lib-report/lib/file-writer.cjs | 184 -------- .../src/coverage/lib-report/lib/path.cjs | 169 ------- .../coverage/lib-report/lib/report-base.cjs | 16 - .../lib-report/lib/summarizer-factory.cjs | 284 ----------- .../src/coverage/lib-report/lib/tree.cjs | 137 ------ .../coverage/lib-report/lib/watermarks.cjs | 15 - .../coverage/lib-report/lib/xml-writer.cjs | 90 ---- 69 files changed, 5 insertions(+), 6135 deletions(-) rename v-next/{hardhat-vendors => hardhat-vendored}/.gitignore (87%) rename v-next/{hardhat-vendors => hardhat-vendored}/.prettierignore (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/CHANGELOG.md (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/LICENSE (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/README.md (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/eslint.config.js (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/package.json (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/src/copy-assets.ts (100%) rename v-next/{hardhat-vendors => hardhat-vendored}/tsconfig.json (100%) delete mode 100644 v-next/hardhat-vendors/dist/src/copy-assets.js delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/index.js delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs delete mode 100644 v-next/hardhat-vendors/dist/src/coverage/types.js delete mode 120000 v-next/hardhat-vendors/node_modules/@types/bn.js delete mode 100644 v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/index.js delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/favicon.png delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/ciao.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/index.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs delete mode 100644 v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs diff --git a/v-next/hardhat-vendors/.gitignore b/v-next/hardhat-vendored/.gitignore similarity index 87% rename from v-next/hardhat-vendors/.gitignore rename to v-next/hardhat-vendored/.gitignore index 0e1706cfcd7..c8607fe252d 100644 --- a/v-next/hardhat-vendors/.gitignore +++ b/v-next/hardhat-vendored/.gitignore @@ -12,3 +12,8 @@ coverage # all the tmp folders in the fixture projects /test/fixture-projects/tmp/ + +!*.js +!*.cjs +!*.css +!*.png diff --git a/v-next/hardhat-vendors/.prettierignore b/v-next/hardhat-vendored/.prettierignore similarity index 100% rename from v-next/hardhat-vendors/.prettierignore rename to v-next/hardhat-vendored/.prettierignore diff --git a/v-next/hardhat-vendors/CHANGELOG.md b/v-next/hardhat-vendored/CHANGELOG.md similarity index 100% rename from v-next/hardhat-vendors/CHANGELOG.md rename to v-next/hardhat-vendored/CHANGELOG.md diff --git a/v-next/hardhat-vendors/LICENSE b/v-next/hardhat-vendored/LICENSE similarity index 100% rename from v-next/hardhat-vendors/LICENSE rename to v-next/hardhat-vendored/LICENSE diff --git a/v-next/hardhat-vendors/README.md b/v-next/hardhat-vendored/README.md similarity index 100% rename from v-next/hardhat-vendors/README.md rename to v-next/hardhat-vendored/README.md diff --git a/v-next/hardhat-vendors/eslint.config.js b/v-next/hardhat-vendored/eslint.config.js similarity index 100% rename from v-next/hardhat-vendors/eslint.config.js rename to v-next/hardhat-vendored/eslint.config.js diff --git a/v-next/hardhat-vendors/package.json b/v-next/hardhat-vendored/package.json similarity index 100% rename from v-next/hardhat-vendors/package.json rename to v-next/hardhat-vendored/package.json diff --git a/v-next/hardhat-vendors/src/copy-assets.ts b/v-next/hardhat-vendored/src/copy-assets.ts similarity index 100% rename from v-next/hardhat-vendors/src/copy-assets.ts rename to v-next/hardhat-vendored/src/copy-assets.ts diff --git a/v-next/hardhat-vendors/tsconfig.json b/v-next/hardhat-vendored/tsconfig.json similarity index 100% rename from v-next/hardhat-vendors/tsconfig.json rename to v-next/hardhat-vendored/tsconfig.json diff --git a/v-next/hardhat-vendors/dist/src/copy-assets.js b/v-next/hardhat-vendors/dist/src/copy-assets.js deleted file mode 100644 index af80157c693..00000000000 --- a/v-next/hardhat-vendors/dist/src/copy-assets.js +++ /dev/null @@ -1,11 +0,0 @@ -import { cp } from "node:fs/promises"; -import path from "node:path"; -async function copyFolder(from, to) { - const src = path.resolve(from); - const dest = path.resolve(to); - await cp(src, dest, { recursive: true, force: true }); - console.log(`Copied folder from ${src} -> ${dest}`); -} -// eslint-disable-next-line no-restricted-syntax -- allow in this post build script -await copyFolder(path.resolve(process.cwd(), "src", "coverage", "istanbul-reports", "lib", "html", "assets"), path.resolve(process.cwd(), "dist", "src", "coverage", "istanbul-reports", "lib", "html", "assets")); -//# sourceMappingURL=copy-assets.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs deleted file mode 100644 index 1f0f029ec88..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/html-escaper/index.cjs +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -const { replace } = ""; -// escape -const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; -const ca = /[&<>'"]/g; -const esca = { - "&": "&", - "<": "<", - ">": ">", - "'": "'", - '"': """, -}; -const pe = (m) => esca[m]; -/** - * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. - * @param {string} es the input to safely escape - * @returns {string} the escaped input, and it **throws** an error if - * the input type is unexpected, except for boolean and numbers, - * converted as string. - */ -const escape = (es) => replace.call(es, ca, pe); -exports.escape = escape; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/index.js b/v-next/hardhat-vendors/dist/src/coverage/index.js deleted file mode 100644 index ef05ce4b00b..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import libCoverage from "./lib-coverage/index.cjs"; -export { libCoverage }; -import libReport from "./lib-report/index.js"; -export { libReport }; -import reports from "./istanbul-reports/index.cjs"; -export { reports }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs deleted file mode 100644 index ddfb1ef1c6d..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/index.cjs +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); -module.exports = { - create(name, cfg) { - cfg = cfg || {}; - let Cons; - try { - Cons = require(path.join(__dirname, "lib", name, "index.cjs")); - } - catch (e) { - if (e.code !== "MODULE_NOT_FOUND") { - throw e; - } - Cons = require(name); - } - return new Cons(cfg); - }, -}; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs deleted file mode 100644 index cda3f88caf1..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs +++ /dev/null @@ -1,249 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const InsertionText = require("./insertion-text.cjs"); -const lt = "\u0001"; -const gt = "\u0002"; -const RE_LT = //g; -const RE_AMP = /&/g; -var RE_lt = /\u0001/g; -var RE_gt = /\u0002/g; -function title(str) { - return ' title="' + str + '" '; -} -function customEscape(text) { - text = String(text); - return text - .replace(RE_AMP, "&") - .replace(RE_LT, "<") - .replace(RE_GT, ">") - .replace(RE_lt, "<") - .replace(RE_gt, ">"); -} -function annotateLines(fileCoverage, structuredText) { - const lineStats = fileCoverage.getLineCoverage(); - if (!lineStats) { - return; - } - Object.entries(lineStats).forEach(([lineNumber, count]) => { - if (structuredText[lineNumber]) { - structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; - structuredText[lineNumber].hits = count; - } - }); -} -function annotateStatements(fileCoverage, structuredText) { - const statementStats = fileCoverage.s; - const statementMeta = fileCoverage.statementMap; - Object.entries(statementStats).forEach(([stName, count]) => { - const meta = statementMeta[stName]; - const type = count > 0 ? "yes" : "no"; - const startCol = meta.start.column; - let endCol = meta.end.column + 1; - const startLine = meta.start.line; - const endLine = meta.end.line; - const openSpan = lt + - 'span class="' + - (meta.skip ? "cstat-skip" : "cstat-no") + - '"' + - title("statement not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); - } - }); -} -function annotateFunctions(fileCoverage, structuredText) { - const fnStats = fileCoverage.f; - const fnMeta = fileCoverage.fnMap; - if (!fnStats) { - return; - } - Object.entries(fnStats).forEach(([fName, count]) => { - const meta = fnMeta[fName]; - const type = count > 0 ? "yes" : "no"; - // Some versions of the instrumenter in the wild populate 'func' - // but not 'decl': - const decl = meta.decl || meta.loc; - const startCol = decl.start.column; - let endCol = decl.end.column + 1; - const startLine = decl.start.line; - const endLine = decl.end.line; - const openSpan = lt + - 'span class="' + - (meta.skip ? "fstat-skip" : "fstat-no") + - '"' + - title("function not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); - } - }); -} -function annotateBranches(fileCoverage, structuredText) { - const branchStats = fileCoverage.b; - const branchMeta = fileCoverage.branchMap; - if (!branchStats) { - return; - } - Object.entries(branchStats).forEach(([branchName, branchArray]) => { - const sumCount = branchArray.reduce((p, n) => p + n, 0); - const metaArray = branchMeta[branchName].locations; - let i; - let count; - let meta; - let startCol; - let endCol; - let startLine; - let endLine; - let openSpan; - let closeSpan; - let text; - // only highlight if partial branches are missing or if there is a - // single uncovered branch. - if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { - // Need to recover the metaArray placeholder item to count an implicit else - if ( - // Check if the branch is a conditional if branch. - branchMeta[branchName].type === "if" && - // Check if the branch has an implicit else. - branchArray.length === 2 && - // Check if the implicit else branch is unaccounted for. - metaArray.length === 1 && - // Check if the implicit else branch is uncovered. - branchArray[1] === 0) { - metaArray[1] = { - start: {}, - end: {}, - }; - } - for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { - count = branchArray[i]; - meta = metaArray[i]; - startCol = meta.start.column; - endCol = meta.end.column + 1; - startLine = meta.start.line; - endLine = meta.end.line; - openSpan = - lt + - 'span class="branch-' + - i + - " " + - (meta.skip ? "cbranch-skip" : "cbranch-no") + - '"' + - title("branch not covered") + - gt; - closeSpan = lt + "/span" + gt; - // If the branch is an implicit else from an if statement, - // then the coverage report won't show a statistic. - // Therefore, the previous branch will be used to report that - // there is no coverage on that implicit branch. - if (count === 0 && - startLine === undefined && - branchMeta[branchName].type === "if") { - const prevMeta = metaArray[i - 1]; - startCol = prevMeta.start.column; - endCol = prevMeta.end.column + 1; - startLine = prevMeta.start.line; - endLine = prevMeta.end.line; - } - if (count === 0 && structuredText[startLine]) { - //skip branches taken - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - if (branchMeta[branchName].type === "if") { - // 'if' is a special case - // since the else branch might not be visible, being nonexistent - text.insertAt(startCol, lt + - 'span class="' + - (meta.skip ? "skip-if-branch" : "missing-if-branch") + - '"' + - title((i === 0 ? "if" : "else") + " path not taken") + - gt + - (i === 0 ? "I" : "E") + - lt + - "/span" + - gt, true, false); - } - else { - text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); - } - } - } - } - }); -} -function annotateSourceCode(fileCoverage, sourceStore) { - let codeArray; - let lineCoverageArray; - try { - const sourceText = sourceStore.getSource(fileCoverage.path); - const code = sourceText.split(/(?:\r?\n)|\r/); - let count = 0; - const structured = code.map((str) => { - count += 1; - return { - line: count, - covered: "neutral", - hits: 0, - text: new InsertionText(str, true), - }; - }); - structured.unshift({ - line: 0, - covered: null, - text: new InsertionText(""), - }); - annotateLines(fileCoverage, structured); - //note: order is important, since statements typically result in spanning the whole line and doing branches late - //causes mismatched tags - annotateBranches(fileCoverage, structured); - annotateFunctions(fileCoverage, structured); - annotateStatements(fileCoverage, structured); - structured.shift(); - codeArray = structured.map((item) => customEscape(item.text.toString()) || " "); - lineCoverageArray = structured.map((item) => ({ - covered: item.covered, - hits: item.hits > 0 ? item.hits + "x" : " ", - })); - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: structured.length, - }; - } - catch (ex) { - codeArray = [ex.message]; - lineCoverageArray = [{ covered: "no", hits: 0 }]; - String(ex.stack || "") - .split(/\r?\n/) - .forEach((line) => { - codeArray.push(line); - lineCoverageArray.push({ covered: "no", hits: 0 }); - }); - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: codeArray.length, - }; - } -} -module.exports = annotateSourceCode; -//# sourceMappingURL=annotator.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css deleted file mode 100644 index f418035b469..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/base.css +++ /dev/null @@ -1,224 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* yellow */ -.cbranch-no { background: yellow !important; color: #111; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -.highlighted, -.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ - background: #C21F39 !important; -} -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -.medium .chart { border:1px solid #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } - -.coverage-summary td.empty { - opacity: .5; - padding-top: 4px; - padding-bottom: 4px; - line-height: 1; - color: #888; -} - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js deleted file mode 100644 index eb527848ee7..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js +++ /dev/null @@ -1,86 +0,0 @@ -var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; - - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selector that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } - - makeCurrent(nextIndex); - } - - function goToNext() { - var nextIndex = 0; - - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } - - makeCurrent(nextIndex); - } - - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } - - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; -})(); -window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png deleted file mode 100644 index c1525b811a167671e9de1fa78aab9f5c0b61cef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js deleted file mode 100644 index 83122f78ace..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js +++ /dev/null @@ -1,209 +0,0 @@ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - - // Try to create a RegExp from the searchValue. If it fails (invalid regex), - // it will be treated as a plain text search - let searchRegex; - try { - searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive - } catch (error) { - searchRegex = null; - } - - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - let isMatch = false; - - if (searchRegex) { - // If a valid regex was created, use it for matching - isMatch = searchRegex.test(row.textContent); - } else { - // Otherwise, fall back to the original plain text search - isMatch = row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()); - } - - row.style.display = isMatch ? '' : 'none'; - } - } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css deleted file mode 100644 index b317a7cda31..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js deleted file mode 100644 index ef51e038668..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs deleted file mode 100644 index a2390d3ad04..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/index.cjs +++ /dev/null @@ -1,339 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const path = require("node:path"); -const html = require("../../../html-escaper/index.cjs"); -const ReportBase = require("../../../lib-report/lib/report-base.cjs"); -const annotator = require("./annotator.cjs"); -function htmlHead(details) { - return ` - - Code coverage report for ${html.escape(details.entity)} - - - - - - - - `; -} -function headerTemplate(details) { - function metricsTemplate({ pct, covered, total }, kind) { - return ` -
- ${pct}% - ${kind} - ${covered}/${total} -
- `; - } - function skipTemplate(metrics) { - const statements = metrics.statements.skipped; - const branches = metrics.branches.skipped; - const functions = metrics.functions.skipped; - const countLabel = (c, label, plural) => c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; - const skips = [].concat(countLabel(statements, "statement", "s"), countLabel(functions, "function", "s"), countLabel(branches, "branch", "es")); - if (skips.length === 0) { - return ""; - } - return ` -
- ${skips.join(", ")} - Ignored      -
- `; - } - return ` - - -${htmlHead(details)} - -
-
-

${details.pathHtml}

-
- ${metricsTemplate(details.metrics.statements, "Statements")} - ${metricsTemplate(details.metrics.branches, "Branches")} - ${metricsTemplate(details.metrics.functions, "Functions")} - ${metricsTemplate(details.metrics.lines, "Lines")} - ${skipTemplate(details.metrics)} -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
- `; -} -function footerTemplate(details) { - return ` -
-
- - - - - - - - `; -} -function detailTemplate(data) { - const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); - const lineLink = (num) => `${num}`; - const lineCount = (line) => `${line.hits}`; - /* This is rendered in a `
`, need control of all whitespace. */
-    return [
-        "",
-        `${lineNumbers.map(lineLink).join("\n")}`,
-        `${data.lineCoverage
-            .map(lineCount)
-            .join("\n")}`,
-        `
${data.annotatedCode.join("\n")}
`, - "", - ].join(""); -} -const summaryTableHeader = [ - '
', - '', - "", - "", - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - "", - "", - "", -].join("\n"); -function summaryLineTemplate(details) { - const { reportClasses, metrics, file, output } = details; - const percentGraph = (pct) => { - if (!isFinite(pct)) { - return ""; - } - const cls = ["cover-fill"]; - if (pct === 100) { - cls.push("cover-full"); - } - pct = Math.floor(pct); - return [ - `
`, - `
`, - ].join(""); - }; - const summaryType = (type, showGraph = false) => { - const info = metrics[type]; - const reportClass = reportClasses[type]; - const result = [ - ``, - ``, - ]; - if (showGraph) { - result.unshift(``); - } - return result; - }; - return [] - .concat("", ``, summaryType("statements", true), summaryType("branches"), summaryType("functions"), summaryType("lines"), "\n") - .join("\n\t"); -} -const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, `
${percentGraph(info.pct)}
`, `
${html.escape(file)}
", "
"].join("\n"); -const emptyClasses = { - statements: "empty", - lines: "empty", - functions: "empty", - branches: "empty", -}; -const standardLinkMapper = { - getPath(node) { - if (typeof node === "string") { - return node; - } - let filePath = node.getQualifiedName(); - if (node.isSummary()) { - if (filePath !== "") { - filePath += "/index.html"; - } - else { - filePath = "index.html"; - } - } - else { - filePath += ".html"; - } - return filePath; - }, - relativePath(source, target) { - const targetPath = this.getPath(target); - const sourcePath = path.dirname(this.getPath(source)); - return path.posix.relative(sourcePath, targetPath); - }, - assetPath(node, name) { - return this.relativePath(this.getPath(node), name); - }, -}; -function fixPct(metrics) { - Object.keys(emptyClasses).forEach((key) => { - metrics[key].pct = 0; - }); - return metrics; -} -class HtmlReport extends ReportBase { - constructor(opts) { - super(); - this.verbose = opts.verbose; - this.linkMapper = opts.linkMapper || standardLinkMapper; - this.subdir = opts.subdir || ""; - this.date = new Date().toISOString(); - this.skipEmpty = opts.skipEmpty; - } - getBreadcrumbHtml(node) { - let parent = node.getParent(); - const nodePath = []; - while (parent) { - nodePath.push(parent); - parent = parent.getParent(); - } - const linkPath = nodePath.map((ancestor) => { - const target = this.linkMapper.relativePath(node, ancestor); - const name = ancestor.getRelativeName() || "All files"; - return '' + name + ""; - }); - linkPath.reverse(); - return linkPath.length > 0 - ? linkPath.join(" / ") + " " + node.getRelativeName() - : "All files"; - } - fillTemplate(node, templateData, context) { - const linkMapper = this.linkMapper; - const summary = node.getCoverageSummary(); - templateData.entity = node.getQualifiedName() || "All files"; - templateData.metrics = summary; - templateData.reportClass = context.classForPercent("statements", summary.statements.pct); - templateData.pathHtml = this.getBreadcrumbHtml(node); - templateData.base = { - css: linkMapper.assetPath(node, "base.css"), - }; - templateData.sorter = { - js: linkMapper.assetPath(node, "sorter.js"), - image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), - }; - templateData.blockNavigation = { - js: linkMapper.assetPath(node, "block-navigation.js"), - }; - templateData.prettify = { - js: linkMapper.assetPath(node, "prettify.js"), - css: linkMapper.assetPath(node, "prettify.css"), - }; - templateData.favicon = linkMapper.assetPath(node, "favicon.png"); - } - getTemplateData() { - return { datetime: this.date }; - } - getWriter(context) { - if (!this.subdir) { - return context.writer; - } - return context.writer.writerForDir(this.subdir); - } - onStart(root, context) { - const assetHeaders = { - ".js": "/* eslint-disable */\n", - }; - [".", "vendor"].forEach((subdir) => { - const writer = this.getWriter(context); - const srcDir = path.resolve(__dirname, "assets", subdir); - fs.readdirSync(srcDir).forEach((f) => { - const resolvedSource = path.resolve(srcDir, f); - const resolvedDestination = "."; - const stat = fs.statSync(resolvedSource); - let dest; - if (stat.isFile()) { - dest = resolvedDestination + "/" + f; - if (this.verbose) { - console.log("Write asset: " + dest); - } - writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); - } - }); - }); - } - onSummary(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - const children = node.getChildren(); - const skipEmpty = this.skipEmpty; - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write(summaryTableHeader); - children.forEach((child) => { - const metrics = child.getCoverageSummary(); - const isEmpty = metrics.isEmpty(); - if (skipEmpty && isEmpty) { - return; - } - const reportClasses = isEmpty - ? emptyClasses - : { - statements: context.classForPercent("statements", metrics.statements.pct), - lines: context.classForPercent("lines", metrics.lines.pct), - functions: context.classForPercent("functions", metrics.functions.pct), - branches: context.classForPercent("branches", metrics.branches.pct), - }; - const data = { - metrics: isEmpty ? fixPct(metrics) : metrics, - reportClasses, - file: child.getRelativeName(), - output: linkMapper.relativePath(node, child), - }; - cw.write(summaryLineTemplate(data) + "\n"); - }); - cw.write(summaryTableFooter); - cw.write(footerTemplate(templateData)); - cw.close(); - } - onDetail(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write('
\n');
-        cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
-        cw.write("
\n"); - cw.write(footerTemplate(templateData)); - cw.close(); - } -} -module.exports = HtmlReport; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs deleted file mode 100644 index 6cc92030ae8..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -function InsertionText(text, consumeBlanks) { - this.text = text; - this.origLength = text.length; - this.offsets = []; - this.consumeBlanks = consumeBlanks; - this.startPos = this.findFirstNonBlank(); - this.endPos = this.findLastNonBlank(); -} -const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; -InsertionText.prototype = { - findFirstNonBlank() { - let pos = -1; - const text = this.text; - const len = text.length; - let i; - for (i = 0; i < len; i += 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - findLastNonBlank() { - const text = this.text; - const len = text.length; - let pos = text.length + 1; - let i; - for (i = len - 1; i >= 0; i -= 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - originalLength() { - return this.origLength; - }, - insertAt(col, str, insertBefore, consumeBlanks) { - consumeBlanks = - typeof consumeBlanks === 'undefined' - ? this.consumeBlanks - : consumeBlanks; - col = col > this.originalLength() ? this.originalLength() : col; - col = col < 0 ? 0 : col; - if (consumeBlanks) { - if (col <= this.startPos) { - col = 0; - } - if (col > this.endPos) { - col = this.origLength; - } - } - const len = str.length; - const offset = this.findOffset(col, len, insertBefore); - const realPos = col + offset; - const text = this.text; - this.text = text.substring(0, realPos) + str + text.substring(realPos); - return this; - }, - findOffset(pos, len, insertBefore) { - const offsets = this.offsets; - let offsetObj; - let cumulativeOffset = 0; - let i; - for (i = 0; i < offsets.length; i += 1) { - offsetObj = offsets[i]; - if (offsetObj.pos < pos || - (offsetObj.pos === pos && !insertBefore)) { - cumulativeOffset += offsetObj.len; - } - if (offsetObj.pos >= pos) { - break; - } - } - if (offsetObj && offsetObj.pos === pos) { - offsetObj.len += len; - } - else { - offsets.splice(i, 0, { pos, len }); - } - return cumulativeOffset; - }, - wrap(startPos, startText, endPos, endText, consumeBlanks) { - this.insertAt(startPos, startText, true, consumeBlanks); - this.insertAt(endPos, endText, false, consumeBlanks); - return this; - }, - wrapLine(startText, endText) { - this.wrap(0, startText, this.originalLength(), endText); - }, - toString() { - return this.text; - } -}; -module.exports = InsertionText; -//# sourceMappingURL=insertion-text.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs deleted file mode 100644 index 86ee436a301..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/index.cjs +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -/** - * istanbul-lib-coverage exports an API that allows you to create and manipulate - * file coverage, coverage maps (a set of file coverage objects) and summary - * coverage objects. File coverage for the same file can be merged as can - * entire coverage maps. - * - * @module Exports - */ -const { FileCoverage } = require("./lib/file-coverage.cjs"); -const { CoverageMap } = require("./lib/coverage-map.cjs"); -const { CoverageSummary } = require("./lib/coverage-summary.cjs"); -module.exports = { - /** - * creates a coverage summary object - * @param {Object} obj an argument with the same semantics - * as the one passed to the `CoverageSummary` constructor - * @returns {CoverageSummary} - */ - createCoverageSummary(obj) { - if (obj && obj instanceof CoverageSummary) { - return obj; - } - return new CoverageSummary(obj); - }, - /** - * creates a CoverageMap object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the CoverageMap constructor. - * @returns {CoverageMap} - */ - createCoverageMap(obj) { - if (obj && obj instanceof CoverageMap) { - return obj; - } - return new CoverageMap(obj); - }, - /** - * creates a FileCoverage object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the FileCoverage constructor. - * @returns {FileCoverage} - */ - createFileCoverage(obj) { - if (obj && obj instanceof FileCoverage) { - return obj; - } - return new FileCoverage(obj); - }, -}; -/** classes exported for reuse */ -module.exports.classes = { - /** - * the file coverage constructor - */ - FileCoverage, -}; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs deleted file mode 100644 index bad5422758a..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-map.cjs +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const { FileCoverage } = require("./file-coverage.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); -function maybeConstruct(obj, klass) { - if (obj instanceof klass) { - return obj; - } - return new klass(obj); -} -function loadMap(source) { - const data = Object.create(null); - if (!source) { - return data; - } - Object.entries(source).forEach(([k, cov]) => { - data[k] = maybeConstruct(cov, FileCoverage); - }); - return data; -} -/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ -class CoverageMap { - /** - * @constructor - * @param {Object} [obj=undefined] obj A coverage map from which to initialize this - * map's contents. This can be the raw global coverage object. - */ - constructor(obj) { - if (obj instanceof CoverageMap) { - this.data = obj.data; - } - else { - this.data = loadMap(obj); - } - } - /** - * merges a second coverage map into this one - * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged - * correctly for the same files and additional file coverage keys are created - * as needed. - */ - merge(obj) { - const other = maybeConstruct(obj, CoverageMap); - Object.values(other.data).forEach((fc) => { - this.addFileCoverage(fc); - }); - } - /** - * filter the coveragemap based on the callback provided - * @param {Function (filename)} callback - Returns true if the path - * should be included in the coveragemap. False if it should be - * removed. - */ - filter(callback) { - Object.keys(this.data).forEach((k) => { - if (!callback(k)) { - delete this.data[k]; - } - }); - } - /** - * returns a JSON-serializable POJO for this coverage map - * @returns {Object} - */ - toJSON() { - return this.data; - } - /** - * returns an array for file paths for which this map has coverage - * @returns {Array{string}} - array of files - */ - files() { - return Object.keys(this.data); - } - /** - * returns the file coverage for the specified file. - * @param {String} file - * @returns {FileCoverage} - */ - fileCoverageFor(file) { - const fc = this.data[file]; - if (!fc) { - throw new Error(`No file coverage available for: ${file}`); - } - return fc; - } - addFileCoverage(fc) { - const cov = new FileCoverage(fc); - const { path } = cov; - if (this.data[path]) { - this.data[path].merge(cov); - } - else { - this.data[path] = cov; - } - } - /** - * returns the coverage summary for all the file coverage objects in this map. - * @returns {CoverageSummary} - */ - getCoverageSummary() { - const ret = new CoverageSummary(); - Object.values(this.data).forEach((fc) => { - ret.merge(fc.toSummary()); - }); - return ret; - } -} -module.exports = { - CoverageMap, -}; -//# sourceMappingURL=coverage-map.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs deleted file mode 100644 index 8762aca9296..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); -function blankSummary() { - const empty = () => ({ - total: 0, - covered: 0, - skipped: 0, - pct: "Unknown", - }); - return { - lines: empty(), - statements: empty(), - functions: empty(), - branches: empty(), - branchesTrue: empty(), - }; -} -// asserts that a data object "looks like" a summary coverage object -function assertValidSummary(obj) { - const valid = obj && obj.lines && obj.statements && obj.functions && obj.branches; - if (!valid) { - throw new Error("Invalid summary coverage object, missing keys, found:" + - Object.keys(obj).join(",")); - } -} -/** - * CoverageSummary provides a summary of code coverage . It exposes 4 properties, - * `lines`, `statements`, `branches`, and `functions`. Each of these properties - * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. - * `pct` is a percentage number (0-100). - */ -class CoverageSummary { - /** - * @constructor - * @param {Object|CoverageSummary} [obj=undefined] an optional data object or - * another coverage summary to initialize this object with. - */ - constructor(obj) { - if (!obj) { - this.data = blankSummary(); - } - else if (obj instanceof CoverageSummary) { - this.data = obj.data; - } - else { - this.data = obj; - } - assertValidSummary(this.data); - } - /** - * merges a second summary coverage object into this one - * @param {CoverageSummary} obj - another coverage summary object - */ - merge(obj) { - const keys = [ - "lines", - "statements", - "branches", - "functions", - "branchesTrue", - ]; - keys.forEach((key) => { - if (obj[key]) { - this[key].total += obj[key].total; - this[key].covered += obj[key].covered; - this[key].skipped += obj[key].skipped; - this[key].pct = percent(this[key].covered, this[key].total); - } - }); - return this; - } - /** - * returns a POJO that is JSON serializable. May be used to get the raw - * summary object. - */ - toJSON() { - return this.data; - } - /** - * return true if summary has no lines of code - */ - isEmpty() { - return this.lines.total === 0; - } -} -dataProperties(CoverageSummary, [ - "lines", - "statements", - "functions", - "branches", - "branchesTrue", -]); -module.exports = { - CoverageSummary, -}; -//# sourceMappingURL=coverage-summary.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs deleted file mode 100644 index e8a22f8e598..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/data-properties.cjs +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -module.exports = function dataProperties(klass, properties) { - properties.forEach((p) => { - Object.defineProperty(klass.prototype, p, { - enumerable: true, - get() { - return this.data[p]; - }, - }); - }); -}; -//# sourceMappingURL=data-properties.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs deleted file mode 100644 index 72900a820ba..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/file-coverage.cjs +++ /dev/null @@ -1,387 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); -// returns a data object that represents empty coverage -function emptyCoverage(filePath, reportLogic) { - const cov = { - path: filePath, - statementMap: {}, - fnMap: {}, - branchMap: {}, - s: {}, - f: {}, - b: {}, - }; - if (reportLogic) - cov.bT = {}; - return cov; -} -// asserts that a data object "looks like" a coverage object -function assertValidObject(obj) { - const valid = obj && - obj.path && - obj.statementMap && - obj.fnMap && - obj.branchMap && - obj.s && - obj.f && - obj.b; - if (!valid) { - throw new Error("Invalid file coverage object, missing keys, found:" + - Object.keys(obj).join(",")); - } -} -const keyFromLoc = ({ start, end }) => `${start.line}|${start.column}|${end.line}|${end.column}`; -const isObj = (o) => !!o && typeof o === "object"; -const isLineCol = (o) => isObj(o) && typeof o.line === "number" && typeof o.column === "number"; -const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); -const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); -// When merging, we can have a case where two ranges cover -// the same block of code with `hits=1`, and each carve out a -// different range with `hits=0` to indicate it's uncovered. -// Find the nearest container so that we can properly indicate -// that both sections are hit. -// Returns null if no containing item is found. -const findNearestContainer = (item, map) => { - const itemLoc = getLoc(item); - if (!itemLoc) - return null; - // the B item is not an identified range in the A set, BUT - // it may be contained by an identified A range. If so, then - // any hit of that containing A range counts as a hit of this - // B range as well. We have to find the *narrowest* containing - // range to be accurate, since ranges can be hit and un-hit - // in a nested fashion. - let nearestContainingItem = null; - let containerDistance = null; - let containerKey = null; - for (const [i, mapItem] of Object.entries(map)) { - const mapLoc = getLoc(mapItem); - if (!mapLoc) - continue; - // contained if all of line distances are > 0 - // or line distance is 0 and col dist is >= 0 - const distance = [ - itemLoc.start.line - mapLoc.start.line, - itemLoc.start.column - mapLoc.start.column, - mapLoc.end.line - itemLoc.end.line, - mapLoc.end.column - itemLoc.end.column, - ]; - if (distance[0] < 0 || - distance[2] < 0 || - (distance[0] === 0 && distance[1] < 0) || - (distance[2] === 0 && distance[3] < 0)) { - continue; - } - if (nearestContainingItem === null) { - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - continue; - } - // closer line more relevant than closer column - const closerBefore = distance[0] < containerDistance[0] || - (distance[0] === 0 && distance[1] < containerDistance[1]); - const closerAfter = distance[2] < containerDistance[2] || - (distance[2] === 0 && distance[3] < containerDistance[3]); - if (closerBefore || closerAfter) { - // closer - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - } - } - return containerKey; -}; -// either add two numbers, or all matching entries in a number[] -const addHits = (aHits, bHits) => { - if (typeof aHits === "number" && typeof bHits === "number") { - return aHits + bHits; - } - else if (Array.isArray(aHits) && Array.isArray(bHits)) { - return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); - } - return null; -}; -const addNearestContainerHits = (item, itemHits, map, mapHits) => { - const container = findNearestContainer(item, map); - if (container) { - return addHits(itemHits, mapHits[container]); - } - else { - return itemHits; - } -}; -const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { - const aItems = {}; - for (const [key, itemHits] of Object.entries(aHits)) { - const item = aMap[key]; - aItems[itemKey(item)] = [itemHits, item]; - } - const bItems = {}; - for (const [key, itemHits] of Object.entries(bHits)) { - const item = bMap[key]; - bItems[itemKey(item)] = [itemHits, item]; - } - const mergedItems = {}; - for (const [key, aValue] of Object.entries(aItems)) { - let aItemHits = aValue[0]; - const aItem = aValue[1]; - const bValue = bItems[key]; - if (!bValue) { - // not an identified range in b, but might be contained by one - aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); - } - else { - // is an identified range in b, so add the hits together - aItemHits = addHits(aItemHits, bValue[0]); - } - mergedItems[key] = [aItemHits, aItem]; - } - // now find the items in b that are not in a. already added matches. - for (const [key, bValue] of Object.entries(bItems)) { - let bItemHits = bValue[0]; - const bItem = bValue[1]; - if (mergedItems[key]) - continue; - // not an identified range in b, but might be contained by one - bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); - mergedItems[key] = [bItemHits, bItem]; - } - const hits = {}; - const map = {}; - Object.values(mergedItems).forEach(([itemHits, item], i) => { - hits[i] = itemHits; - map[i] = item; - }); - return [hits, map]; -}; -/** - * provides a read-only view of coverage for a single file. - * The deep structure of this object is documented elsewhere. It has the following - * properties: - * - * * `path` - the file path for which coverage is being tracked - * * `statementMap` - map of statement locations keyed by statement index - * * `fnMap` - map of function metadata keyed by function index - * * `branchMap` - map of branch metadata keyed by branch index - * * `s` - hit counts for statements - * * `f` - hit count for functions - * * `b` - hit count for branches - */ -class FileCoverage { - /** - * @constructor - * @param {Object|FileCoverage|String} pathOrObj is a string that initializes - * and empty coverage object with the specified file path or a data object that - * has all the required properties for a file coverage object. - */ - constructor(pathOrObj, reportLogic = false) { - if (!pathOrObj) { - throw new Error("Coverage must be initialized with a path or an object"); - } - if (typeof pathOrObj === "string") { - this.data = emptyCoverage(pathOrObj, reportLogic); - } - else if (pathOrObj instanceof FileCoverage) { - this.data = pathOrObj.data; - } - else if (typeof pathOrObj === "object") { - this.data = pathOrObj; - } - else { - throw new Error("Invalid argument to coverage constructor"); - } - assertValidObject(this.data); - } - /** - * returns computed line coverage from statement coverage. - * This is a map of hits keyed by line number in the source. - */ - getLineCoverage() { - const statementMap = this.data.statementMap; - const statements = this.data.s; - const lineMap = Object.create(null); - Object.entries(statements).forEach(([st, count]) => { - /* istanbul ignore if: is this even possible? */ - if (!statementMap[st]) { - return; - } - const { line } = statementMap[st].start; - const prevVal = lineMap[line]; - if (prevVal === undefined || prevVal < count) { - lineMap[line] = count; - } - }); - return lineMap; - } - /** - * returns an array of uncovered line numbers. - * @returns {Array} an array of line numbers for which no hits have been - * collected. - */ - getUncoveredLines() { - const lc = this.getLineCoverage(); - const ret = []; - Object.entries(lc).forEach(([l, hits]) => { - if (hits === 0) { - ret.push(l); - } - }); - return ret; - } - /** - * returns a map of branch coverage by source line number. - * @returns {Object} an object keyed by line number. Each object - * has a `covered`, `total` and `coverage` (percentage) property. - */ - getBranchCoverageByLine() { - const branchMap = this.branchMap; - const branches = this.b; - const ret = {}; - Object.entries(branchMap).forEach(([k, map]) => { - const line = map.line || map.loc.start.line; - const branchData = branches[k]; - ret[line] = ret[line] || []; - ret[line].push(...branchData); - }); - Object.entries(ret).forEach(([k, dataArray]) => { - const covered = dataArray.filter((item) => item > 0); - const coverage = (covered.length / dataArray.length) * 100; - ret[k] = { - covered: covered.length, - total: dataArray.length, - coverage, - }; - }); - return ret; - } - /** - * return a JSON-serializable POJO for this file coverage object - */ - toJSON() { - return this.data; - } - /** - * merges a second coverage object into this one, updating hit counts - * @param {FileCoverage} other - the coverage object to be merged into this one. - * Note that the other object should have the same structure as this one (same file). - */ - merge(other) { - if (other.all === true) { - return; - } - if (this.all === true) { - this.data = other.data; - return; - } - let [hits, map] = mergeProp(this.s, this.statementMap, other.s, other.statementMap); - this.data.s = hits; - this.data.statementMap = map; - const keyFromLocProp = (x) => keyFromLoc(x.loc); - const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); - [hits, map] = mergeProp(this.f, this.fnMap, other.f, other.fnMap, keyFromLocProp); - this.data.f = hits; - this.data.fnMap = map; - [hits, map] = mergeProp(this.b, this.branchMap, other.b, other.branchMap, keyFromLocationsProp); - this.data.b = hits; - this.data.branchMap = map; - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT && other.bT) { - [hits, map] = mergeProp(this.bT, this.branchMap, other.bT, other.branchMap, keyFromLocationsProp); - this.data.bT = hits; - } - } - computeSimpleTotals(property) { - let stats = this[property]; - if (typeof stats === "function") { - stats = stats.call(this); - } - const ret = { - total: Object.keys(stats).length, - covered: Object.values(stats).filter((v) => !!v).length, - skipped: 0, - }; - ret.pct = percent(ret.covered, ret.total); - return ret; - } - computeBranchTotals(property) { - const stats = this[property]; - const ret = { total: 0, covered: 0, skipped: 0 }; - Object.values(stats).forEach((branches) => { - ret.covered += branches.filter((hits) => hits > 0).length; - ret.total += branches.length; - }); - ret.pct = percent(ret.covered, ret.total); - return ret; - } - /** - * resets hit counts for all statements, functions and branches - * in this coverage object resulting in zero coverage. - */ - resetHits() { - const statements = this.s; - const functions = this.f; - const branches = this.b; - const branchesTrue = this.bT; - Object.keys(statements).forEach((s) => { - statements[s] = 0; - }); - Object.keys(functions).forEach((f) => { - functions[f] = 0; - }); - Object.keys(branches).forEach((b) => { - branches[b].fill(0); - }); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (branchesTrue) { - Object.keys(branchesTrue).forEach((bT) => { - branchesTrue[bT].fill(0); - }); - } - } - /** - * returns a CoverageSummary for this file coverage object - * @returns {CoverageSummary} - */ - toSummary() { - const ret = {}; - ret.lines = this.computeSimpleTotals("getLineCoverage"); - ret.functions = this.computeSimpleTotals("f", "fnMap"); - ret.statements = this.computeSimpleTotals("s", "statementMap"); - ret.branches = this.computeBranchTotals("b"); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT) { - ret.branchesTrue = this.computeBranchTotals("bT"); - } - return new CoverageSummary(ret); - } -} -// expose coverage data attributes -dataProperties(FileCoverage, [ - "path", - "statementMap", - "fnMap", - "branchMap", - "s", - "f", - "b", - "bT", - "all", -]); -module.exports = { - FileCoverage, - // exported for testing - findNearestContainer, - addHits, - addNearestContainerHits, -}; -//# sourceMappingURL=file-coverage.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs deleted file mode 100644 index 7e0b1ee99e0..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-coverage/lib/percent.cjs +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -module.exports = function percent(covered, total) { - let tmp; - if (total > 0) { - tmp = (1000 * 100 * covered) / total; - return Math.floor(tmp / 10) / 100; - } - else { - return 100.0; - } -}; -//# sourceMappingURL=percent.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js b/v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js deleted file mode 100644 index 65e53decb91..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -/** - * @module Exports - */ -const Context = require("./lib/context.cjs"); -const watermarks = require("./lib/watermarks.cjs"); -const ReportBase = require("./lib/report-base.cjs"); -module.exports = { - /** - * returns a reporting context for the supplied options - * @param {Object} [opts=null] opts - * @returns {Context} - */ - createContext(opts) { - return new Context(opts); - }, - /** - * returns the default watermarks that would be used when not - * overridden - * @returns {Object} an object with `statements`, `functions`, `branches`, - * and `line` keys. Each value is a 2 element array that has the low and - * high watermark as percentages. - */ - getDefaultWatermarks() { - return watermarks.getDefault(); - }, - /** - * Base class for all reports - */ - ReportBase, -}; -export {}; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs deleted file mode 100644 index 5eb918c4098..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/context.cjs +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const FileWriter = require("./file-writer.cjs"); -const XMLWriter = require("./xml-writer.cjs"); -const tree = require("./tree.cjs"); -const watermarks = require("./watermarks.cjs"); -const SummarizerFactory = require("./summarizer-factory.cjs"); -function defaultSourceLookup(path) { - try { - return fs.readFileSync(path, "utf8"); - } - catch (ex) { - throw new Error(`Unable to lookup source: ${path} (${ex.message})`); - } -} -function normalizeWatermarks(specified = {}) { - Object.entries(watermarks.getDefault()).forEach(([k, value]) => { - const specValue = specified[k]; - if (!Array.isArray(specValue) || specValue.length !== 2) { - specified[k] = value; - } - }); - return specified; -} -/** - * A reporting context that is passed to report implementations - * @param {Object} [opts=null] opts options - * @param {String} [opts.dir='coverage'] opts.dir the reporting directory - * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for - * statements, lines, branches and functions - * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a - * function that returns source code given a file path. Defaults to - * filesystem lookups based on path. - * @constructor - */ -class Context { - constructor(opts) { - this.dir = opts.dir || "coverage"; - this.watermarks = normalizeWatermarks(opts.watermarks); - this.sourceFinder = opts.sourceFinder || defaultSourceLookup; - this._summarizerFactory = new SummarizerFactory(opts.coverageMap, opts.defaultSummarizer); - this.data = {}; - } - /** - * returns a FileWriter implementation for reporting use. Also available - * as the `writer` property on the context. - * @returns {Writer} - */ - getWriter() { - return this.writer; - } - /** - * returns the source code for the specified file path or throws if - * the source could not be found. - * @param {String} filePath the file path as found in a file coverage object - * @returns {String} the source code - */ - getSource(filePath) { - return this.sourceFinder(filePath); - } - /** - * returns the coverage class given a coverage - * types and a percentage value. - * @param {String} type - the coverage type, one of `statements`, `functions`, - * `branches`, or `lines` - * @param {Number} value - the percentage value - * @returns {String} one of `high`, `medium` or `low` - */ - classForPercent(type, value) { - const watermarks = this.watermarks[type]; - if (!watermarks) { - return "unknown"; - } - if (value < watermarks[0]) { - return "low"; - } - if (value >= watermarks[1]) { - return "high"; - } - return "medium"; - } - /** - * returns an XML writer for the supplied content writer - * @param {ContentWriter} contentWriter the content writer to which the returned XML writer - * writes data - * @returns {XMLWriter} - */ - getXMLWriter(contentWriter) { - return new XMLWriter(contentWriter); - } - /** - * returns a full visitor given a partial one. - * @param {Object} partialVisitor a partial visitor only having the functions of - * interest to the caller. These functions are called with a scope that is the - * supplied object. - * @returns {Visitor} - */ - getVisitor(partialVisitor) { - return new tree.Visitor(partialVisitor); - } - getTree(name = "defaultSummarizer") { - return this._summarizerFactory[name]; - } -} -Object.defineProperty(Context.prototype, "writer", { - enumerable: true, - get() { - if (!this.data.writer) { - this.data.writer = new FileWriter(this.dir); - } - return this.data.writer; - }, -}); -module.exports = Context; -//# sourceMappingURL=context.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs deleted file mode 100644 index a79f541a0b6..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/file-writer.cjs +++ /dev/null @@ -1,165 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); -const fs = require("node:fs"); -const { mkdir } = require("node:fs/promises"); -/** - * Base class for writing content - * @class ContentWriter - * @constructor - */ -class ContentWriter { - /** - * returns the colorized version of a string. Typically, - * content writers that write to files will return the - * same string and ones writing to a tty will wrap it in - * appropriate escape sequences. - * @param {String} str the string to colorize - * @param {String} clazz one of `high`, `medium` or `low` - * @returns {String} the colorized form of the string - */ - colorize(str /*, clazz*/) { - return str; - } - /** - * writes a string appended with a newline to the destination - * @param {String} str the string to write - */ - println(str) { - this.write(`${str}\n`); - } - /** - * closes this content writer. Should be called after all writes are complete. - */ - close() { } -} -/** - * a content writer that writes to a file - * @param {Number} fd - the file descriptor - * @extends ContentWriter - * @constructor - */ -class FileContentWriter extends ContentWriter { - constructor(fd) { - super(); - this.fd = fd; - } - write(str) { - fs.writeSync(this.fd, str); - } - close() { - fs.closeSync(this.fd); - } -} -// allow stdout to be captured for tests. -let capture = false; -let output = ""; -/** - * a content writer that writes to the console - * @extends ContentWriter - * @constructor - */ -class ConsoleWriter extends ContentWriter { - write(str) { - if (capture) { - output += str; - } - else { - process.stdout.write(str); - } - } - colorize(str, clazz) { - const colors = { - low: "31;1", - medium: "33;1", - high: "32;1", - }; - return str; - } -} -/** - * utility for writing files under a specific directory - * @class FileWriter - * @param {String} baseDir the base directory under which files should be written - * @constructor - */ -class FileWriter { - constructor(baseDir) { - if (!baseDir) { - throw new Error("baseDir must be specified"); - } - this.baseDir = baseDir; - } - /** - * static helpers for capturing stdout report output; - * super useful for tests! - */ - static startCapture() { - capture = true; - } - static stopCapture() { - capture = false; - } - static getOutput() { - return output; - } - static resetOutput() { - output = ""; - } - /** - * returns a FileWriter that is rooted at the supplied subdirectory - * @param {String} subdir the subdirectory under which to root the - * returned FileWriter - * @returns {FileWriter} - */ - writerForDir(subdir) { - if (path.isAbsolute(subdir)) { - throw new Error(`Cannot create subdir writer for absolute path: ${subdir}`); - } - return new FileWriter(`${this.baseDir}/${subdir}`); - } - /** - * copies a file from a source directory to a destination name - * @param {String} source path to source file - * @param {String} dest relative path to destination file - * @param {String} [header=undefined] optional text to prepend to destination - * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) - */ - copyFile(source, dest, header) { - if (path.isAbsolute(dest)) { - throw new Error(`Cannot write to absolute path: ${dest}`); - } - dest = path.resolve(this.baseDir, dest); - mkdir(path.dirname(dest), { recursive: true }); - let contents; - if (header) { - contents = header + fs.readFileSync(source, "utf8"); - } - else { - contents = fs.readFileSync(source); - } - fs.writeFileSync(dest, contents); - } - /** - * returns a content writer for writing content to the supplied file. - * @param {String|null} file the relative path to the file or the special - * values `"-"` or `null` for writing to the console - * @returns {ContentWriter} - */ - writeFile(file) { - if (file === null || file === "-") { - return new ConsoleWriter(); - } - if (path.isAbsolute(file)) { - throw new Error(`Cannot write to absolute path: ${file}`); - } - file = path.resolve(this.baseDir, file); - mkdir(path.dirname(file), { recursive: true }); - return new FileContentWriter(fs.openSync(file, "w")); - } -} -module.exports = FileWriter; -//# sourceMappingURL=file-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs deleted file mode 100644 index 3bf30e53640..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/path.cjs +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const path = require("node:path"); -let parsePath = path.parse; -let SEP = path.sep; -const origParser = parsePath; -const origSep = SEP; -function makeRelativeNormalizedPath(str, sep) { - const parsed = parsePath(str); - let root = parsed.root; - let dir; - let file = parsed.base; - let quoted; - let pos; - // handle a weird windows case separately - if (sep === "\\") { - pos = root.indexOf(":\\"); - if (pos >= 0) { - root = root.substring(0, pos + 2); - } - } - dir = parsed.dir.substring(root.length); - if (str === "") { - return []; - } - if (sep !== "/") { - quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); - dir = dir.replace(quoted, "/"); - file = file.replace(quoted, "/"); // excessively paranoid? - } - if (dir !== "") { - dir = `${dir}/${file}`; - } - else { - dir = file; - } - if (dir.substring(0, 1) === "/") { - dir = dir.substring(1); - } - dir = dir.split(/\/+/); - return dir; -} -class Path { - constructor(strOrArray) { - if (Array.isArray(strOrArray)) { - this.v = strOrArray; - } - else if (typeof strOrArray === "string") { - this.v = makeRelativeNormalizedPath(strOrArray, SEP); - } - else { - throw new Error(`Invalid Path argument must be string or array:${strOrArray}`); - } - } - toString() { - return this.v.join("/"); - } - hasParent() { - return this.v.length > 0; - } - parent() { - if (!this.hasParent()) { - throw new Error("Unable to get parent for 0 elem path"); - } - const p = this.v.slice(); - p.pop(); - return new Path(p); - } - elements() { - return this.v.slice(); - } - name() { - return this.v.slice(-1)[0]; - } - contains(other) { - let i; - if (other.length > this.length) { - return false; - } - for (i = 0; i < other.length; i += 1) { - if (this.v[i] !== other.v[i]) { - return false; - } - } - return true; - } - ancestorOf(other) { - return other.contains(this) && other.length !== this.length; - } - descendantOf(other) { - return this.contains(other) && other.length !== this.length; - } - commonPrefixPath(other) { - const len = this.length > other.length ? other.length : this.length; - let i; - const ret = []; - for (i = 0; i < len; i += 1) { - if (this.v[i] === other.v[i]) { - ret.push(this.v[i]); - } - else { - break; - } - } - return new Path(ret); - } - static compare(a, b) { - const al = a.length; - const bl = b.length; - if (al < bl) { - return -1; - } - if (al > bl) { - return 1; - } - const astr = a.toString(); - const bstr = b.toString(); - return astr < bstr ? -1 : astr > bstr ? 1 : 0; - } -} -["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { - Object.defineProperty(Path.prototype, fn, { - value(...args) { - return this.v[fn](...args); - }, - }); -}); -Object.defineProperty(Path.prototype, "length", { - enumerable: true, - get() { - return this.v.length; - }, -}); -module.exports = Path; -Path.tester = { - setParserAndSep(p, sep) { - parsePath = p; - SEP = sep; - }, - reset() { - parsePath = origParser; - SEP = origSep; - }, -}; -//# sourceMappingURL=path.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs deleted file mode 100644 index 70ba85a2c68..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/report-base.cjs +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -// TODO: switch to class private field when targeting node.js 12 -const _summarizer = Symbol("ReportBase.#summarizer"); -class ReportBase { - constructor(opts = {}) { - this[_summarizer] = opts.summarizer; - } - execute(context) { - context.getTree(this[_summarizer]).visit(this, context); - } -} -module.exports = ReportBase; -//# sourceMappingURL=report-base.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs deleted file mode 100644 index 795a0d73ee1..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/summarizer-factory.cjs +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const coverage = require("../../lib-coverage/index.cjs"); -const Path = require("./path.cjs"); -const { BaseNode, BaseTree } = require("./tree.cjs"); -class ReportNode extends BaseNode { - constructor(path, fileCoverage) { - super(); - this.path = path; - this.parent = null; - this.fileCoverage = fileCoverage; - this.children = []; - } - static createRoot(children) { - const root = new ReportNode(new Path([])); - children.forEach((child) => { - root.addChild(child); - }); - return root; - } - addChild(child) { - child.parent = this; - this.children.push(child); - } - asRelative(p) { - if (p.substring(0, 1) === "/") { - return p.substring(1); - } - return p; - } - getQualifiedName() { - return this.asRelative(this.path.toString()); - } - getRelativeName() { - const parent = this.getParent(); - const myPath = this.path; - let relPath; - let i; - const parentPath = parent ? parent.path : new Path([]); - if (parentPath.ancestorOf(myPath)) { - relPath = new Path(myPath.elements()); - for (i = 0; i < parentPath.length; i += 1) { - relPath.shift(); - } - return this.asRelative(relPath.toString()); - } - return this.asRelative(this.path.toString()); - } - getParent() { - return this.parent; - } - getChildren() { - return this.children; - } - isSummary() { - return !this.fileCoverage; - } - getFileCoverage() { - return this.fileCoverage; - } - getCoverageSummary(filesOnly) { - const cacheProp = `c_${filesOnly ? "files" : "full"}`; - let summary; - if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { - return this[cacheProp]; - } - if (!this.isSummary()) { - summary = this.getFileCoverage().toSummary(); - } - else { - let count = 0; - summary = coverage.createCoverageSummary(); - this.getChildren().forEach((child) => { - if (filesOnly && child.isSummary()) { - return; - } - count += 1; - summary.merge(child.getCoverageSummary(filesOnly)); - }); - if (count === 0 && filesOnly) { - summary = null; - } - } - this[cacheProp] = summary; - return summary; - } -} -class ReportTree extends BaseTree { - constructor(root, childPrefix) { - super(root); - const maybePrefix = (node) => { - if (childPrefix && !node.isRoot()) { - node.path.unshift(childPrefix); - } - }; - this.visit({ - onDetail: maybePrefix, - onSummary(node) { - maybePrefix(node); - node.children.sort((a, b) => { - const astr = a.path.toString(); - const bstr = b.path.toString(); - return astr < bstr - ? -1 - : astr > bstr - ? 1 - : /* istanbul ignore next */ 0; - }); - }, - }); - } -} -function findCommonParent(paths) { - return paths.reduce((common, path) => common.commonPrefixPath(path), paths[0] || new Path([])); -} -function findOrCreateParent(parentPath, nodeMap, created = () => { }) { - let parent = nodeMap[parentPath.toString()]; - if (!parent) { - parent = new ReportNode(parentPath); - nodeMap[parentPath.toString()] = parent; - created(parentPath, parent); - } - return parent; -} -function toDirParents(list) { - const nodeMap = Object.create(null); - list.forEach((o) => { - const parent = findOrCreateParent(o.path.parent(), nodeMap); - parent.addChild(new ReportNode(o.path, o.fileCoverage)); - }); - return Object.values(nodeMap); -} -function addAllPaths(topPaths, nodeMap, path, node) { - const parent = findOrCreateParent(path.parent(), nodeMap, (parentPath, parent) => { - if (parentPath.hasParent()) { - addAllPaths(topPaths, nodeMap, parentPath, parent); - } - else { - topPaths.push(parent); - } - }); - parent.addChild(node); -} -function foldIntoOneDir(node, parent) { - const { children } = node; - if (children.length === 1 && !children[0].fileCoverage) { - children[0].parent = parent; - return foldIntoOneDir(children[0], parent); - } - node.children = children.map((child) => foldIntoOneDir(child, node)); - return node; -} -function pkgSummaryPrefix(dirParents, commonParent) { - if (!dirParents.some((dp) => dp.path.length === 0)) { - return; - } - if (commonParent.length === 0) { - return "root"; - } - return commonParent.name(); -} -class SummarizerFactory { - constructor(coverageMap, defaultSummarizer = "pkg") { - this._coverageMap = coverageMap; - this._defaultSummarizer = defaultSummarizer; - this._initialList = coverageMap.files().map((filePath) => ({ - filePath, - path: new Path(filePath), - fileCoverage: coverageMap.fileCoverageFor(filePath), - })); - this._commonParent = findCommonParent(this._initialList.map((o) => o.path.parent())); - if (this._commonParent.length > 0) { - this._initialList.forEach((o) => { - o.path.splice(0, this._commonParent.length); - }); - } - } - get defaultSummarizer() { - return this[this._defaultSummarizer]; - } - get flat() { - if (!this._flat) { - this._flat = new ReportTree(ReportNode.createRoot(this._initialList.map((node) => new ReportNode(node.path, node.fileCoverage)))); - } - return this._flat; - } - _createPkg() { - const dirParents = toDirParents(this._initialList); - if (dirParents.length === 1) { - return new ReportTree(dirParents[0]); - } - return new ReportTree(ReportNode.createRoot(dirParents), pkgSummaryPrefix(dirParents, this._commonParent)); - } - get pkg() { - if (!this._pkg) { - this._pkg = this._createPkg(); - } - return this._pkg; - } - _createNested() { - const nodeMap = Object.create(null); - const topPaths = []; - this._initialList.forEach((o) => { - const node = new ReportNode(o.path, o.fileCoverage); - addAllPaths(topPaths, nodeMap, o.path, node); - }); - const topNodes = topPaths.map((node) => foldIntoOneDir(node)); - if (topNodes.length === 1) { - return new ReportTree(topNodes[0]); - } - return new ReportTree(ReportNode.createRoot(topNodes)); - } - get nested() { - if (!this._nested) { - this._nested = this._createNested(); - } - return this._nested; - } -} -module.exports = SummarizerFactory; -//# sourceMappingURL=summarizer-factory.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs deleted file mode 100644 index 784260e959c..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/tree.cjs +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -/** - * An object with methods that are called during the traversal of the coverage tree. - * A visitor has the following methods that are called during tree traversal. - * - * * `onStart(root, state)` - called before traversal begins - * * `onSummary(node, state)` - called for every summary node - * * `onDetail(node, state)` - called for every detail node - * * `onSummaryEnd(node, state)` - called after all children have been visited for - * a summary node. - * * `onEnd(root, state)` - called after traversal ends - * - * @param delegate - a partial visitor that only implements the methods of interest - * The visitor object supplies the missing methods as noops. For example, reports - * that only need the final coverage summary need implement `onStart` and nothing - * else. Reports that use only detailed coverage information need implement `onDetail` - * and nothing else. - * @constructor - */ -class Visitor { - constructor(delegate) { - this.delegate = delegate; - } -} -["Start", "End", "Summary", "SummaryEnd", "Detail"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(Visitor.prototype, fn, { - writable: true, - value(node, state) { - if (typeof this.delegate[fn] === "function") { - this.delegate[fn](node, state); - } - }, - }); -}); -class CompositeVisitor extends Visitor { - constructor(visitors) { - super(); - if (!Array.isArray(visitors)) { - visitors = [visitors]; - } - this.visitors = visitors.map((v) => { - if (v instanceof Visitor) { - return v; - } - return new Visitor(v); - }); - } -} -["Start", "Summary", "SummaryEnd", "Detail", "End"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(CompositeVisitor.prototype, fn, { - value(node, state) { - this.visitors.forEach((v) => { - v[fn](node, state); - }); - }, - }); -}); -class BaseNode { - isRoot() { - return !this.getParent(); - } - /** - * visit all nodes depth-first from this node down. Note that `onStart` - * and `onEnd` are never called on the visitor even if the current - * node is the root of the tree. - * @param visitor a full visitor that is called during tree traversal - * @param state optional state that is passed around - */ - visit(visitor, state) { - if (this.isSummary()) { - visitor.onSummary(this, state); - } - else { - visitor.onDetail(this, state); - } - this.getChildren().forEach((child) => { - child.visit(visitor, state); - }); - if (this.isSummary()) { - visitor.onSummaryEnd(this, state); - } - } -} -/** - * abstract base class for a coverage tree. - * @constructor - */ -class BaseTree { - constructor(root) { - this.root = root; - } - /** - * returns the root node of the tree - */ - getRoot() { - return this.root; - } - /** - * visits the tree depth-first with the supplied partial visitor - * @param visitor - a potentially partial visitor - * @param state - the state to be passed around during tree traversal - */ - visit(visitor, state) { - if (!(visitor instanceof Visitor)) { - visitor = new Visitor(visitor); - } - visitor.onStart(this.getRoot(), state); - this.getRoot().visit(visitor, state); - visitor.onEnd(this.getRoot(), state); - } -} -module.exports = { - BaseTree, - BaseNode, - Visitor, - CompositeVisitor, -}; -//# sourceMappingURL=tree.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs deleted file mode 100644 index 6ba3cb2280a..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/watermarks.cjs +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -module.exports = { - getDefault() { - return { - statements: [50, 80], - functions: [50, 80], - branches: [50, 80], - lines: [50, 80], - }; - }, -}; -//# sourceMappingURL=watermarks.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs deleted file mode 100644 index ce0b0e0eb97..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/lib-report/lib/xml-writer.cjs +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const INDENT = " "; -function attrString(attrs) { - return Object.entries(attrs || {}) - .map(([k, v]) => ` ${k}="${v}"`) - .join(""); -} -/** - * a utility class to produce well-formed, indented XML - * @param {ContentWriter} contentWriter the content writer that this utility wraps - * @constructor - */ -class XMLWriter { - constructor(contentWriter) { - this.cw = contentWriter; - this.stack = []; - } - indent(str) { - return this.stack.map(() => INDENT).join("") + str; - } - /** - * writes the opening XML tag with the supplied attributes - * @param {String} name tag name - * @param {Object} [attrs=null] attrs attributes for the tag - */ - openTag(name, attrs) { - const str = this.indent(`<${name + attrString(attrs)}>`); - this.cw.println(str); - this.stack.push(name); - } - /** - * closes an open XML tag. - * @param {String} name - tag name to close. This must match the writer's - * notion of the tag that is currently open. - */ - closeTag(name) { - if (this.stack.length === 0) { - throw new Error(`Attempt to close tag ${name} when not opened`); - } - const stashed = this.stack.pop(); - const str = ``; - if (stashed !== name) { - throw new Error(`Attempt to close tag ${name} when ${stashed} was the one open`); - } - this.cw.println(this.indent(str)); - } - /** - * writes a tag and its value opening and closing it at the same time - * @param {String} name tag name - * @param {Object} [attrs=null] attrs tag attributes - * @param {String} [content=null] content optional tag content - */ - inlineTag(name, attrs, content) { - let str = "<" + name + attrString(attrs); - if (content) { - str += `>${content}`; - } - else { - str += "/>"; - } - str = this.indent(str); - this.cw.println(str); - } - /** - * closes all open tags and ends the document - */ - closeAll() { - this.stack - .slice() - .reverse() - .forEach((name) => { - this.closeTag(name); - }); - } -} -module.exports = XMLWriter; -//# sourceMappingURL=xml-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/dist/src/coverage/types.js b/v-next/hardhat-vendors/dist/src/coverage/types.js deleted file mode 100644 index 718fd38ae40..00000000000 --- a/v-next/hardhat-vendors/dist/src/coverage/types.js +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendors/node_modules/@types/bn.js b/v-next/hardhat-vendors/node_modules/@types/bn.js deleted file mode 120000 index 112e2ea8381..00000000000 --- a/v-next/hardhat-vendors/node_modules/@types/bn.js +++ /dev/null @@ -1 +0,0 @@ -../../../../node_modules/.pnpm/@types+bn.js@5.2.0/node_modules/@types/bn.js \ No newline at end of file diff --git a/v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs deleted file mode 100644 index d823b800faf..00000000000 --- a/v-next/hardhat-vendors/src/coverage/html-escaper/index.cjs +++ /dev/null @@ -1,24 +0,0 @@ -const { replace } = ""; - -// escape -const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; -const ca = /[&<>'"]/g; - -const esca = { - "&": "&", - "<": "<", - ">": ">", - "'": "'", - '"': """, -}; -const pe = (m) => esca[m]; - -/** - * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. - * @param {string} es the input to safely escape - * @returns {string} the escaped input, and it **throws** an error if - * the input type is unexpected, except for boolean and numbers, - * converted as string. - */ -const escape = (es) => replace.call(es, ca, pe); -exports.escape = escape; diff --git a/v-next/hardhat-vendors/src/coverage/index.js b/v-next/hardhat-vendors/src/coverage/index.js deleted file mode 100644 index e77664e0c22..00000000000 --- a/v-next/hardhat-vendors/src/coverage/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import libCoverage from "./lib-coverage/index.cjs"; -export { libCoverage }; - -import libReport from "./lib-report/index.cjs"; -export { libReport }; - -import reports from "./istanbul-reports/index.cjs"; -export { reports }; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs deleted file mode 100644 index 7db2b63fa9f..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/index.cjs +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); - -module.exports = { - create(name, cfg) { - cfg = cfg || {}; - let Cons; - try { - Cons = require(path.join(__dirname, "lib", name, "index.cjs")); - } catch (e) { - if (e.code !== "MODULE_NOT_FOUND") { - throw e; - } - - Cons = require(name); - } - - return new Cons(cfg); - }, -}; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs deleted file mode 100644 index a9b47a7380a..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/annotator.cjs +++ /dev/null @@ -1,294 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const InsertionText = require("./insertion-text.cjs"); -const lt = "\u0001"; -const gt = "\u0002"; -const RE_LT = //g; -const RE_AMP = /&/g; - -var RE_lt = /\u0001/g; - -var RE_gt = /\u0002/g; - -function title(str) { - return ' title="' + str + '" '; -} - -function customEscape(text) { - text = String(text); - return text - .replace(RE_AMP, "&") - .replace(RE_LT, "<") - .replace(RE_GT, ">") - .replace(RE_lt, "<") - .replace(RE_gt, ">"); -} - -function annotateLines(fileCoverage, structuredText) { - const lineStats = fileCoverage.getLineCoverage(); - if (!lineStats) { - return; - } - Object.entries(lineStats).forEach(([lineNumber, count]) => { - if (structuredText[lineNumber]) { - structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; - structuredText[lineNumber].hits = count; - } - }); -} - -function annotateStatements(fileCoverage, structuredText) { - const statementStats = fileCoverage.s; - const statementMeta = fileCoverage.statementMap; - Object.entries(statementStats).forEach(([stName, count]) => { - const meta = statementMeta[stName]; - const type = count > 0 ? "yes" : "no"; - const startCol = meta.start.column; - let endCol = meta.end.column + 1; - const startLine = meta.start.line; - const endLine = meta.end.line; - const openSpan = - lt + - 'span class="' + - (meta.skip ? "cstat-skip" : "cstat-no") + - '"' + - title("statement not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap( - startCol, - openSpan, - startCol < endCol ? endCol : text.originalLength(), - closeSpan, - ); - } - }); -} - -function annotateFunctions(fileCoverage, structuredText) { - const fnStats = fileCoverage.f; - const fnMeta = fileCoverage.fnMap; - if (!fnStats) { - return; - } - Object.entries(fnStats).forEach(([fName, count]) => { - const meta = fnMeta[fName]; - const type = count > 0 ? "yes" : "no"; - // Some versions of the instrumenter in the wild populate 'func' - // but not 'decl': - const decl = meta.decl || meta.loc; - const startCol = decl.start.column; - let endCol = decl.end.column + 1; - const startLine = decl.start.line; - const endLine = decl.end.line; - const openSpan = - lt + - 'span class="' + - (meta.skip ? "fstat-skip" : "fstat-no") + - '"' + - title("function not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap( - startCol, - openSpan, - startCol < endCol ? endCol : text.originalLength(), - closeSpan, - ); - } - }); -} - -function annotateBranches(fileCoverage, structuredText) { - const branchStats = fileCoverage.b; - const branchMeta = fileCoverage.branchMap; - if (!branchStats) { - return; - } - - Object.entries(branchStats).forEach(([branchName, branchArray]) => { - const sumCount = branchArray.reduce((p, n) => p + n, 0); - const metaArray = branchMeta[branchName].locations; - let i; - let count; - let meta; - let startCol; - let endCol; - let startLine; - let endLine; - let openSpan; - let closeSpan; - let text; - - // only highlight if partial branches are missing or if there is a - // single uncovered branch. - if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { - // Need to recover the metaArray placeholder item to count an implicit else - if ( - // Check if the branch is a conditional if branch. - branchMeta[branchName].type === "if" && - // Check if the branch has an implicit else. - branchArray.length === 2 && - // Check if the implicit else branch is unaccounted for. - metaArray.length === 1 && - // Check if the implicit else branch is uncovered. - branchArray[1] === 0 - ) { - metaArray[1] = { - start: {}, - end: {}, - }; - } - - for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { - count = branchArray[i]; - meta = metaArray[i]; - startCol = meta.start.column; - endCol = meta.end.column + 1; - startLine = meta.start.line; - endLine = meta.end.line; - openSpan = - lt + - 'span class="branch-' + - i + - " " + - (meta.skip ? "cbranch-skip" : "cbranch-no") + - '"' + - title("branch not covered") + - gt; - closeSpan = lt + "/span" + gt; - - // If the branch is an implicit else from an if statement, - // then the coverage report won't show a statistic. - // Therefore, the previous branch will be used to report that - // there is no coverage on that implicit branch. - if ( - count === 0 && - startLine === undefined && - branchMeta[branchName].type === "if" - ) { - const prevMeta = metaArray[i - 1]; - startCol = prevMeta.start.column; - endCol = prevMeta.end.column + 1; - startLine = prevMeta.start.line; - endLine = prevMeta.end.line; - } - - if (count === 0 && structuredText[startLine]) { - //skip branches taken - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - if (branchMeta[branchName].type === "if") { - // 'if' is a special case - // since the else branch might not be visible, being nonexistent - text.insertAt( - startCol, - lt + - 'span class="' + - (meta.skip ? "skip-if-branch" : "missing-if-branch") + - '"' + - title((i === 0 ? "if" : "else") + " path not taken") + - gt + - (i === 0 ? "I" : "E") + - lt + - "/span" + - gt, - true, - false, - ); - } else { - text.wrap( - startCol, - openSpan, - startCol < endCol ? endCol : text.originalLength(), - closeSpan, - ); - } - } - } - } - }); -} - -function annotateSourceCode(fileCoverage, sourceStore) { - let codeArray; - let lineCoverageArray; - try { - const sourceText = sourceStore.getSource(fileCoverage.path); - const code = sourceText.split(/(?:\r?\n)|\r/); - let count = 0; - const structured = code.map((str) => { - count += 1; - return { - line: count, - covered: "neutral", - hits: 0, - text: new InsertionText(str, true), - }; - }); - structured.unshift({ - line: 0, - covered: null, - text: new InsertionText(""), - }); - annotateLines(fileCoverage, structured); - //note: order is important, since statements typically result in spanning the whole line and doing branches late - //causes mismatched tags - annotateBranches(fileCoverage, structured); - annotateFunctions(fileCoverage, structured); - annotateStatements(fileCoverage, structured); - structured.shift(); - - codeArray = structured.map( - (item) => customEscape(item.text.toString()) || " ", - ); - - lineCoverageArray = structured.map((item) => ({ - covered: item.covered, - hits: item.hits > 0 ? item.hits + "x" : " ", - })); - - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: structured.length, - }; - } catch (ex) { - codeArray = [ex.message]; - lineCoverageArray = [{ covered: "no", hits: 0 }]; - String(ex.stack || "") - .split(/\r?\n/) - .forEach((line) => { - codeArray.push(line); - lineCoverageArray.push({ covered: "no", hits: 0 }); - }); - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: codeArray.length, - }; - } -} - -module.exports = annotateSourceCode; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css deleted file mode 100644 index f418035b469..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/base.css +++ /dev/null @@ -1,224 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* yellow */ -.cbranch-no { background: yellow !important; color: #111; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -.highlighted, -.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ - background: #C21F39 !important; -} -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -.medium .chart { border:1px solid #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } - -.coverage-summary td.empty { - opacity: .5; - padding-top: 4px; - padding-bottom: 4px; - line-height: 1; - color: #888; -} - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js deleted file mode 100644 index eb527848ee7..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js +++ /dev/null @@ -1,86 +0,0 @@ -var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; - - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selector that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } - - makeCurrent(nextIndex); - } - - function goToNext() { - var nextIndex = 0; - - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } - - makeCurrent(nextIndex); - } - - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } - - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; -})(); -window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/favicon.png deleted file mode 100644 index c1525b811a167671e9de1fa78aab9f5c0b61cef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js deleted file mode 100644 index 83122f78ace..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/sorter.js +++ /dev/null @@ -1,209 +0,0 @@ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - - // Try to create a RegExp from the searchValue. If it fails (invalid regex), - // it will be treated as a plain text search - let searchRegex; - try { - searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive - } catch (error) { - searchRegex = null; - } - - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - let isMatch = false; - - if (searchRegex) { - // If a valid regex was created, use it for matching - isMatch = searchRegex.test(row.textContent); - } else { - // Otherwise, fall back to the original plain text search - isMatch = row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()); - } - - row.style.display = isMatch ? '' : 'none'; - } - } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css deleted file mode 100644 index b317a7cda31..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js deleted file mode 100644 index ef51e038668..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs deleted file mode 100644 index a958877e7f2..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/index.cjs +++ /dev/null @@ -1,409 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const path = require("node:path"); -const html = require("../../../html-escaper/index.cjs"); -const ReportBase = require("../../../lib-report/lib/report-base.cjs"); -const annotator = require("./annotator.cjs"); - -function htmlHead(details) { - return ` - - Code coverage report for ${html.escape(details.entity)} - - - - - - - - `; -} - -function headerTemplate(details) { - function metricsTemplate({ pct, covered, total }, kind) { - return ` -
- ${pct}% - ${kind} - ${covered}/${total} -
- `; - } - - function skipTemplate(metrics) { - const statements = metrics.statements.skipped; - const branches = metrics.branches.skipped; - const functions = metrics.functions.skipped; - - const countLabel = (c, label, plural) => - c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; - const skips = [].concat( - countLabel(statements, "statement", "s"), - countLabel(functions, "function", "s"), - countLabel(branches, "branch", "es"), - ); - - if (skips.length === 0) { - return ""; - } - - return ` -
- ${skips.join(", ")} - Ignored      -
- `; - } - - return ` - - -${htmlHead(details)} - -
-
-

${details.pathHtml}

-
- ${metricsTemplate(details.metrics.statements, "Statements")} - ${metricsTemplate(details.metrics.branches, "Branches")} - ${metricsTemplate(details.metrics.functions, "Functions")} - ${metricsTemplate(details.metrics.lines, "Lines")} - ${skipTemplate(details.metrics)} -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
- `; -} - -function footerTemplate(details) { - return ` -
-
- - - - - - - - `; -} - -function detailTemplate(data) { - const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); - const lineLink = (num) => - `${num}`; - const lineCount = (line) => - `${line.hits}`; - - /* This is rendered in a `
`, need control of all whitespace. */
-  return [
-    "",
-    `${lineNumbers.map(lineLink).join("\n")}`,
-    `${data.lineCoverage
-      .map(lineCount)
-      .join("\n")}`,
-    `
${data.annotatedCode.join(
-      "\n",
-    )}
`, - "", - ].join(""); -} -const summaryTableHeader = [ - '
', - '', - "", - "", - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - "", - "", - "", -].join("\n"); - -function summaryLineTemplate(details) { - const { reportClasses, metrics, file, output } = details; - const percentGraph = (pct) => { - if (!isFinite(pct)) { - return ""; - } - - const cls = ["cover-fill"]; - if (pct === 100) { - cls.push("cover-full"); - } - - pct = Math.floor(pct); - return [ - `
`, - `
`, - ].join(""); - }; - const summaryType = (type, showGraph = false) => { - const info = metrics[type]; - const reportClass = reportClasses[type]; - const result = [ - ``, - ``, - ]; - if (showGraph) { - result.unshift( - ``, - ); - } - - return result; - }; - - return [] - .concat( - "", - ``, - summaryType("statements", true), - summaryType("branches"), - summaryType("functions"), - summaryType("lines"), - "\n", - ) - .join("\n\t"); -} - -const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, - `
${percentGraph(info.pct)}
`, - `
${html.escape(file)}
", "
"].join("\n"); -const emptyClasses = { - statements: "empty", - lines: "empty", - functions: "empty", - branches: "empty", -}; - -const standardLinkMapper = { - getPath(node) { - if (typeof node === "string") { - return node; - } - let filePath = node.getQualifiedName(); - if (node.isSummary()) { - if (filePath !== "") { - filePath += "/index.html"; - } else { - filePath = "index.html"; - } - } else { - filePath += ".html"; - } - return filePath; - }, - - relativePath(source, target) { - const targetPath = this.getPath(target); - const sourcePath = path.dirname(this.getPath(source)); - return path.posix.relative(sourcePath, targetPath); - }, - - assetPath(node, name) { - return this.relativePath(this.getPath(node), name); - }, -}; - -function fixPct(metrics) { - Object.keys(emptyClasses).forEach((key) => { - metrics[key].pct = 0; - }); - return metrics; -} - -class HtmlReport extends ReportBase { - constructor(opts) { - super(); - - this.verbose = opts.verbose; - this.linkMapper = opts.linkMapper || standardLinkMapper; - this.subdir = opts.subdir || ""; - this.date = new Date().toISOString(); - this.skipEmpty = opts.skipEmpty; - } - - getBreadcrumbHtml(node) { - let parent = node.getParent(); - const nodePath = []; - - while (parent) { - nodePath.push(parent); - parent = parent.getParent(); - } - - const linkPath = nodePath.map((ancestor) => { - const target = this.linkMapper.relativePath(node, ancestor); - const name = ancestor.getRelativeName() || "All files"; - return '' + name + ""; - }); - - linkPath.reverse(); - return linkPath.length > 0 - ? linkPath.join(" / ") + " " + node.getRelativeName() - : "All files"; - } - - fillTemplate(node, templateData, context) { - const linkMapper = this.linkMapper; - const summary = node.getCoverageSummary(); - templateData.entity = node.getQualifiedName() || "All files"; - templateData.metrics = summary; - templateData.reportClass = context.classForPercent( - "statements", - summary.statements.pct, - ); - templateData.pathHtml = this.getBreadcrumbHtml(node); - templateData.base = { - css: linkMapper.assetPath(node, "base.css"), - }; - templateData.sorter = { - js: linkMapper.assetPath(node, "sorter.js"), - image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), - }; - templateData.blockNavigation = { - js: linkMapper.assetPath(node, "block-navigation.js"), - }; - templateData.prettify = { - js: linkMapper.assetPath(node, "prettify.js"), - css: linkMapper.assetPath(node, "prettify.css"), - }; - templateData.favicon = linkMapper.assetPath(node, "favicon.png"); - } - - getTemplateData() { - return { datetime: this.date }; - } - - getWriter(context) { - if (!this.subdir) { - return context.writer; - } - return context.writer.writerForDir(this.subdir); - } - - onStart(root, context) { - const assetHeaders = { - ".js": "/* eslint-disable */\n", - }; - - [".", "vendor"].forEach((subdir) => { - const writer = this.getWriter(context); - const srcDir = path.resolve(__dirname, "assets", subdir); - fs.readdirSync(srcDir).forEach((f) => { - const resolvedSource = path.resolve(srcDir, f); - const resolvedDestination = "."; - const stat = fs.statSync(resolvedSource); - let dest; - - if (stat.isFile()) { - dest = resolvedDestination + "/" + f; - if (this.verbose) { - console.log("Write asset: " + dest); - } - writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); - } - }); - }); - } - - onSummary(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - const children = node.getChildren(); - const skipEmpty = this.skipEmpty; - - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write(summaryTableHeader); - children.forEach((child) => { - const metrics = child.getCoverageSummary(); - const isEmpty = metrics.isEmpty(); - if (skipEmpty && isEmpty) { - return; - } - const reportClasses = isEmpty - ? emptyClasses - : { - statements: context.classForPercent( - "statements", - metrics.statements.pct, - ), - lines: context.classForPercent("lines", metrics.lines.pct), - functions: context.classForPercent( - "functions", - metrics.functions.pct, - ), - branches: context.classForPercent("branches", metrics.branches.pct), - }; - const data = { - metrics: isEmpty ? fixPct(metrics) : metrics, - reportClasses, - file: child.getRelativeName(), - output: linkMapper.relativePath(node, child), - }; - cw.write(summaryLineTemplate(data) + "\n"); - }); - cw.write(summaryTableFooter); - cw.write(footerTemplate(templateData)); - cw.close(); - } - - onDetail(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write('
\n');
-    cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
-    cw.write("
\n"); - cw.write(footerTemplate(templateData)); - cw.close(); - } -} - -module.exports = HtmlReport; diff --git a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs deleted file mode 100644 index 6f8064245c2..00000000000 --- a/v-next/hardhat-vendors/src/coverage/istanbul-reports/lib/html/insertion-text.cjs +++ /dev/null @@ -1,114 +0,0 @@ -'use strict'; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -function InsertionText(text, consumeBlanks) { - this.text = text; - this.origLength = text.length; - this.offsets = []; - this.consumeBlanks = consumeBlanks; - this.startPos = this.findFirstNonBlank(); - this.endPos = this.findLastNonBlank(); -} - -const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; - -InsertionText.prototype = { - findFirstNonBlank() { - let pos = -1; - const text = this.text; - const len = text.length; - let i; - for (i = 0; i < len; i += 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - findLastNonBlank() { - const text = this.text; - const len = text.length; - let pos = text.length + 1; - let i; - for (i = len - 1; i >= 0; i -= 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - originalLength() { - return this.origLength; - }, - - insertAt(col, str, insertBefore, consumeBlanks) { - consumeBlanks = - typeof consumeBlanks === 'undefined' - ? this.consumeBlanks - : consumeBlanks; - col = col > this.originalLength() ? this.originalLength() : col; - col = col < 0 ? 0 : col; - - if (consumeBlanks) { - if (col <= this.startPos) { - col = 0; - } - if (col > this.endPos) { - col = this.origLength; - } - } - - const len = str.length; - const offset = this.findOffset(col, len, insertBefore); - const realPos = col + offset; - const text = this.text; - this.text = text.substring(0, realPos) + str + text.substring(realPos); - return this; - }, - - findOffset(pos, len, insertBefore) { - const offsets = this.offsets; - let offsetObj; - let cumulativeOffset = 0; - let i; - - for (i = 0; i < offsets.length; i += 1) { - offsetObj = offsets[i]; - if ( - offsetObj.pos < pos || - (offsetObj.pos === pos && !insertBefore) - ) { - cumulativeOffset += offsetObj.len; - } - if (offsetObj.pos >= pos) { - break; - } - } - if (offsetObj && offsetObj.pos === pos) { - offsetObj.len += len; - } else { - offsets.splice(i, 0, { pos, len }); - } - return cumulativeOffset; - }, - - wrap(startPos, startText, endPos, endText, consumeBlanks) { - this.insertAt(startPos, startText, true, consumeBlanks); - this.insertAt(endPos, endText, false, consumeBlanks); - return this; - }, - - wrapLine(startText, endText) { - this.wrap(0, startText, this.originalLength(), endText); - }, - - toString() { - return this.text; - } -}; - -module.exports = InsertionText; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs deleted file mode 100644 index c6074ee2d56..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-coverage/index.cjs +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -/** - * istanbul-lib-coverage exports an API that allows you to create and manipulate - * file coverage, coverage maps (a set of file coverage objects) and summary - * coverage objects. File coverage for the same file can be merged as can - * entire coverage maps. - * - * @module Exports - */ -const { FileCoverage } = require("./lib/file-coverage.cjs"); -const { CoverageMap } = require("./lib/coverage-map.cjs"); -const { CoverageSummary } = require("./lib/coverage-summary.cjs"); - -module.exports = { - /** - * creates a coverage summary object - * @param {Object} obj an argument with the same semantics - * as the one passed to the `CoverageSummary` constructor - * @returns {CoverageSummary} - */ - createCoverageSummary(obj) { - if (obj && obj instanceof CoverageSummary) { - return obj; - } - return new CoverageSummary(obj); - }, - /** - * creates a CoverageMap object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the CoverageMap constructor. - * @returns {CoverageMap} - */ - createCoverageMap(obj) { - if (obj && obj instanceof CoverageMap) { - return obj; - } - return new CoverageMap(obj); - }, - /** - * creates a FileCoverage object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the FileCoverage constructor. - * @returns {FileCoverage} - */ - createFileCoverage(obj) { - if (obj && obj instanceof FileCoverage) { - return obj; - } - return new FileCoverage(obj); - }, -}; - -/** classes exported for reuse */ -module.exports.classes = { - /** - * the file coverage constructor - */ - FileCoverage, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs deleted file mode 100644 index d5820c2c740..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-map.cjs +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const { FileCoverage } = require("./file-coverage.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); - -function maybeConstruct(obj, klass) { - if (obj instanceof klass) { - return obj; - } - - return new klass(obj); -} - -function loadMap(source) { - const data = Object.create(null); - if (!source) { - return data; - } - - Object.entries(source).forEach(([k, cov]) => { - data[k] = maybeConstruct(cov, FileCoverage); - }); - - return data; -} - -/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ -class CoverageMap { - /** - * @constructor - * @param {Object} [obj=undefined] obj A coverage map from which to initialize this - * map's contents. This can be the raw global coverage object. - */ - constructor(obj) { - if (obj instanceof CoverageMap) { - this.data = obj.data; - } else { - this.data = loadMap(obj); - } - } - - /** - * merges a second coverage map into this one - * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged - * correctly for the same files and additional file coverage keys are created - * as needed. - */ - merge(obj) { - const other = maybeConstruct(obj, CoverageMap); - Object.values(other.data).forEach((fc) => { - this.addFileCoverage(fc); - }); - } - - /** - * filter the coveragemap based on the callback provided - * @param {Function (filename)} callback - Returns true if the path - * should be included in the coveragemap. False if it should be - * removed. - */ - filter(callback) { - Object.keys(this.data).forEach((k) => { - if (!callback(k)) { - delete this.data[k]; - } - }); - } - - /** - * returns a JSON-serializable POJO for this coverage map - * @returns {Object} - */ - toJSON() { - return this.data; - } - - /** - * returns an array for file paths for which this map has coverage - * @returns {Array{string}} - array of files - */ - files() { - return Object.keys(this.data); - } - - /** - * returns the file coverage for the specified file. - * @param {String} file - * @returns {FileCoverage} - */ - fileCoverageFor(file) { - const fc = this.data[file]; - if (!fc) { - throw new Error(`No file coverage available for: ${file}`); - } - return fc; - } - - addFileCoverage(fc) { - const cov = new FileCoverage(fc); - const { path } = cov; - if (this.data[path]) { - this.data[path].merge(cov); - } else { - this.data[path] = cov; - } - } - - /** - * returns the coverage summary for all the file coverage objects in this map. - * @returns {CoverageSummary} - */ - getCoverageSummary() { - const ret = new CoverageSummary(); - Object.values(this.data).forEach((fc) => { - ret.merge(fc.toSummary()); - }); - - return ret; - } -} - -module.exports = { - CoverageMap, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs deleted file mode 100644 index 1e6a9498936..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/coverage-summary.cjs +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); - -function blankSummary() { - const empty = () => ({ - total: 0, - covered: 0, - skipped: 0, - pct: "Unknown", - }); - - return { - lines: empty(), - statements: empty(), - functions: empty(), - branches: empty(), - branchesTrue: empty(), - }; -} - -// asserts that a data object "looks like" a summary coverage object -function assertValidSummary(obj) { - const valid = - obj && obj.lines && obj.statements && obj.functions && obj.branches; - if (!valid) { - throw new Error( - "Invalid summary coverage object, missing keys, found:" + - Object.keys(obj).join(","), - ); - } -} - -/** - * CoverageSummary provides a summary of code coverage . It exposes 4 properties, - * `lines`, `statements`, `branches`, and `functions`. Each of these properties - * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. - * `pct` is a percentage number (0-100). - */ -class CoverageSummary { - /** - * @constructor - * @param {Object|CoverageSummary} [obj=undefined] an optional data object or - * another coverage summary to initialize this object with. - */ - constructor(obj) { - if (!obj) { - this.data = blankSummary(); - } else if (obj instanceof CoverageSummary) { - this.data = obj.data; - } else { - this.data = obj; - } - assertValidSummary(this.data); - } - - /** - * merges a second summary coverage object into this one - * @param {CoverageSummary} obj - another coverage summary object - */ - merge(obj) { - const keys = [ - "lines", - "statements", - "branches", - "functions", - "branchesTrue", - ]; - keys.forEach((key) => { - if (obj[key]) { - this[key].total += obj[key].total; - this[key].covered += obj[key].covered; - this[key].skipped += obj[key].skipped; - this[key].pct = percent(this[key].covered, this[key].total); - } - }); - - return this; - } - - /** - * returns a POJO that is JSON serializable. May be used to get the raw - * summary object. - */ - toJSON() { - return this.data; - } - - /** - * return true if summary has no lines of code - */ - isEmpty() { - return this.lines.total === 0; - } -} - -dataProperties(CoverageSummary, [ - "lines", - "statements", - "functions", - "branches", - "branchesTrue", -]); - -module.exports = { - CoverageSummary, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs deleted file mode 100644 index ad6ac0e1453..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/data-properties.cjs +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -module.exports = function dataProperties(klass, properties) { - properties.forEach((p) => { - Object.defineProperty(klass.prototype, p, { - enumerable: true, - get() { - return this.data[p]; - }, - }); - }); -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs deleted file mode 100644 index 47f45bbd63f..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/file-coverage.cjs +++ /dev/null @@ -1,442 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); - -// returns a data object that represents empty coverage -function emptyCoverage(filePath, reportLogic) { - const cov = { - path: filePath, - statementMap: {}, - fnMap: {}, - branchMap: {}, - s: {}, - f: {}, - b: {}, - }; - if (reportLogic) cov.bT = {}; - return cov; -} - -// asserts that a data object "looks like" a coverage object -function assertValidObject(obj) { - const valid = - obj && - obj.path && - obj.statementMap && - obj.fnMap && - obj.branchMap && - obj.s && - obj.f && - obj.b; - if (!valid) { - throw new Error( - "Invalid file coverage object, missing keys, found:" + - Object.keys(obj).join(","), - ); - } -} - -const keyFromLoc = ({ start, end }) => - `${start.line}|${start.column}|${end.line}|${end.column}`; - -const isObj = (o) => !!o && typeof o === "object"; -const isLineCol = (o) => - isObj(o) && typeof o.line === "number" && typeof o.column === "number"; -const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); -const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); - -// When merging, we can have a case where two ranges cover -// the same block of code with `hits=1`, and each carve out a -// different range with `hits=0` to indicate it's uncovered. -// Find the nearest container so that we can properly indicate -// that both sections are hit. -// Returns null if no containing item is found. -const findNearestContainer = (item, map) => { - const itemLoc = getLoc(item); - if (!itemLoc) return null; - // the B item is not an identified range in the A set, BUT - // it may be contained by an identified A range. If so, then - // any hit of that containing A range counts as a hit of this - // B range as well. We have to find the *narrowest* containing - // range to be accurate, since ranges can be hit and un-hit - // in a nested fashion. - let nearestContainingItem = null; - let containerDistance = null; - let containerKey = null; - for (const [i, mapItem] of Object.entries(map)) { - const mapLoc = getLoc(mapItem); - if (!mapLoc) continue; - // contained if all of line distances are > 0 - // or line distance is 0 and col dist is >= 0 - const distance = [ - itemLoc.start.line - mapLoc.start.line, - itemLoc.start.column - mapLoc.start.column, - mapLoc.end.line - itemLoc.end.line, - mapLoc.end.column - itemLoc.end.column, - ]; - if ( - distance[0] < 0 || - distance[2] < 0 || - (distance[0] === 0 && distance[1] < 0) || - (distance[2] === 0 && distance[3] < 0) - ) { - continue; - } - if (nearestContainingItem === null) { - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - continue; - } - // closer line more relevant than closer column - const closerBefore = - distance[0] < containerDistance[0] || - (distance[0] === 0 && distance[1] < containerDistance[1]); - const closerAfter = - distance[2] < containerDistance[2] || - (distance[2] === 0 && distance[3] < containerDistance[3]); - if (closerBefore || closerAfter) { - // closer - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - } - } - return containerKey; -}; - -// either add two numbers, or all matching entries in a number[] -const addHits = (aHits, bHits) => { - if (typeof aHits === "number" && typeof bHits === "number") { - return aHits + bHits; - } else if (Array.isArray(aHits) && Array.isArray(bHits)) { - return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); - } - return null; -}; - -const addNearestContainerHits = (item, itemHits, map, mapHits) => { - const container = findNearestContainer(item, map); - if (container) { - return addHits(itemHits, mapHits[container]); - } else { - return itemHits; - } -}; - -const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { - const aItems = {}; - for (const [key, itemHits] of Object.entries(aHits)) { - const item = aMap[key]; - aItems[itemKey(item)] = [itemHits, item]; - } - const bItems = {}; - for (const [key, itemHits] of Object.entries(bHits)) { - const item = bMap[key]; - bItems[itemKey(item)] = [itemHits, item]; - } - const mergedItems = {}; - for (const [key, aValue] of Object.entries(aItems)) { - let aItemHits = aValue[0]; - const aItem = aValue[1]; - const bValue = bItems[key]; - if (!bValue) { - // not an identified range in b, but might be contained by one - aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); - } else { - // is an identified range in b, so add the hits together - aItemHits = addHits(aItemHits, bValue[0]); - } - mergedItems[key] = [aItemHits, aItem]; - } - // now find the items in b that are not in a. already added matches. - for (const [key, bValue] of Object.entries(bItems)) { - let bItemHits = bValue[0]; - const bItem = bValue[1]; - if (mergedItems[key]) continue; - // not an identified range in b, but might be contained by one - bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); - mergedItems[key] = [bItemHits, bItem]; - } - - const hits = {}; - const map = {}; - - Object.values(mergedItems).forEach(([itemHits, item], i) => { - hits[i] = itemHits; - map[i] = item; - }); - - return [hits, map]; -}; - -/** - * provides a read-only view of coverage for a single file. - * The deep structure of this object is documented elsewhere. It has the following - * properties: - * - * * `path` - the file path for which coverage is being tracked - * * `statementMap` - map of statement locations keyed by statement index - * * `fnMap` - map of function metadata keyed by function index - * * `branchMap` - map of branch metadata keyed by branch index - * * `s` - hit counts for statements - * * `f` - hit count for functions - * * `b` - hit count for branches - */ -class FileCoverage { - /** - * @constructor - * @param {Object|FileCoverage|String} pathOrObj is a string that initializes - * and empty coverage object with the specified file path or a data object that - * has all the required properties for a file coverage object. - */ - constructor(pathOrObj, reportLogic = false) { - if (!pathOrObj) { - throw new Error("Coverage must be initialized with a path or an object"); - } - if (typeof pathOrObj === "string") { - this.data = emptyCoverage(pathOrObj, reportLogic); - } else if (pathOrObj instanceof FileCoverage) { - this.data = pathOrObj.data; - } else if (typeof pathOrObj === "object") { - this.data = pathOrObj; - } else { - throw new Error("Invalid argument to coverage constructor"); - } - assertValidObject(this.data); - } - - /** - * returns computed line coverage from statement coverage. - * This is a map of hits keyed by line number in the source. - */ - getLineCoverage() { - const statementMap = this.data.statementMap; - const statements = this.data.s; - const lineMap = Object.create(null); - - Object.entries(statements).forEach(([st, count]) => { - /* istanbul ignore if: is this even possible? */ - if (!statementMap[st]) { - return; - } - const { line } = statementMap[st].start; - const prevVal = lineMap[line]; - if (prevVal === undefined || prevVal < count) { - lineMap[line] = count; - } - }); - return lineMap; - } - - /** - * returns an array of uncovered line numbers. - * @returns {Array} an array of line numbers for which no hits have been - * collected. - */ - getUncoveredLines() { - const lc = this.getLineCoverage(); - const ret = []; - Object.entries(lc).forEach(([l, hits]) => { - if (hits === 0) { - ret.push(l); - } - }); - return ret; - } - - /** - * returns a map of branch coverage by source line number. - * @returns {Object} an object keyed by line number. Each object - * has a `covered`, `total` and `coverage` (percentage) property. - */ - getBranchCoverageByLine() { - const branchMap = this.branchMap; - const branches = this.b; - const ret = {}; - Object.entries(branchMap).forEach(([k, map]) => { - const line = map.line || map.loc.start.line; - const branchData = branches[k]; - ret[line] = ret[line] || []; - ret[line].push(...branchData); - }); - Object.entries(ret).forEach(([k, dataArray]) => { - const covered = dataArray.filter((item) => item > 0); - const coverage = (covered.length / dataArray.length) * 100; - ret[k] = { - covered: covered.length, - total: dataArray.length, - coverage, - }; - }); - return ret; - } - - /** - * return a JSON-serializable POJO for this file coverage object - */ - toJSON() { - return this.data; - } - - /** - * merges a second coverage object into this one, updating hit counts - * @param {FileCoverage} other - the coverage object to be merged into this one. - * Note that the other object should have the same structure as this one (same file). - */ - merge(other) { - if (other.all === true) { - return; - } - - if (this.all === true) { - this.data = other.data; - return; - } - - let [hits, map] = mergeProp( - this.s, - this.statementMap, - other.s, - other.statementMap, - ); - this.data.s = hits; - this.data.statementMap = map; - - const keyFromLocProp = (x) => keyFromLoc(x.loc); - const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); - - [hits, map] = mergeProp( - this.f, - this.fnMap, - other.f, - other.fnMap, - keyFromLocProp, - ); - this.data.f = hits; - this.data.fnMap = map; - - [hits, map] = mergeProp( - this.b, - this.branchMap, - other.b, - other.branchMap, - keyFromLocationsProp, - ); - this.data.b = hits; - this.data.branchMap = map; - - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT && other.bT) { - [hits, map] = mergeProp( - this.bT, - this.branchMap, - other.bT, - other.branchMap, - keyFromLocationsProp, - ); - this.data.bT = hits; - } - } - - computeSimpleTotals(property) { - let stats = this[property]; - - if (typeof stats === "function") { - stats = stats.call(this); - } - - const ret = { - total: Object.keys(stats).length, - covered: Object.values(stats).filter((v) => !!v).length, - skipped: 0, - }; - ret.pct = percent(ret.covered, ret.total); - return ret; - } - - computeBranchTotals(property) { - const stats = this[property]; - const ret = { total: 0, covered: 0, skipped: 0 }; - - Object.values(stats).forEach((branches) => { - ret.covered += branches.filter((hits) => hits > 0).length; - ret.total += branches.length; - }); - ret.pct = percent(ret.covered, ret.total); - return ret; - } - - /** - * resets hit counts for all statements, functions and branches - * in this coverage object resulting in zero coverage. - */ - resetHits() { - const statements = this.s; - const functions = this.f; - const branches = this.b; - const branchesTrue = this.bT; - Object.keys(statements).forEach((s) => { - statements[s] = 0; - }); - Object.keys(functions).forEach((f) => { - functions[f] = 0; - }); - Object.keys(branches).forEach((b) => { - branches[b].fill(0); - }); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (branchesTrue) { - Object.keys(branchesTrue).forEach((bT) => { - branchesTrue[bT].fill(0); - }); - } - } - - /** - * returns a CoverageSummary for this file coverage object - * @returns {CoverageSummary} - */ - toSummary() { - const ret = {}; - ret.lines = this.computeSimpleTotals("getLineCoverage"); - ret.functions = this.computeSimpleTotals("f", "fnMap"); - ret.statements = this.computeSimpleTotals("s", "statementMap"); - ret.branches = this.computeBranchTotals("b"); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT) { - ret.branchesTrue = this.computeBranchTotals("bT"); - } - return new CoverageSummary(ret); - } -} - -// expose coverage data attributes -dataProperties(FileCoverage, [ - "path", - "statementMap", - "fnMap", - "branchMap", - "s", - "f", - "b", - "bT", - "all", -]); - -module.exports = { - FileCoverage, - // exported for testing - findNearestContainer, - addHits, - addNearestContainerHits, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs deleted file mode 100644 index ecb468d56b9..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-coverage/lib/percent.cjs +++ /dev/null @@ -1,15 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -module.exports = function percent(covered, total) { - let tmp; - if (total > 0) { - tmp = (1000 * 100 * covered) / total; - return Math.floor(tmp / 10) / 100; - } else { - return 100.0; - } -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/ciao.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/ciao.cjs deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/index.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/index.cjs deleted file mode 100644 index f7aad0370c1..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/index.cjs +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -/** - * @module Exports - */ - -const Context = require("./lib/context.cjs"); -const watermarks = require("./lib/watermarks.cjs"); -const ReportBase = require("./lib/report-base.cjs"); - -module.exports = { - /** - * returns a reporting context for the supplied options - * @param {Object} [opts=null] opts - * @returns {Context} - */ - createContext(opts) { - return new Context(opts); - }, - - /** - * returns the default watermarks that would be used when not - * overridden - * @returns {Object} an object with `statements`, `functions`, `branches`, - * and `line` keys. Each value is a 2 element array that has the low and - * high watermark as percentages. - */ - getDefaultWatermarks() { - return watermarks.getDefault(); - }, - - /** - * Base class for all reports - */ - ReportBase, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs deleted file mode 100644 index 92ab1478486..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/context.cjs +++ /dev/null @@ -1,132 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const FileWriter = require("./file-writer.cjs"); -const XMLWriter = require("./xml-writer.cjs"); -const tree = require("./tree.cjs"); -const watermarks = require("./watermarks.cjs"); -const SummarizerFactory = require("./summarizer-factory.cjs"); - -function defaultSourceLookup(path) { - try { - return fs.readFileSync(path, "utf8"); - } catch (ex) { - throw new Error(`Unable to lookup source: ${path} (${ex.message})`); - } -} - -function normalizeWatermarks(specified = {}) { - Object.entries(watermarks.getDefault()).forEach(([k, value]) => { - const specValue = specified[k]; - if (!Array.isArray(specValue) || specValue.length !== 2) { - specified[k] = value; - } - }); - - return specified; -} - -/** - * A reporting context that is passed to report implementations - * @param {Object} [opts=null] opts options - * @param {String} [opts.dir='coverage'] opts.dir the reporting directory - * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for - * statements, lines, branches and functions - * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a - * function that returns source code given a file path. Defaults to - * filesystem lookups based on path. - * @constructor - */ -class Context { - constructor(opts) { - this.dir = opts.dir || "coverage"; - this.watermarks = normalizeWatermarks(opts.watermarks); - this.sourceFinder = opts.sourceFinder || defaultSourceLookup; - this._summarizerFactory = new SummarizerFactory( - opts.coverageMap, - opts.defaultSummarizer, - ); - this.data = {}; - } - - /** - * returns a FileWriter implementation for reporting use. Also available - * as the `writer` property on the context. - * @returns {Writer} - */ - getWriter() { - return this.writer; - } - - /** - * returns the source code for the specified file path or throws if - * the source could not be found. - * @param {String} filePath the file path as found in a file coverage object - * @returns {String} the source code - */ - getSource(filePath) { - return this.sourceFinder(filePath); - } - - /** - * returns the coverage class given a coverage - * types and a percentage value. - * @param {String} type - the coverage type, one of `statements`, `functions`, - * `branches`, or `lines` - * @param {Number} value - the percentage value - * @returns {String} one of `high`, `medium` or `low` - */ - classForPercent(type, value) { - const watermarks = this.watermarks[type]; - if (!watermarks) { - return "unknown"; - } - if (value < watermarks[0]) { - return "low"; - } - if (value >= watermarks[1]) { - return "high"; - } - return "medium"; - } - - /** - * returns an XML writer for the supplied content writer - * @param {ContentWriter} contentWriter the content writer to which the returned XML writer - * writes data - * @returns {XMLWriter} - */ - getXMLWriter(contentWriter) { - return new XMLWriter(contentWriter); - } - - /** - * returns a full visitor given a partial one. - * @param {Object} partialVisitor a partial visitor only having the functions of - * interest to the caller. These functions are called with a scope that is the - * supplied object. - * @returns {Visitor} - */ - getVisitor(partialVisitor) { - return new tree.Visitor(partialVisitor); - } - - getTree(name = "defaultSummarizer") { - return this._summarizerFactory[name]; - } -} - -Object.defineProperty(Context.prototype, "writer", { - enumerable: true, - get() { - if (!this.data.writer) { - this.data.writer = new FileWriter(this.dir); - } - return this.data.writer; - }, -}); - -module.exports = Context; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs deleted file mode 100644 index 658de8f06f8..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/file-writer.cjs +++ /dev/null @@ -1,184 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); -const fs = require("node:fs"); -const { mkdir } = require("node:fs/promises"); - -/** - * Base class for writing content - * @class ContentWriter - * @constructor - */ -class ContentWriter { - /** - * returns the colorized version of a string. Typically, - * content writers that write to files will return the - * same string and ones writing to a tty will wrap it in - * appropriate escape sequences. - * @param {String} str the string to colorize - * @param {String} clazz one of `high`, `medium` or `low` - * @returns {String} the colorized form of the string - */ - colorize(str /*, clazz*/) { - return str; - } - - /** - * writes a string appended with a newline to the destination - * @param {String} str the string to write - */ - println(str) { - this.write(`${str}\n`); - } - - /** - * closes this content writer. Should be called after all writes are complete. - */ - close() {} -} - -/** - * a content writer that writes to a file - * @param {Number} fd - the file descriptor - * @extends ContentWriter - * @constructor - */ -class FileContentWriter extends ContentWriter { - constructor(fd) { - super(); - - this.fd = fd; - } - - write(str) { - fs.writeSync(this.fd, str); - } - - close() { - fs.closeSync(this.fd); - } -} - -// allow stdout to be captured for tests. -let capture = false; -let output = ""; - -/** - * a content writer that writes to the console - * @extends ContentWriter - * @constructor - */ -class ConsoleWriter extends ContentWriter { - write(str) { - if (capture) { - output += str; - } else { - process.stdout.write(str); - } - } - - colorize(str, clazz) { - const colors = { - low: "31;1", - medium: "33;1", - high: "32;1", - }; - - return str; - } -} - -/** - * utility for writing files under a specific directory - * @class FileWriter - * @param {String} baseDir the base directory under which files should be written - * @constructor - */ -class FileWriter { - constructor(baseDir) { - if (!baseDir) { - throw new Error("baseDir must be specified"); - } - this.baseDir = baseDir; - } - - /** - * static helpers for capturing stdout report output; - * super useful for tests! - */ - static startCapture() { - capture = true; - } - - static stopCapture() { - capture = false; - } - - static getOutput() { - return output; - } - - static resetOutput() { - output = ""; - } - - /** - * returns a FileWriter that is rooted at the supplied subdirectory - * @param {String} subdir the subdirectory under which to root the - * returned FileWriter - * @returns {FileWriter} - */ - writerForDir(subdir) { - if (path.isAbsolute(subdir)) { - throw new Error( - `Cannot create subdir writer for absolute path: ${subdir}`, - ); - } - return new FileWriter(`${this.baseDir}/${subdir}`); - } - - /** - * copies a file from a source directory to a destination name - * @param {String} source path to source file - * @param {String} dest relative path to destination file - * @param {String} [header=undefined] optional text to prepend to destination - * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) - */ - copyFile(source, dest, header) { - if (path.isAbsolute(dest)) { - throw new Error(`Cannot write to absolute path: ${dest}`); - } - dest = path.resolve(this.baseDir, dest); - mkdir(path.dirname(dest), { recursive: true }); - let contents; - if (header) { - contents = header + fs.readFileSync(source, "utf8"); - } else { - contents = fs.readFileSync(source); - } - fs.writeFileSync(dest, contents); - } - - /** - * returns a content writer for writing content to the supplied file. - * @param {String|null} file the relative path to the file or the special - * values `"-"` or `null` for writing to the console - * @returns {ContentWriter} - */ - writeFile(file) { - if (file === null || file === "-") { - return new ConsoleWriter(); - } - if (path.isAbsolute(file)) { - throw new Error(`Cannot write to absolute path: ${file}`); - } - file = path.resolve(this.baseDir, file); - mkdir(path.dirname(file), { recursive: true }); - return new FileContentWriter(fs.openSync(file, "w")); - } -} - -module.exports = FileWriter; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs deleted file mode 100644 index 89f8033883b..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/path.cjs +++ /dev/null @@ -1,169 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const path = require("node:path"); -let parsePath = path.parse; -let SEP = path.sep; -const origParser = parsePath; -const origSep = SEP; - -function makeRelativeNormalizedPath(str, sep) { - const parsed = parsePath(str); - let root = parsed.root; - let dir; - let file = parsed.base; - let quoted; - let pos; - - // handle a weird windows case separately - if (sep === "\\") { - pos = root.indexOf(":\\"); - if (pos >= 0) { - root = root.substring(0, pos + 2); - } - } - dir = parsed.dir.substring(root.length); - - if (str === "") { - return []; - } - - if (sep !== "/") { - quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); - dir = dir.replace(quoted, "/"); - file = file.replace(quoted, "/"); // excessively paranoid? - } - - if (dir !== "") { - dir = `${dir}/${file}`; - } else { - dir = file; - } - if (dir.substring(0, 1) === "/") { - dir = dir.substring(1); - } - dir = dir.split(/\/+/); - return dir; -} - -class Path { - constructor(strOrArray) { - if (Array.isArray(strOrArray)) { - this.v = strOrArray; - } else if (typeof strOrArray === "string") { - this.v = makeRelativeNormalizedPath(strOrArray, SEP); - } else { - throw new Error( - `Invalid Path argument must be string or array:${strOrArray}`, - ); - } - } - - toString() { - return this.v.join("/"); - } - - hasParent() { - return this.v.length > 0; - } - - parent() { - if (!this.hasParent()) { - throw new Error("Unable to get parent for 0 elem path"); - } - const p = this.v.slice(); - p.pop(); - return new Path(p); - } - - elements() { - return this.v.slice(); - } - - name() { - return this.v.slice(-1)[0]; - } - - contains(other) { - let i; - if (other.length > this.length) { - return false; - } - for (i = 0; i < other.length; i += 1) { - if (this.v[i] !== other.v[i]) { - return false; - } - } - return true; - } - - ancestorOf(other) { - return other.contains(this) && other.length !== this.length; - } - - descendantOf(other) { - return this.contains(other) && other.length !== this.length; - } - - commonPrefixPath(other) { - const len = this.length > other.length ? other.length : this.length; - let i; - const ret = []; - - for (i = 0; i < len; i += 1) { - if (this.v[i] === other.v[i]) { - ret.push(this.v[i]); - } else { - break; - } - } - return new Path(ret); - } - - static compare(a, b) { - const al = a.length; - const bl = b.length; - - if (al < bl) { - return -1; - } - - if (al > bl) { - return 1; - } - - const astr = a.toString(); - const bstr = b.toString(); - return astr < bstr ? -1 : astr > bstr ? 1 : 0; - } -} - -["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { - Object.defineProperty(Path.prototype, fn, { - value(...args) { - return this.v[fn](...args); - }, - }); -}); - -Object.defineProperty(Path.prototype, "length", { - enumerable: true, - get() { - return this.v.length; - }, -}); - -module.exports = Path; -Path.tester = { - setParserAndSep(p, sep) { - parsePath = p; - SEP = sep; - }, - reset() { - parsePath = origParser; - SEP = origSep; - }, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs deleted file mode 100644 index 1575121b53b..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/report-base.cjs +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -// TODO: switch to class private field when targeting node.js 12 -const _summarizer = Symbol("ReportBase.#summarizer"); - -class ReportBase { - constructor(opts = {}) { - this[_summarizer] = opts.summarizer; - } - - execute(context) { - context.getTree(this[_summarizer]).visit(this, context); - } -} - -module.exports = ReportBase; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs deleted file mode 100644 index cb2c429bc9a..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/summarizer-factory.cjs +++ /dev/null @@ -1,284 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -const coverage = require("../../lib-coverage/index.cjs"); -const Path = require("./path.cjs"); -const { BaseNode, BaseTree } = require("./tree.cjs"); - -class ReportNode extends BaseNode { - constructor(path, fileCoverage) { - super(); - - this.path = path; - this.parent = null; - this.fileCoverage = fileCoverage; - this.children = []; - } - - static createRoot(children) { - const root = new ReportNode(new Path([])); - - children.forEach((child) => { - root.addChild(child); - }); - - return root; - } - - addChild(child) { - child.parent = this; - this.children.push(child); - } - - asRelative(p) { - if (p.substring(0, 1) === "/") { - return p.substring(1); - } - return p; - } - - getQualifiedName() { - return this.asRelative(this.path.toString()); - } - - getRelativeName() { - const parent = this.getParent(); - const myPath = this.path; - let relPath; - let i; - const parentPath = parent ? parent.path : new Path([]); - if (parentPath.ancestorOf(myPath)) { - relPath = new Path(myPath.elements()); - for (i = 0; i < parentPath.length; i += 1) { - relPath.shift(); - } - return this.asRelative(relPath.toString()); - } - return this.asRelative(this.path.toString()); - } - - getParent() { - return this.parent; - } - - getChildren() { - return this.children; - } - - isSummary() { - return !this.fileCoverage; - } - - getFileCoverage() { - return this.fileCoverage; - } - - getCoverageSummary(filesOnly) { - const cacheProp = `c_${filesOnly ? "files" : "full"}`; - let summary; - - if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { - return this[cacheProp]; - } - - if (!this.isSummary()) { - summary = this.getFileCoverage().toSummary(); - } else { - let count = 0; - summary = coverage.createCoverageSummary(); - this.getChildren().forEach((child) => { - if (filesOnly && child.isSummary()) { - return; - } - count += 1; - summary.merge(child.getCoverageSummary(filesOnly)); - }); - if (count === 0 && filesOnly) { - summary = null; - } - } - this[cacheProp] = summary; - return summary; - } -} - -class ReportTree extends BaseTree { - constructor(root, childPrefix) { - super(root); - - const maybePrefix = (node) => { - if (childPrefix && !node.isRoot()) { - node.path.unshift(childPrefix); - } - }; - this.visit({ - onDetail: maybePrefix, - onSummary(node) { - maybePrefix(node); - node.children.sort((a, b) => { - const astr = a.path.toString(); - const bstr = b.path.toString(); - return astr < bstr - ? -1 - : astr > bstr - ? 1 - : /* istanbul ignore next */ 0; - }); - }, - }); - } -} - -function findCommonParent(paths) { - return paths.reduce( - (common, path) => common.commonPrefixPath(path), - paths[0] || new Path([]), - ); -} - -function findOrCreateParent(parentPath, nodeMap, created = () => {}) { - let parent = nodeMap[parentPath.toString()]; - - if (!parent) { - parent = new ReportNode(parentPath); - nodeMap[parentPath.toString()] = parent; - created(parentPath, parent); - } - - return parent; -} - -function toDirParents(list) { - const nodeMap = Object.create(null); - list.forEach((o) => { - const parent = findOrCreateParent(o.path.parent(), nodeMap); - parent.addChild(new ReportNode(o.path, o.fileCoverage)); - }); - - return Object.values(nodeMap); -} - -function addAllPaths(topPaths, nodeMap, path, node) { - const parent = findOrCreateParent( - path.parent(), - nodeMap, - (parentPath, parent) => { - if (parentPath.hasParent()) { - addAllPaths(topPaths, nodeMap, parentPath, parent); - } else { - topPaths.push(parent); - } - }, - ); - - parent.addChild(node); -} - -function foldIntoOneDir(node, parent) { - const { children } = node; - if (children.length === 1 && !children[0].fileCoverage) { - children[0].parent = parent; - return foldIntoOneDir(children[0], parent); - } - node.children = children.map((child) => foldIntoOneDir(child, node)); - return node; -} - -function pkgSummaryPrefix(dirParents, commonParent) { - if (!dirParents.some((dp) => dp.path.length === 0)) { - return; - } - - if (commonParent.length === 0) { - return "root"; - } - - return commonParent.name(); -} - -class SummarizerFactory { - constructor(coverageMap, defaultSummarizer = "pkg") { - this._coverageMap = coverageMap; - this._defaultSummarizer = defaultSummarizer; - this._initialList = coverageMap.files().map((filePath) => ({ - filePath, - path: new Path(filePath), - fileCoverage: coverageMap.fileCoverageFor(filePath), - })); - this._commonParent = findCommonParent( - this._initialList.map((o) => o.path.parent()), - ); - if (this._commonParent.length > 0) { - this._initialList.forEach((o) => { - o.path.splice(0, this._commonParent.length); - }); - } - } - - get defaultSummarizer() { - return this[this._defaultSummarizer]; - } - - get flat() { - if (!this._flat) { - this._flat = new ReportTree( - ReportNode.createRoot( - this._initialList.map( - (node) => new ReportNode(node.path, node.fileCoverage), - ), - ), - ); - } - - return this._flat; - } - - _createPkg() { - const dirParents = toDirParents(this._initialList); - if (dirParents.length === 1) { - return new ReportTree(dirParents[0]); - } - - return new ReportTree( - ReportNode.createRoot(dirParents), - pkgSummaryPrefix(dirParents, this._commonParent), - ); - } - - get pkg() { - if (!this._pkg) { - this._pkg = this._createPkg(); - } - - return this._pkg; - } - - _createNested() { - const nodeMap = Object.create(null); - const topPaths = []; - this._initialList.forEach((o) => { - const node = new ReportNode(o.path, o.fileCoverage); - addAllPaths(topPaths, nodeMap, o.path, node); - }); - - const topNodes = topPaths.map((node) => foldIntoOneDir(node)); - if (topNodes.length === 1) { - return new ReportTree(topNodes[0]); - } - - return new ReportTree(ReportNode.createRoot(topNodes)); - } - - get nested() { - if (!this._nested) { - this._nested = this._createNested(); - } - - return this._nested; - } -} - -module.exports = SummarizerFactory; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs deleted file mode 100644 index 6bac8b98ea4..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/tree.cjs +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; - -/** - * An object with methods that are called during the traversal of the coverage tree. - * A visitor has the following methods that are called during tree traversal. - * - * * `onStart(root, state)` - called before traversal begins - * * `onSummary(node, state)` - called for every summary node - * * `onDetail(node, state)` - called for every detail node - * * `onSummaryEnd(node, state)` - called after all children have been visited for - * a summary node. - * * `onEnd(root, state)` - called after traversal ends - * - * @param delegate - a partial visitor that only implements the methods of interest - * The visitor object supplies the missing methods as noops. For example, reports - * that only need the final coverage summary need implement `onStart` and nothing - * else. Reports that use only detailed coverage information need implement `onDetail` - * and nothing else. - * @constructor - */ -class Visitor { - constructor(delegate) { - this.delegate = delegate; - } -} - -["Start", "End", "Summary", "SummaryEnd", "Detail"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(Visitor.prototype, fn, { - writable: true, - value(node, state) { - if (typeof this.delegate[fn] === "function") { - this.delegate[fn](node, state); - } - }, - }); - }); - -class CompositeVisitor extends Visitor { - constructor(visitors) { - super(); - - if (!Array.isArray(visitors)) { - visitors = [visitors]; - } - this.visitors = visitors.map((v) => { - if (v instanceof Visitor) { - return v; - } - return new Visitor(v); - }); - } -} - -["Start", "Summary", "SummaryEnd", "Detail", "End"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(CompositeVisitor.prototype, fn, { - value(node, state) { - this.visitors.forEach((v) => { - v[fn](node, state); - }); - }, - }); - }); - -class BaseNode { - isRoot() { - return !this.getParent(); - } - - /** - * visit all nodes depth-first from this node down. Note that `onStart` - * and `onEnd` are never called on the visitor even if the current - * node is the root of the tree. - * @param visitor a full visitor that is called during tree traversal - * @param state optional state that is passed around - */ - visit(visitor, state) { - if (this.isSummary()) { - visitor.onSummary(this, state); - } else { - visitor.onDetail(this, state); - } - - this.getChildren().forEach((child) => { - child.visit(visitor, state); - }); - - if (this.isSummary()) { - visitor.onSummaryEnd(this, state); - } - } -} - -/** - * abstract base class for a coverage tree. - * @constructor - */ -class BaseTree { - constructor(root) { - this.root = root; - } - - /** - * returns the root node of the tree - */ - getRoot() { - return this.root; - } - - /** - * visits the tree depth-first with the supplied partial visitor - * @param visitor - a potentially partial visitor - * @param state - the state to be passed around during tree traversal - */ - visit(visitor, state) { - if (!(visitor instanceof Visitor)) { - visitor = new Visitor(visitor); - } - visitor.onStart(this.getRoot(), state); - this.getRoot().visit(visitor, state); - visitor.onEnd(this.getRoot(), state); - } -} - -module.exports = { - BaseTree, - BaseNode, - Visitor, - CompositeVisitor, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs deleted file mode 100644 index 0be610017a9..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/watermarks.cjs +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -module.exports = { - getDefault() { - return { - statements: [50, 80], - functions: [50, 80], - branches: [50, 80], - lines: [50, 80], - }; - }, -}; diff --git a/v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs deleted file mode 100644 index aea68a1b53f..00000000000 --- a/v-next/hardhat-vendors/src/coverage/lib-report/lib/xml-writer.cjs +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const INDENT = " "; - -function attrString(attrs) { - return Object.entries(attrs || {}) - .map(([k, v]) => ` ${k}="${v}"`) - .join(""); -} - -/** - * a utility class to produce well-formed, indented XML - * @param {ContentWriter} contentWriter the content writer that this utility wraps - * @constructor - */ -class XMLWriter { - constructor(contentWriter) { - this.cw = contentWriter; - this.stack = []; - } - - indent(str) { - return this.stack.map(() => INDENT).join("") + str; - } - - /** - * writes the opening XML tag with the supplied attributes - * @param {String} name tag name - * @param {Object} [attrs=null] attrs attributes for the tag - */ - openTag(name, attrs) { - const str = this.indent(`<${name + attrString(attrs)}>`); - this.cw.println(str); - this.stack.push(name); - } - - /** - * closes an open XML tag. - * @param {String} name - tag name to close. This must match the writer's - * notion of the tag that is currently open. - */ - closeTag(name) { - if (this.stack.length === 0) { - throw new Error(`Attempt to close tag ${name} when not opened`); - } - const stashed = this.stack.pop(); - const str = ``; - - if (stashed !== name) { - throw new Error( - `Attempt to close tag ${name} when ${stashed} was the one open`, - ); - } - this.cw.println(this.indent(str)); - } - - /** - * writes a tag and its value opening and closing it at the same time - * @param {String} name tag name - * @param {Object} [attrs=null] attrs tag attributes - * @param {String} [content=null] content optional tag content - */ - inlineTag(name, attrs, content) { - let str = "<" + name + attrString(attrs); - if (content) { - str += `>${content}`; - } else { - str += "/>"; - } - str = this.indent(str); - this.cw.println(str); - } - - /** - * closes all open tags and ends the document - */ - closeAll() { - this.stack - .slice() - .reverse() - .forEach((name) => { - this.closeTag(name); - }); - } -} - -module.exports = XMLWriter; From c8ea03660491c7ad93144dc235649fff89ef2b17 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:07:29 +0100 Subject: [PATCH 17/32] exclude from gitignore --- .../hardhat-vendored/dist/src/copy-assets.js | 11 + .../dist/src/coverage/html-escaper/index.cjs | 23 + .../dist/src/coverage/index.js | 7 + .../src/coverage/istanbul-reports/index.cjs | 23 + .../istanbul-reports/lib/html/annotator.cjs | 249 ++++++++++ .../istanbul-reports/lib/html/assets/base.css | 224 +++++++++ .../lib/html/assets/block-navigation.js | 86 ++++ .../lib/html/assets/favicon.png | Bin 0 -> 445 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../lib/html/assets/sorter.js | 209 +++++++++ .../lib/html/assets/vendor/prettify.css | 1 + .../lib/html/assets/vendor/prettify.js | 1 + .../istanbul-reports/lib/html/index.cjs | 339 ++++++++++++++ .../lib/html/insertion-text.cjs | 103 ++++ .../dist/src/coverage/lib-coverage/index.cjs | 62 +++ .../lib-coverage/lib/coverage-map.cjs | 115 +++++ .../lib-coverage/lib/coverage-summary.cjs | 101 ++++ .../lib-coverage/lib/data-properties.cjs | 12 + .../lib-coverage/lib/file-coverage.cjs | 387 +++++++++++++++ .../src/coverage/lib-coverage/lib/percent.cjs | 16 + .../dist/src/coverage/lib-report/ciao.cjs | 3 + .../dist/src/coverage/lib-report/index.cjs | 36 ++ .../src/coverage/lib-report/lib/context.cjs | 119 +++++ .../coverage/lib-report/lib/file-writer.cjs | 165 +++++++ .../dist/src/coverage/lib-report/lib/path.cjs | 148 ++++++ .../coverage/lib-report/lib/report-base.cjs | 13 + .../lib-report/lib/summarizer-factory.cjs | 224 +++++++++ .../dist/src/coverage/lib-report/lib/tree.cjs | 126 +++++ .../coverage/lib-report/lib/watermarks.cjs | 16 + .../coverage/lib-report/lib/xml-writer.cjs | 81 ++++ .../dist/src/coverage/types.js | 2 + .../node_modules/@types/bn.js | 1 + .../src/coverage/html-escaper/index.cjs | 24 + v-next/hardhat-vendored/src/coverage/index.js | 8 + .../src/coverage/istanbul-reports/index.cjs | 24 + .../istanbul-reports/lib/html/annotator.cjs | 294 ++++++++++++ .../istanbul-reports/lib/html/assets/base.css | 224 +++++++++ .../lib/html/assets/block-navigation.js | 86 ++++ .../lib/html/assets/favicon.png | Bin 0 -> 445 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../lib/html/assets/sorter.js | 209 +++++++++ .../lib/html/assets/vendor/prettify.css | 1 + .../lib/html/assets/vendor/prettify.js | 1 + .../istanbul-reports/lib/html/index.cjs | 409 ++++++++++++++++ .../lib/html/insertion-text.cjs | 114 +++++ .../src/coverage/lib-coverage/index.cjs | 64 +++ .../lib-coverage/lib/coverage-map.cjs | 128 +++++ .../lib-coverage/lib/coverage-summary.cjs | 112 +++++ .../lib-coverage/lib/data-properties.cjs | 12 + .../lib-coverage/lib/file-coverage.cjs | 442 ++++++++++++++++++ .../src/coverage/lib-coverage/lib/percent.cjs | 15 + .../src/coverage/lib-report/ciao.cjs | 0 .../src/coverage/lib-report/index.cjs | 40 ++ .../src/coverage/lib-report/lib/context.cjs | 132 ++++++ .../coverage/lib-report/lib/file-writer.cjs | 184 ++++++++ .../src/coverage/lib-report/lib/path.cjs | 169 +++++++ .../coverage/lib-report/lib/report-base.cjs | 16 + .../lib-report/lib/summarizer-factory.cjs | 284 +++++++++++ .../src/coverage/lib-report/lib/tree.cjs | 137 ++++++ .../coverage/lib-report/lib/watermarks.cjs | 15 + .../coverage/lib-report/lib/xml-writer.cjs | 90 ++++ 61 files changed, 6137 insertions(+) create mode 100644 v-next/hardhat-vendored/dist/src/copy-assets.js create mode 100644 v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/index.js create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs create mode 100644 v-next/hardhat-vendored/dist/src/coverage/types.js create mode 120000 v-next/hardhat-vendored/node_modules/@types/bn.js create mode 100644 v-next/hardhat-vendored/src/coverage/html-escaper/index.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/index.js create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/index.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/annotator.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/base.css create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/favicon.png create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sorter.js create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/index.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/insertion-text.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-coverage/index.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-map.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-summary.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-coverage/lib/data-properties.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-coverage/lib/file-coverage.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-coverage/lib/percent.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/index.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/context.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/file-writer.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/path.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/report-base.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/summarizer-factory.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/tree.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/watermarks.cjs create mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/lib/xml-writer.cjs diff --git a/v-next/hardhat-vendored/dist/src/copy-assets.js b/v-next/hardhat-vendored/dist/src/copy-assets.js new file mode 100644 index 00000000000..af80157c693 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/copy-assets.js @@ -0,0 +1,11 @@ +import { cp } from "node:fs/promises"; +import path from "node:path"; +async function copyFolder(from, to) { + const src = path.resolve(from); + const dest = path.resolve(to); + await cp(src, dest, { recursive: true, force: true }); + console.log(`Copied folder from ${src} -> ${dest}`); +} +// eslint-disable-next-line no-restricted-syntax -- allow in this post build script +await copyFolder(path.resolve(process.cwd(), "src", "coverage", "istanbul-reports", "lib", "html", "assets"), path.resolve(process.cwd(), "dist", "src", "coverage", "istanbul-reports", "lib", "html", "assets")); +//# sourceMappingURL=copy-assets.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs new file mode 100644 index 00000000000..1f0f029ec88 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs @@ -0,0 +1,23 @@ +"use strict"; +const { replace } = ""; +// escape +const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; +const ca = /[&<>'"]/g; +const esca = { + "&": "&", + "<": "<", + ">": ">", + "'": "'", + '"': """, +}; +const pe = (m) => esca[m]; +/** + * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. + * @param {string} es the input to safely escape + * @returns {string} the escaped input, and it **throws** an error if + * the input type is unexpected, except for boolean and numbers, + * converted as string. + */ +const escape = (es) => replace.call(es, ca, pe); +exports.escape = escape; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/index.js b/v-next/hardhat-vendored/dist/src/coverage/index.js new file mode 100644 index 00000000000..4e2633774c5 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/index.js @@ -0,0 +1,7 @@ +import libCoverage from "./lib-coverage/index.cjs"; +export { libCoverage }; +import libReport from "./lib-report/index.cjs"; +export { libReport }; +import reports from "./istanbul-reports/index.cjs"; +export { reports }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs new file mode 100644 index 00000000000..ddfb1ef1c6d --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs @@ -0,0 +1,23 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); +module.exports = { + create(name, cfg) { + cfg = cfg || {}; + let Cons; + try { + Cons = require(path.join(__dirname, "lib", name, "index.cjs")); + } + catch (e) { + if (e.code !== "MODULE_NOT_FOUND") { + throw e; + } + Cons = require(name); + } + return new Cons(cfg); + }, +}; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs new file mode 100644 index 00000000000..cda3f88caf1 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs @@ -0,0 +1,249 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const InsertionText = require("./insertion-text.cjs"); +const lt = "\u0001"; +const gt = "\u0002"; +const RE_LT = //g; +const RE_AMP = /&/g; +var RE_lt = /\u0001/g; +var RE_gt = /\u0002/g; +function title(str) { + return ' title="' + str + '" '; +} +function customEscape(text) { + text = String(text); + return text + .replace(RE_AMP, "&") + .replace(RE_LT, "<") + .replace(RE_GT, ">") + .replace(RE_lt, "<") + .replace(RE_gt, ">"); +} +function annotateLines(fileCoverage, structuredText) { + const lineStats = fileCoverage.getLineCoverage(); + if (!lineStats) { + return; + } + Object.entries(lineStats).forEach(([lineNumber, count]) => { + if (structuredText[lineNumber]) { + structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; + structuredText[lineNumber].hits = count; + } + }); +} +function annotateStatements(fileCoverage, structuredText) { + const statementStats = fileCoverage.s; + const statementMeta = fileCoverage.statementMap; + Object.entries(statementStats).forEach(([stName, count]) => { + const meta = statementMeta[stName]; + const type = count > 0 ? "yes" : "no"; + const startCol = meta.start.column; + let endCol = meta.end.column + 1; + const startLine = meta.start.line; + const endLine = meta.end.line; + const openSpan = lt + + 'span class="' + + (meta.skip ? "cstat-skip" : "cstat-no") + + '"' + + title("statement not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); + } + }); +} +function annotateFunctions(fileCoverage, structuredText) { + const fnStats = fileCoverage.f; + const fnMeta = fileCoverage.fnMap; + if (!fnStats) { + return; + } + Object.entries(fnStats).forEach(([fName, count]) => { + const meta = fnMeta[fName]; + const type = count > 0 ? "yes" : "no"; + // Some versions of the instrumenter in the wild populate 'func' + // but not 'decl': + const decl = meta.decl || meta.loc; + const startCol = decl.start.column; + let endCol = decl.end.column + 1; + const startLine = decl.start.line; + const endLine = decl.end.line; + const openSpan = lt + + 'span class="' + + (meta.skip ? "fstat-skip" : "fstat-no") + + '"' + + title("function not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); + } + }); +} +function annotateBranches(fileCoverage, structuredText) { + const branchStats = fileCoverage.b; + const branchMeta = fileCoverage.branchMap; + if (!branchStats) { + return; + } + Object.entries(branchStats).forEach(([branchName, branchArray]) => { + const sumCount = branchArray.reduce((p, n) => p + n, 0); + const metaArray = branchMeta[branchName].locations; + let i; + let count; + let meta; + let startCol; + let endCol; + let startLine; + let endLine; + let openSpan; + let closeSpan; + let text; + // only highlight if partial branches are missing or if there is a + // single uncovered branch. + if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { + // Need to recover the metaArray placeholder item to count an implicit else + if ( + // Check if the branch is a conditional if branch. + branchMeta[branchName].type === "if" && + // Check if the branch has an implicit else. + branchArray.length === 2 && + // Check if the implicit else branch is unaccounted for. + metaArray.length === 1 && + // Check if the implicit else branch is uncovered. + branchArray[1] === 0) { + metaArray[1] = { + start: {}, + end: {}, + }; + } + for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { + count = branchArray[i]; + meta = metaArray[i]; + startCol = meta.start.column; + endCol = meta.end.column + 1; + startLine = meta.start.line; + endLine = meta.end.line; + openSpan = + lt + + 'span class="branch-' + + i + + " " + + (meta.skip ? "cbranch-skip" : "cbranch-no") + + '"' + + title("branch not covered") + + gt; + closeSpan = lt + "/span" + gt; + // If the branch is an implicit else from an if statement, + // then the coverage report won't show a statistic. + // Therefore, the previous branch will be used to report that + // there is no coverage on that implicit branch. + if (count === 0 && + startLine === undefined && + branchMeta[branchName].type === "if") { + const prevMeta = metaArray[i - 1]; + startCol = prevMeta.start.column; + endCol = prevMeta.end.column + 1; + startLine = prevMeta.start.line; + endLine = prevMeta.end.line; + } + if (count === 0 && structuredText[startLine]) { + //skip branches taken + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + if (branchMeta[branchName].type === "if") { + // 'if' is a special case + // since the else branch might not be visible, being nonexistent + text.insertAt(startCol, lt + + 'span class="' + + (meta.skip ? "skip-if-branch" : "missing-if-branch") + + '"' + + title((i === 0 ? "if" : "else") + " path not taken") + + gt + + (i === 0 ? "I" : "E") + + lt + + "/span" + + gt, true, false); + } + else { + text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); + } + } + } + } + }); +} +function annotateSourceCode(fileCoverage, sourceStore) { + let codeArray; + let lineCoverageArray; + try { + const sourceText = sourceStore.getSource(fileCoverage.path); + const code = sourceText.split(/(?:\r?\n)|\r/); + let count = 0; + const structured = code.map((str) => { + count += 1; + return { + line: count, + covered: "neutral", + hits: 0, + text: new InsertionText(str, true), + }; + }); + structured.unshift({ + line: 0, + covered: null, + text: new InsertionText(""), + }); + annotateLines(fileCoverage, structured); + //note: order is important, since statements typically result in spanning the whole line and doing branches late + //causes mismatched tags + annotateBranches(fileCoverage, structured); + annotateFunctions(fileCoverage, structured); + annotateStatements(fileCoverage, structured); + structured.shift(); + codeArray = structured.map((item) => customEscape(item.text.toString()) || " "); + lineCoverageArray = structured.map((item) => ({ + covered: item.covered, + hits: item.hits > 0 ? item.hits + "x" : " ", + })); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: structured.length, + }; + } + catch (ex) { + codeArray = [ex.message]; + lineCoverageArray = [{ covered: "no", hits: 0 }]; + String(ex.stack || "") + .split(/\r?\n/) + .forEach((line) => { + codeArray.push(line); + lineCoverageArray.push({ covered: "no", hits: 0 }); + }); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: codeArray.length, + }; + } +} +module.exports = annotateSourceCode; +//# sourceMappingURL=annotator.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css new file mode 100644 index 00000000000..f418035b469 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js new file mode 100644 index 00000000000..eb527848ee7 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js @@ -0,0 +1,86 @@ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js new file mode 100644 index 00000000000..83122f78ace --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js @@ -0,0 +1,209 @@ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css new file mode 100644 index 00000000000..b317a7cda31 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js new file mode 100644 index 00000000000..ef51e038668 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs new file mode 100644 index 00000000000..a2390d3ad04 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs @@ -0,0 +1,339 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const path = require("node:path"); +const html = require("../../../html-escaper/index.cjs"); +const ReportBase = require("../../../lib-report/lib/report-base.cjs"); +const annotator = require("./annotator.cjs"); +function htmlHead(details) { + return ` + + Code coverage report for ${html.escape(details.entity)} + + + + + + + + `; +} +function headerTemplate(details) { + function metricsTemplate({ pct, covered, total }, kind) { + return ` +
+ ${pct}% + ${kind} + ${covered}/${total} +
+ `; + } + function skipTemplate(metrics) { + const statements = metrics.statements.skipped; + const branches = metrics.branches.skipped; + const functions = metrics.functions.skipped; + const countLabel = (c, label, plural) => c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; + const skips = [].concat(countLabel(statements, "statement", "s"), countLabel(functions, "function", "s"), countLabel(branches, "branch", "es")); + if (skips.length === 0) { + return ""; + } + return ` +
+ ${skips.join(", ")} + Ignored      +
+ `; + } + return ` + + +${htmlHead(details)} + +
+
+

${details.pathHtml}

+
+ ${metricsTemplate(details.metrics.statements, "Statements")} + ${metricsTemplate(details.metrics.branches, "Branches")} + ${metricsTemplate(details.metrics.functions, "Functions")} + ${metricsTemplate(details.metrics.lines, "Lines")} + ${skipTemplate(details.metrics)} +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+ `; +} +function footerTemplate(details) { + return ` +
+
+ + + + + + + + `; +} +function detailTemplate(data) { + const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); + const lineLink = (num) => `${num}`; + const lineCount = (line) => `${line.hits}`; + /* This is rendered in a `
`, need control of all whitespace. */
+    return [
+        "",
+        `${lineNumbers.map(lineLink).join("\n")}`,
+        `${data.lineCoverage
+            .map(lineCount)
+            .join("\n")}`,
+        `
${data.annotatedCode.join("\n")}
`, + "", + ].join(""); +} +const summaryTableHeader = [ + '
', + '', + "", + "", + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + "", + "", + "", +].join("\n"); +function summaryLineTemplate(details) { + const { reportClasses, metrics, file, output } = details; + const percentGraph = (pct) => { + if (!isFinite(pct)) { + return ""; + } + const cls = ["cover-fill"]; + if (pct === 100) { + cls.push("cover-full"); + } + pct = Math.floor(pct); + return [ + `
`, + `
`, + ].join(""); + }; + const summaryType = (type, showGraph = false) => { + const info = metrics[type]; + const reportClass = reportClasses[type]; + const result = [ + ``, + ``, + ]; + if (showGraph) { + result.unshift(``); + } + return result; + }; + return [] + .concat("", ``, summaryType("statements", true), summaryType("branches"), summaryType("functions"), summaryType("lines"), "\n") + .join("\n\t"); +} +const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, `
${percentGraph(info.pct)}
`, `
${html.escape(file)}
", "
"].join("\n"); +const emptyClasses = { + statements: "empty", + lines: "empty", + functions: "empty", + branches: "empty", +}; +const standardLinkMapper = { + getPath(node) { + if (typeof node === "string") { + return node; + } + let filePath = node.getQualifiedName(); + if (node.isSummary()) { + if (filePath !== "") { + filePath += "/index.html"; + } + else { + filePath = "index.html"; + } + } + else { + filePath += ".html"; + } + return filePath; + }, + relativePath(source, target) { + const targetPath = this.getPath(target); + const sourcePath = path.dirname(this.getPath(source)); + return path.posix.relative(sourcePath, targetPath); + }, + assetPath(node, name) { + return this.relativePath(this.getPath(node), name); + }, +}; +function fixPct(metrics) { + Object.keys(emptyClasses).forEach((key) => { + metrics[key].pct = 0; + }); + return metrics; +} +class HtmlReport extends ReportBase { + constructor(opts) { + super(); + this.verbose = opts.verbose; + this.linkMapper = opts.linkMapper || standardLinkMapper; + this.subdir = opts.subdir || ""; + this.date = new Date().toISOString(); + this.skipEmpty = opts.skipEmpty; + } + getBreadcrumbHtml(node) { + let parent = node.getParent(); + const nodePath = []; + while (parent) { + nodePath.push(parent); + parent = parent.getParent(); + } + const linkPath = nodePath.map((ancestor) => { + const target = this.linkMapper.relativePath(node, ancestor); + const name = ancestor.getRelativeName() || "All files"; + return '' + name + ""; + }); + linkPath.reverse(); + return linkPath.length > 0 + ? linkPath.join(" / ") + " " + node.getRelativeName() + : "All files"; + } + fillTemplate(node, templateData, context) { + const linkMapper = this.linkMapper; + const summary = node.getCoverageSummary(); + templateData.entity = node.getQualifiedName() || "All files"; + templateData.metrics = summary; + templateData.reportClass = context.classForPercent("statements", summary.statements.pct); + templateData.pathHtml = this.getBreadcrumbHtml(node); + templateData.base = { + css: linkMapper.assetPath(node, "base.css"), + }; + templateData.sorter = { + js: linkMapper.assetPath(node, "sorter.js"), + image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), + }; + templateData.blockNavigation = { + js: linkMapper.assetPath(node, "block-navigation.js"), + }; + templateData.prettify = { + js: linkMapper.assetPath(node, "prettify.js"), + css: linkMapper.assetPath(node, "prettify.css"), + }; + templateData.favicon = linkMapper.assetPath(node, "favicon.png"); + } + getTemplateData() { + return { datetime: this.date }; + } + getWriter(context) { + if (!this.subdir) { + return context.writer; + } + return context.writer.writerForDir(this.subdir); + } + onStart(root, context) { + const assetHeaders = { + ".js": "/* eslint-disable */\n", + }; + [".", "vendor"].forEach((subdir) => { + const writer = this.getWriter(context); + const srcDir = path.resolve(__dirname, "assets", subdir); + fs.readdirSync(srcDir).forEach((f) => { + const resolvedSource = path.resolve(srcDir, f); + const resolvedDestination = "."; + const stat = fs.statSync(resolvedSource); + let dest; + if (stat.isFile()) { + dest = resolvedDestination + "/" + f; + if (this.verbose) { + console.log("Write asset: " + dest); + } + writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); + } + }); + }); + } + onSummary(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + const children = node.getChildren(); + const skipEmpty = this.skipEmpty; + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write(summaryTableHeader); + children.forEach((child) => { + const metrics = child.getCoverageSummary(); + const isEmpty = metrics.isEmpty(); + if (skipEmpty && isEmpty) { + return; + } + const reportClasses = isEmpty + ? emptyClasses + : { + statements: context.classForPercent("statements", metrics.statements.pct), + lines: context.classForPercent("lines", metrics.lines.pct), + functions: context.classForPercent("functions", metrics.functions.pct), + branches: context.classForPercent("branches", metrics.branches.pct), + }; + const data = { + metrics: isEmpty ? fixPct(metrics) : metrics, + reportClasses, + file: child.getRelativeName(), + output: linkMapper.relativePath(node, child), + }; + cw.write(summaryLineTemplate(data) + "\n"); + }); + cw.write(summaryTableFooter); + cw.write(footerTemplate(templateData)); + cw.close(); + } + onDetail(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write('
\n');
+        cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
+        cw.write("
\n"); + cw.write(footerTemplate(templateData)); + cw.close(); + } +} +module.exports = HtmlReport; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs new file mode 100644 index 00000000000..6cc92030ae8 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs @@ -0,0 +1,103 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +function InsertionText(text, consumeBlanks) { + this.text = text; + this.origLength = text.length; + this.offsets = []; + this.consumeBlanks = consumeBlanks; + this.startPos = this.findFirstNonBlank(); + this.endPos = this.findLastNonBlank(); +} +const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; +InsertionText.prototype = { + findFirstNonBlank() { + let pos = -1; + const text = this.text; + const len = text.length; + let i; + for (i = 0; i < len; i += 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + findLastNonBlank() { + const text = this.text; + const len = text.length; + let pos = text.length + 1; + let i; + for (i = len - 1; i >= 0; i -= 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + originalLength() { + return this.origLength; + }, + insertAt(col, str, insertBefore, consumeBlanks) { + consumeBlanks = + typeof consumeBlanks === 'undefined' + ? this.consumeBlanks + : consumeBlanks; + col = col > this.originalLength() ? this.originalLength() : col; + col = col < 0 ? 0 : col; + if (consumeBlanks) { + if (col <= this.startPos) { + col = 0; + } + if (col > this.endPos) { + col = this.origLength; + } + } + const len = str.length; + const offset = this.findOffset(col, len, insertBefore); + const realPos = col + offset; + const text = this.text; + this.text = text.substring(0, realPos) + str + text.substring(realPos); + return this; + }, + findOffset(pos, len, insertBefore) { + const offsets = this.offsets; + let offsetObj; + let cumulativeOffset = 0; + let i; + for (i = 0; i < offsets.length; i += 1) { + offsetObj = offsets[i]; + if (offsetObj.pos < pos || + (offsetObj.pos === pos && !insertBefore)) { + cumulativeOffset += offsetObj.len; + } + if (offsetObj.pos >= pos) { + break; + } + } + if (offsetObj && offsetObj.pos === pos) { + offsetObj.len += len; + } + else { + offsets.splice(i, 0, { pos, len }); + } + return cumulativeOffset; + }, + wrap(startPos, startText, endPos, endText, consumeBlanks) { + this.insertAt(startPos, startText, true, consumeBlanks); + this.insertAt(endPos, endText, false, consumeBlanks); + return this; + }, + wrapLine(startText, endText) { + this.wrap(0, startText, this.originalLength(), endText); + }, + toString() { + return this.text; + } +}; +module.exports = InsertionText; +//# sourceMappingURL=insertion-text.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs new file mode 100644 index 00000000000..86ee436a301 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs @@ -0,0 +1,62 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +/** + * istanbul-lib-coverage exports an API that allows you to create and manipulate + * file coverage, coverage maps (a set of file coverage objects) and summary + * coverage objects. File coverage for the same file can be merged as can + * entire coverage maps. + * + * @module Exports + */ +const { FileCoverage } = require("./lib/file-coverage.cjs"); +const { CoverageMap } = require("./lib/coverage-map.cjs"); +const { CoverageSummary } = require("./lib/coverage-summary.cjs"); +module.exports = { + /** + * creates a coverage summary object + * @param {Object} obj an argument with the same semantics + * as the one passed to the `CoverageSummary` constructor + * @returns {CoverageSummary} + */ + createCoverageSummary(obj) { + if (obj && obj instanceof CoverageSummary) { + return obj; + } + return new CoverageSummary(obj); + }, + /** + * creates a CoverageMap object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the CoverageMap constructor. + * @returns {CoverageMap} + */ + createCoverageMap(obj) { + if (obj && obj instanceof CoverageMap) { + return obj; + } + return new CoverageMap(obj); + }, + /** + * creates a FileCoverage object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the FileCoverage constructor. + * @returns {FileCoverage} + */ + createFileCoverage(obj) { + if (obj && obj instanceof FileCoverage) { + return obj; + } + return new FileCoverage(obj); + }, +}; +/** classes exported for reuse */ +module.exports.classes = { + /** + * the file coverage constructor + */ + FileCoverage, +}; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs new file mode 100644 index 00000000000..bad5422758a --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs @@ -0,0 +1,115 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const { FileCoverage } = require("./file-coverage.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); +function maybeConstruct(obj, klass) { + if (obj instanceof klass) { + return obj; + } + return new klass(obj); +} +function loadMap(source) { + const data = Object.create(null); + if (!source) { + return data; + } + Object.entries(source).forEach(([k, cov]) => { + data[k] = maybeConstruct(cov, FileCoverage); + }); + return data; +} +/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ +class CoverageMap { + /** + * @constructor + * @param {Object} [obj=undefined] obj A coverage map from which to initialize this + * map's contents. This can be the raw global coverage object. + */ + constructor(obj) { + if (obj instanceof CoverageMap) { + this.data = obj.data; + } + else { + this.data = loadMap(obj); + } + } + /** + * merges a second coverage map into this one + * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged + * correctly for the same files and additional file coverage keys are created + * as needed. + */ + merge(obj) { + const other = maybeConstruct(obj, CoverageMap); + Object.values(other.data).forEach((fc) => { + this.addFileCoverage(fc); + }); + } + /** + * filter the coveragemap based on the callback provided + * @param {Function (filename)} callback - Returns true if the path + * should be included in the coveragemap. False if it should be + * removed. + */ + filter(callback) { + Object.keys(this.data).forEach((k) => { + if (!callback(k)) { + delete this.data[k]; + } + }); + } + /** + * returns a JSON-serializable POJO for this coverage map + * @returns {Object} + */ + toJSON() { + return this.data; + } + /** + * returns an array for file paths for which this map has coverage + * @returns {Array{string}} - array of files + */ + files() { + return Object.keys(this.data); + } + /** + * returns the file coverage for the specified file. + * @param {String} file + * @returns {FileCoverage} + */ + fileCoverageFor(file) { + const fc = this.data[file]; + if (!fc) { + throw new Error(`No file coverage available for: ${file}`); + } + return fc; + } + addFileCoverage(fc) { + const cov = new FileCoverage(fc); + const { path } = cov; + if (this.data[path]) { + this.data[path].merge(cov); + } + else { + this.data[path] = cov; + } + } + /** + * returns the coverage summary for all the file coverage objects in this map. + * @returns {CoverageSummary} + */ + getCoverageSummary() { + const ret = new CoverageSummary(); + Object.values(this.data).forEach((fc) => { + ret.merge(fc.toSummary()); + }); + return ret; + } +} +module.exports = { + CoverageMap, +}; +//# sourceMappingURL=coverage-map.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs new file mode 100644 index 00000000000..8762aca9296 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs @@ -0,0 +1,101 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +function blankSummary() { + const empty = () => ({ + total: 0, + covered: 0, + skipped: 0, + pct: "Unknown", + }); + return { + lines: empty(), + statements: empty(), + functions: empty(), + branches: empty(), + branchesTrue: empty(), + }; +} +// asserts that a data object "looks like" a summary coverage object +function assertValidSummary(obj) { + const valid = obj && obj.lines && obj.statements && obj.functions && obj.branches; + if (!valid) { + throw new Error("Invalid summary coverage object, missing keys, found:" + + Object.keys(obj).join(",")); + } +} +/** + * CoverageSummary provides a summary of code coverage . It exposes 4 properties, + * `lines`, `statements`, `branches`, and `functions`. Each of these properties + * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. + * `pct` is a percentage number (0-100). + */ +class CoverageSummary { + /** + * @constructor + * @param {Object|CoverageSummary} [obj=undefined] an optional data object or + * another coverage summary to initialize this object with. + */ + constructor(obj) { + if (!obj) { + this.data = blankSummary(); + } + else if (obj instanceof CoverageSummary) { + this.data = obj.data; + } + else { + this.data = obj; + } + assertValidSummary(this.data); + } + /** + * merges a second summary coverage object into this one + * @param {CoverageSummary} obj - another coverage summary object + */ + merge(obj) { + const keys = [ + "lines", + "statements", + "branches", + "functions", + "branchesTrue", + ]; + keys.forEach((key) => { + if (obj[key]) { + this[key].total += obj[key].total; + this[key].covered += obj[key].covered; + this[key].skipped += obj[key].skipped; + this[key].pct = percent(this[key].covered, this[key].total); + } + }); + return this; + } + /** + * returns a POJO that is JSON serializable. May be used to get the raw + * summary object. + */ + toJSON() { + return this.data; + } + /** + * return true if summary has no lines of code + */ + isEmpty() { + return this.lines.total === 0; + } +} +dataProperties(CoverageSummary, [ + "lines", + "statements", + "functions", + "branches", + "branchesTrue", +]); +module.exports = { + CoverageSummary, +}; +//# sourceMappingURL=coverage-summary.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs new file mode 100644 index 00000000000..e8a22f8e598 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs @@ -0,0 +1,12 @@ +"use strict"; +module.exports = function dataProperties(klass, properties) { + properties.forEach((p) => { + Object.defineProperty(klass.prototype, p, { + enumerable: true, + get() { + return this.data[p]; + }, + }); + }); +}; +//# sourceMappingURL=data-properties.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs new file mode 100644 index 00000000000..72900a820ba --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs @@ -0,0 +1,387 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); +// returns a data object that represents empty coverage +function emptyCoverage(filePath, reportLogic) { + const cov = { + path: filePath, + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {}, + }; + if (reportLogic) + cov.bT = {}; + return cov; +} +// asserts that a data object "looks like" a coverage object +function assertValidObject(obj) { + const valid = obj && + obj.path && + obj.statementMap && + obj.fnMap && + obj.branchMap && + obj.s && + obj.f && + obj.b; + if (!valid) { + throw new Error("Invalid file coverage object, missing keys, found:" + + Object.keys(obj).join(",")); + } +} +const keyFromLoc = ({ start, end }) => `${start.line}|${start.column}|${end.line}|${end.column}`; +const isObj = (o) => !!o && typeof o === "object"; +const isLineCol = (o) => isObj(o) && typeof o.line === "number" && typeof o.column === "number"; +const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); +const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); +// When merging, we can have a case where two ranges cover +// the same block of code with `hits=1`, and each carve out a +// different range with `hits=0` to indicate it's uncovered. +// Find the nearest container so that we can properly indicate +// that both sections are hit. +// Returns null if no containing item is found. +const findNearestContainer = (item, map) => { + const itemLoc = getLoc(item); + if (!itemLoc) + return null; + // the B item is not an identified range in the A set, BUT + // it may be contained by an identified A range. If so, then + // any hit of that containing A range counts as a hit of this + // B range as well. We have to find the *narrowest* containing + // range to be accurate, since ranges can be hit and un-hit + // in a nested fashion. + let nearestContainingItem = null; + let containerDistance = null; + let containerKey = null; + for (const [i, mapItem] of Object.entries(map)) { + const mapLoc = getLoc(mapItem); + if (!mapLoc) + continue; + // contained if all of line distances are > 0 + // or line distance is 0 and col dist is >= 0 + const distance = [ + itemLoc.start.line - mapLoc.start.line, + itemLoc.start.column - mapLoc.start.column, + mapLoc.end.line - itemLoc.end.line, + mapLoc.end.column - itemLoc.end.column, + ]; + if (distance[0] < 0 || + distance[2] < 0 || + (distance[0] === 0 && distance[1] < 0) || + (distance[2] === 0 && distance[3] < 0)) { + continue; + } + if (nearestContainingItem === null) { + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + continue; + } + // closer line more relevant than closer column + const closerBefore = distance[0] < containerDistance[0] || + (distance[0] === 0 && distance[1] < containerDistance[1]); + const closerAfter = distance[2] < containerDistance[2] || + (distance[2] === 0 && distance[3] < containerDistance[3]); + if (closerBefore || closerAfter) { + // closer + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + } + } + return containerKey; +}; +// either add two numbers, or all matching entries in a number[] +const addHits = (aHits, bHits) => { + if (typeof aHits === "number" && typeof bHits === "number") { + return aHits + bHits; + } + else if (Array.isArray(aHits) && Array.isArray(bHits)) { + return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); + } + return null; +}; +const addNearestContainerHits = (item, itemHits, map, mapHits) => { + const container = findNearestContainer(item, map); + if (container) { + return addHits(itemHits, mapHits[container]); + } + else { + return itemHits; + } +}; +const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { + const aItems = {}; + for (const [key, itemHits] of Object.entries(aHits)) { + const item = aMap[key]; + aItems[itemKey(item)] = [itemHits, item]; + } + const bItems = {}; + for (const [key, itemHits] of Object.entries(bHits)) { + const item = bMap[key]; + bItems[itemKey(item)] = [itemHits, item]; + } + const mergedItems = {}; + for (const [key, aValue] of Object.entries(aItems)) { + let aItemHits = aValue[0]; + const aItem = aValue[1]; + const bValue = bItems[key]; + if (!bValue) { + // not an identified range in b, but might be contained by one + aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); + } + else { + // is an identified range in b, so add the hits together + aItemHits = addHits(aItemHits, bValue[0]); + } + mergedItems[key] = [aItemHits, aItem]; + } + // now find the items in b that are not in a. already added matches. + for (const [key, bValue] of Object.entries(bItems)) { + let bItemHits = bValue[0]; + const bItem = bValue[1]; + if (mergedItems[key]) + continue; + // not an identified range in b, but might be contained by one + bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); + mergedItems[key] = [bItemHits, bItem]; + } + const hits = {}; + const map = {}; + Object.values(mergedItems).forEach(([itemHits, item], i) => { + hits[i] = itemHits; + map[i] = item; + }); + return [hits, map]; +}; +/** + * provides a read-only view of coverage for a single file. + * The deep structure of this object is documented elsewhere. It has the following + * properties: + * + * * `path` - the file path for which coverage is being tracked + * * `statementMap` - map of statement locations keyed by statement index + * * `fnMap` - map of function metadata keyed by function index + * * `branchMap` - map of branch metadata keyed by branch index + * * `s` - hit counts for statements + * * `f` - hit count for functions + * * `b` - hit count for branches + */ +class FileCoverage { + /** + * @constructor + * @param {Object|FileCoverage|String} pathOrObj is a string that initializes + * and empty coverage object with the specified file path or a data object that + * has all the required properties for a file coverage object. + */ + constructor(pathOrObj, reportLogic = false) { + if (!pathOrObj) { + throw new Error("Coverage must be initialized with a path or an object"); + } + if (typeof pathOrObj === "string") { + this.data = emptyCoverage(pathOrObj, reportLogic); + } + else if (pathOrObj instanceof FileCoverage) { + this.data = pathOrObj.data; + } + else if (typeof pathOrObj === "object") { + this.data = pathOrObj; + } + else { + throw new Error("Invalid argument to coverage constructor"); + } + assertValidObject(this.data); + } + /** + * returns computed line coverage from statement coverage. + * This is a map of hits keyed by line number in the source. + */ + getLineCoverage() { + const statementMap = this.data.statementMap; + const statements = this.data.s; + const lineMap = Object.create(null); + Object.entries(statements).forEach(([st, count]) => { + /* istanbul ignore if: is this even possible? */ + if (!statementMap[st]) { + return; + } + const { line } = statementMap[st].start; + const prevVal = lineMap[line]; + if (prevVal === undefined || prevVal < count) { + lineMap[line] = count; + } + }); + return lineMap; + } + /** + * returns an array of uncovered line numbers. + * @returns {Array} an array of line numbers for which no hits have been + * collected. + */ + getUncoveredLines() { + const lc = this.getLineCoverage(); + const ret = []; + Object.entries(lc).forEach(([l, hits]) => { + if (hits === 0) { + ret.push(l); + } + }); + return ret; + } + /** + * returns a map of branch coverage by source line number. + * @returns {Object} an object keyed by line number. Each object + * has a `covered`, `total` and `coverage` (percentage) property. + */ + getBranchCoverageByLine() { + const branchMap = this.branchMap; + const branches = this.b; + const ret = {}; + Object.entries(branchMap).forEach(([k, map]) => { + const line = map.line || map.loc.start.line; + const branchData = branches[k]; + ret[line] = ret[line] || []; + ret[line].push(...branchData); + }); + Object.entries(ret).forEach(([k, dataArray]) => { + const covered = dataArray.filter((item) => item > 0); + const coverage = (covered.length / dataArray.length) * 100; + ret[k] = { + covered: covered.length, + total: dataArray.length, + coverage, + }; + }); + return ret; + } + /** + * return a JSON-serializable POJO for this file coverage object + */ + toJSON() { + return this.data; + } + /** + * merges a second coverage object into this one, updating hit counts + * @param {FileCoverage} other - the coverage object to be merged into this one. + * Note that the other object should have the same structure as this one (same file). + */ + merge(other) { + if (other.all === true) { + return; + } + if (this.all === true) { + this.data = other.data; + return; + } + let [hits, map] = mergeProp(this.s, this.statementMap, other.s, other.statementMap); + this.data.s = hits; + this.data.statementMap = map; + const keyFromLocProp = (x) => keyFromLoc(x.loc); + const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); + [hits, map] = mergeProp(this.f, this.fnMap, other.f, other.fnMap, keyFromLocProp); + this.data.f = hits; + this.data.fnMap = map; + [hits, map] = mergeProp(this.b, this.branchMap, other.b, other.branchMap, keyFromLocationsProp); + this.data.b = hits; + this.data.branchMap = map; + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT && other.bT) { + [hits, map] = mergeProp(this.bT, this.branchMap, other.bT, other.branchMap, keyFromLocationsProp); + this.data.bT = hits; + } + } + computeSimpleTotals(property) { + let stats = this[property]; + if (typeof stats === "function") { + stats = stats.call(this); + } + const ret = { + total: Object.keys(stats).length, + covered: Object.values(stats).filter((v) => !!v).length, + skipped: 0, + }; + ret.pct = percent(ret.covered, ret.total); + return ret; + } + computeBranchTotals(property) { + const stats = this[property]; + const ret = { total: 0, covered: 0, skipped: 0 }; + Object.values(stats).forEach((branches) => { + ret.covered += branches.filter((hits) => hits > 0).length; + ret.total += branches.length; + }); + ret.pct = percent(ret.covered, ret.total); + return ret; + } + /** + * resets hit counts for all statements, functions and branches + * in this coverage object resulting in zero coverage. + */ + resetHits() { + const statements = this.s; + const functions = this.f; + const branches = this.b; + const branchesTrue = this.bT; + Object.keys(statements).forEach((s) => { + statements[s] = 0; + }); + Object.keys(functions).forEach((f) => { + functions[f] = 0; + }); + Object.keys(branches).forEach((b) => { + branches[b].fill(0); + }); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (branchesTrue) { + Object.keys(branchesTrue).forEach((bT) => { + branchesTrue[bT].fill(0); + }); + } + } + /** + * returns a CoverageSummary for this file coverage object + * @returns {CoverageSummary} + */ + toSummary() { + const ret = {}; + ret.lines = this.computeSimpleTotals("getLineCoverage"); + ret.functions = this.computeSimpleTotals("f", "fnMap"); + ret.statements = this.computeSimpleTotals("s", "statementMap"); + ret.branches = this.computeBranchTotals("b"); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT) { + ret.branchesTrue = this.computeBranchTotals("bT"); + } + return new CoverageSummary(ret); + } +} +// expose coverage data attributes +dataProperties(FileCoverage, [ + "path", + "statementMap", + "fnMap", + "branchMap", + "s", + "f", + "b", + "bT", + "all", +]); +module.exports = { + FileCoverage, + // exported for testing + findNearestContainer, + addHits, + addNearestContainerHits, +}; +//# sourceMappingURL=file-coverage.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs new file mode 100644 index 00000000000..7e0b1ee99e0 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs @@ -0,0 +1,16 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +module.exports = function percent(covered, total) { + let tmp; + if (total > 0) { + tmp = (1000 * 100 * covered) / total; + return Math.floor(tmp / 10) / 100; + } + else { + return 100.0; + } +}; +//# sourceMappingURL=percent.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs new file mode 100644 index 00000000000..9ccf034704a --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=ciao.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs new file mode 100644 index 00000000000..658f3228b3d --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs @@ -0,0 +1,36 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +/** + * @module Exports + */ +const Context = require("./lib/context.cjs"); +const watermarks = require("./lib/watermarks.cjs"); +const ReportBase = require("./lib/report-base.cjs"); +module.exports = { + /** + * returns a reporting context for the supplied options + * @param {Object} [opts=null] opts + * @returns {Context} + */ + createContext(opts) { + return new Context(opts); + }, + /** + * returns the default watermarks that would be used when not + * overridden + * @returns {Object} an object with `statements`, `functions`, `branches`, + * and `line` keys. Each value is a 2 element array that has the low and + * high watermark as percentages. + */ + getDefaultWatermarks() { + return watermarks.getDefault(); + }, + /** + * Base class for all reports + */ + ReportBase, +}; +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs new file mode 100644 index 00000000000..5eb918c4098 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs @@ -0,0 +1,119 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const FileWriter = require("./file-writer.cjs"); +const XMLWriter = require("./xml-writer.cjs"); +const tree = require("./tree.cjs"); +const watermarks = require("./watermarks.cjs"); +const SummarizerFactory = require("./summarizer-factory.cjs"); +function defaultSourceLookup(path) { + try { + return fs.readFileSync(path, "utf8"); + } + catch (ex) { + throw new Error(`Unable to lookup source: ${path} (${ex.message})`); + } +} +function normalizeWatermarks(specified = {}) { + Object.entries(watermarks.getDefault()).forEach(([k, value]) => { + const specValue = specified[k]; + if (!Array.isArray(specValue) || specValue.length !== 2) { + specified[k] = value; + } + }); + return specified; +} +/** + * A reporting context that is passed to report implementations + * @param {Object} [opts=null] opts options + * @param {String} [opts.dir='coverage'] opts.dir the reporting directory + * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for + * statements, lines, branches and functions + * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a + * function that returns source code given a file path. Defaults to + * filesystem lookups based on path. + * @constructor + */ +class Context { + constructor(opts) { + this.dir = opts.dir || "coverage"; + this.watermarks = normalizeWatermarks(opts.watermarks); + this.sourceFinder = opts.sourceFinder || defaultSourceLookup; + this._summarizerFactory = new SummarizerFactory(opts.coverageMap, opts.defaultSummarizer); + this.data = {}; + } + /** + * returns a FileWriter implementation for reporting use. Also available + * as the `writer` property on the context. + * @returns {Writer} + */ + getWriter() { + return this.writer; + } + /** + * returns the source code for the specified file path or throws if + * the source could not be found. + * @param {String} filePath the file path as found in a file coverage object + * @returns {String} the source code + */ + getSource(filePath) { + return this.sourceFinder(filePath); + } + /** + * returns the coverage class given a coverage + * types and a percentage value. + * @param {String} type - the coverage type, one of `statements`, `functions`, + * `branches`, or `lines` + * @param {Number} value - the percentage value + * @returns {String} one of `high`, `medium` or `low` + */ + classForPercent(type, value) { + const watermarks = this.watermarks[type]; + if (!watermarks) { + return "unknown"; + } + if (value < watermarks[0]) { + return "low"; + } + if (value >= watermarks[1]) { + return "high"; + } + return "medium"; + } + /** + * returns an XML writer for the supplied content writer + * @param {ContentWriter} contentWriter the content writer to which the returned XML writer + * writes data + * @returns {XMLWriter} + */ + getXMLWriter(contentWriter) { + return new XMLWriter(contentWriter); + } + /** + * returns a full visitor given a partial one. + * @param {Object} partialVisitor a partial visitor only having the functions of + * interest to the caller. These functions are called with a scope that is the + * supplied object. + * @returns {Visitor} + */ + getVisitor(partialVisitor) { + return new tree.Visitor(partialVisitor); + } + getTree(name = "defaultSummarizer") { + return this._summarizerFactory[name]; + } +} +Object.defineProperty(Context.prototype, "writer", { + enumerable: true, + get() { + if (!this.data.writer) { + this.data.writer = new FileWriter(this.dir); + } + return this.data.writer; + }, +}); +module.exports = Context; +//# sourceMappingURL=context.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs new file mode 100644 index 00000000000..a79f541a0b6 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs @@ -0,0 +1,165 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); +const fs = require("node:fs"); +const { mkdir } = require("node:fs/promises"); +/** + * Base class for writing content + * @class ContentWriter + * @constructor + */ +class ContentWriter { + /** + * returns the colorized version of a string. Typically, + * content writers that write to files will return the + * same string and ones writing to a tty will wrap it in + * appropriate escape sequences. + * @param {String} str the string to colorize + * @param {String} clazz one of `high`, `medium` or `low` + * @returns {String} the colorized form of the string + */ + colorize(str /*, clazz*/) { + return str; + } + /** + * writes a string appended with a newline to the destination + * @param {String} str the string to write + */ + println(str) { + this.write(`${str}\n`); + } + /** + * closes this content writer. Should be called after all writes are complete. + */ + close() { } +} +/** + * a content writer that writes to a file + * @param {Number} fd - the file descriptor + * @extends ContentWriter + * @constructor + */ +class FileContentWriter extends ContentWriter { + constructor(fd) { + super(); + this.fd = fd; + } + write(str) { + fs.writeSync(this.fd, str); + } + close() { + fs.closeSync(this.fd); + } +} +// allow stdout to be captured for tests. +let capture = false; +let output = ""; +/** + * a content writer that writes to the console + * @extends ContentWriter + * @constructor + */ +class ConsoleWriter extends ContentWriter { + write(str) { + if (capture) { + output += str; + } + else { + process.stdout.write(str); + } + } + colorize(str, clazz) { + const colors = { + low: "31;1", + medium: "33;1", + high: "32;1", + }; + return str; + } +} +/** + * utility for writing files under a specific directory + * @class FileWriter + * @param {String} baseDir the base directory under which files should be written + * @constructor + */ +class FileWriter { + constructor(baseDir) { + if (!baseDir) { + throw new Error("baseDir must be specified"); + } + this.baseDir = baseDir; + } + /** + * static helpers for capturing stdout report output; + * super useful for tests! + */ + static startCapture() { + capture = true; + } + static stopCapture() { + capture = false; + } + static getOutput() { + return output; + } + static resetOutput() { + output = ""; + } + /** + * returns a FileWriter that is rooted at the supplied subdirectory + * @param {String} subdir the subdirectory under which to root the + * returned FileWriter + * @returns {FileWriter} + */ + writerForDir(subdir) { + if (path.isAbsolute(subdir)) { + throw new Error(`Cannot create subdir writer for absolute path: ${subdir}`); + } + return new FileWriter(`${this.baseDir}/${subdir}`); + } + /** + * copies a file from a source directory to a destination name + * @param {String} source path to source file + * @param {String} dest relative path to destination file + * @param {String} [header=undefined] optional text to prepend to destination + * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) + */ + copyFile(source, dest, header) { + if (path.isAbsolute(dest)) { + throw new Error(`Cannot write to absolute path: ${dest}`); + } + dest = path.resolve(this.baseDir, dest); + mkdir(path.dirname(dest), { recursive: true }); + let contents; + if (header) { + contents = header + fs.readFileSync(source, "utf8"); + } + else { + contents = fs.readFileSync(source); + } + fs.writeFileSync(dest, contents); + } + /** + * returns a content writer for writing content to the supplied file. + * @param {String|null} file the relative path to the file or the special + * values `"-"` or `null` for writing to the console + * @returns {ContentWriter} + */ + writeFile(file) { + if (file === null || file === "-") { + return new ConsoleWriter(); + } + if (path.isAbsolute(file)) { + throw new Error(`Cannot write to absolute path: ${file}`); + } + file = path.resolve(this.baseDir, file); + mkdir(path.dirname(file), { recursive: true }); + return new FileContentWriter(fs.openSync(file, "w")); + } +} +module.exports = FileWriter; +//# sourceMappingURL=file-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs new file mode 100644 index 00000000000..3bf30e53640 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs @@ -0,0 +1,148 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const path = require("node:path"); +let parsePath = path.parse; +let SEP = path.sep; +const origParser = parsePath; +const origSep = SEP; +function makeRelativeNormalizedPath(str, sep) { + const parsed = parsePath(str); + let root = parsed.root; + let dir; + let file = parsed.base; + let quoted; + let pos; + // handle a weird windows case separately + if (sep === "\\") { + pos = root.indexOf(":\\"); + if (pos >= 0) { + root = root.substring(0, pos + 2); + } + } + dir = parsed.dir.substring(root.length); + if (str === "") { + return []; + } + if (sep !== "/") { + quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); + dir = dir.replace(quoted, "/"); + file = file.replace(quoted, "/"); // excessively paranoid? + } + if (dir !== "") { + dir = `${dir}/${file}`; + } + else { + dir = file; + } + if (dir.substring(0, 1) === "/") { + dir = dir.substring(1); + } + dir = dir.split(/\/+/); + return dir; +} +class Path { + constructor(strOrArray) { + if (Array.isArray(strOrArray)) { + this.v = strOrArray; + } + else if (typeof strOrArray === "string") { + this.v = makeRelativeNormalizedPath(strOrArray, SEP); + } + else { + throw new Error(`Invalid Path argument must be string or array:${strOrArray}`); + } + } + toString() { + return this.v.join("/"); + } + hasParent() { + return this.v.length > 0; + } + parent() { + if (!this.hasParent()) { + throw new Error("Unable to get parent for 0 elem path"); + } + const p = this.v.slice(); + p.pop(); + return new Path(p); + } + elements() { + return this.v.slice(); + } + name() { + return this.v.slice(-1)[0]; + } + contains(other) { + let i; + if (other.length > this.length) { + return false; + } + for (i = 0; i < other.length; i += 1) { + if (this.v[i] !== other.v[i]) { + return false; + } + } + return true; + } + ancestorOf(other) { + return other.contains(this) && other.length !== this.length; + } + descendantOf(other) { + return this.contains(other) && other.length !== this.length; + } + commonPrefixPath(other) { + const len = this.length > other.length ? other.length : this.length; + let i; + const ret = []; + for (i = 0; i < len; i += 1) { + if (this.v[i] === other.v[i]) { + ret.push(this.v[i]); + } + else { + break; + } + } + return new Path(ret); + } + static compare(a, b) { + const al = a.length; + const bl = b.length; + if (al < bl) { + return -1; + } + if (al > bl) { + return 1; + } + const astr = a.toString(); + const bstr = b.toString(); + return astr < bstr ? -1 : astr > bstr ? 1 : 0; + } +} +["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { + Object.defineProperty(Path.prototype, fn, { + value(...args) { + return this.v[fn](...args); + }, + }); +}); +Object.defineProperty(Path.prototype, "length", { + enumerable: true, + get() { + return this.v.length; + }, +}); +module.exports = Path; +Path.tester = { + setParserAndSep(p, sep) { + parsePath = p; + SEP = sep; + }, + reset() { + parsePath = origParser; + SEP = origSep; + }, +}; +//# sourceMappingURL=path.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs new file mode 100644 index 00000000000..70ba85a2c68 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs @@ -0,0 +1,13 @@ +"use strict"; +// TODO: switch to class private field when targeting node.js 12 +const _summarizer = Symbol("ReportBase.#summarizer"); +class ReportBase { + constructor(opts = {}) { + this[_summarizer] = opts.summarizer; + } + execute(context) { + context.getTree(this[_summarizer]).visit(this, context); + } +} +module.exports = ReportBase; +//# sourceMappingURL=report-base.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs new file mode 100644 index 00000000000..795a0d73ee1 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs @@ -0,0 +1,224 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +const coverage = require("../../lib-coverage/index.cjs"); +const Path = require("./path.cjs"); +const { BaseNode, BaseTree } = require("./tree.cjs"); +class ReportNode extends BaseNode { + constructor(path, fileCoverage) { + super(); + this.path = path; + this.parent = null; + this.fileCoverage = fileCoverage; + this.children = []; + } + static createRoot(children) { + const root = new ReportNode(new Path([])); + children.forEach((child) => { + root.addChild(child); + }); + return root; + } + addChild(child) { + child.parent = this; + this.children.push(child); + } + asRelative(p) { + if (p.substring(0, 1) === "/") { + return p.substring(1); + } + return p; + } + getQualifiedName() { + return this.asRelative(this.path.toString()); + } + getRelativeName() { + const parent = this.getParent(); + const myPath = this.path; + let relPath; + let i; + const parentPath = parent ? parent.path : new Path([]); + if (parentPath.ancestorOf(myPath)) { + relPath = new Path(myPath.elements()); + for (i = 0; i < parentPath.length; i += 1) { + relPath.shift(); + } + return this.asRelative(relPath.toString()); + } + return this.asRelative(this.path.toString()); + } + getParent() { + return this.parent; + } + getChildren() { + return this.children; + } + isSummary() { + return !this.fileCoverage; + } + getFileCoverage() { + return this.fileCoverage; + } + getCoverageSummary(filesOnly) { + const cacheProp = `c_${filesOnly ? "files" : "full"}`; + let summary; + if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { + return this[cacheProp]; + } + if (!this.isSummary()) { + summary = this.getFileCoverage().toSummary(); + } + else { + let count = 0; + summary = coverage.createCoverageSummary(); + this.getChildren().forEach((child) => { + if (filesOnly && child.isSummary()) { + return; + } + count += 1; + summary.merge(child.getCoverageSummary(filesOnly)); + }); + if (count === 0 && filesOnly) { + summary = null; + } + } + this[cacheProp] = summary; + return summary; + } +} +class ReportTree extends BaseTree { + constructor(root, childPrefix) { + super(root); + const maybePrefix = (node) => { + if (childPrefix && !node.isRoot()) { + node.path.unshift(childPrefix); + } + }; + this.visit({ + onDetail: maybePrefix, + onSummary(node) { + maybePrefix(node); + node.children.sort((a, b) => { + const astr = a.path.toString(); + const bstr = b.path.toString(); + return astr < bstr + ? -1 + : astr > bstr + ? 1 + : /* istanbul ignore next */ 0; + }); + }, + }); + } +} +function findCommonParent(paths) { + return paths.reduce((common, path) => common.commonPrefixPath(path), paths[0] || new Path([])); +} +function findOrCreateParent(parentPath, nodeMap, created = () => { }) { + let parent = nodeMap[parentPath.toString()]; + if (!parent) { + parent = new ReportNode(parentPath); + nodeMap[parentPath.toString()] = parent; + created(parentPath, parent); + } + return parent; +} +function toDirParents(list) { + const nodeMap = Object.create(null); + list.forEach((o) => { + const parent = findOrCreateParent(o.path.parent(), nodeMap); + parent.addChild(new ReportNode(o.path, o.fileCoverage)); + }); + return Object.values(nodeMap); +} +function addAllPaths(topPaths, nodeMap, path, node) { + const parent = findOrCreateParent(path.parent(), nodeMap, (parentPath, parent) => { + if (parentPath.hasParent()) { + addAllPaths(topPaths, nodeMap, parentPath, parent); + } + else { + topPaths.push(parent); + } + }); + parent.addChild(node); +} +function foldIntoOneDir(node, parent) { + const { children } = node; + if (children.length === 1 && !children[0].fileCoverage) { + children[0].parent = parent; + return foldIntoOneDir(children[0], parent); + } + node.children = children.map((child) => foldIntoOneDir(child, node)); + return node; +} +function pkgSummaryPrefix(dirParents, commonParent) { + if (!dirParents.some((dp) => dp.path.length === 0)) { + return; + } + if (commonParent.length === 0) { + return "root"; + } + return commonParent.name(); +} +class SummarizerFactory { + constructor(coverageMap, defaultSummarizer = "pkg") { + this._coverageMap = coverageMap; + this._defaultSummarizer = defaultSummarizer; + this._initialList = coverageMap.files().map((filePath) => ({ + filePath, + path: new Path(filePath), + fileCoverage: coverageMap.fileCoverageFor(filePath), + })); + this._commonParent = findCommonParent(this._initialList.map((o) => o.path.parent())); + if (this._commonParent.length > 0) { + this._initialList.forEach((o) => { + o.path.splice(0, this._commonParent.length); + }); + } + } + get defaultSummarizer() { + return this[this._defaultSummarizer]; + } + get flat() { + if (!this._flat) { + this._flat = new ReportTree(ReportNode.createRoot(this._initialList.map((node) => new ReportNode(node.path, node.fileCoverage)))); + } + return this._flat; + } + _createPkg() { + const dirParents = toDirParents(this._initialList); + if (dirParents.length === 1) { + return new ReportTree(dirParents[0]); + } + return new ReportTree(ReportNode.createRoot(dirParents), pkgSummaryPrefix(dirParents, this._commonParent)); + } + get pkg() { + if (!this._pkg) { + this._pkg = this._createPkg(); + } + return this._pkg; + } + _createNested() { + const nodeMap = Object.create(null); + const topPaths = []; + this._initialList.forEach((o) => { + const node = new ReportNode(o.path, o.fileCoverage); + addAllPaths(topPaths, nodeMap, o.path, node); + }); + const topNodes = topPaths.map((node) => foldIntoOneDir(node)); + if (topNodes.length === 1) { + return new ReportTree(topNodes[0]); + } + return new ReportTree(ReportNode.createRoot(topNodes)); + } + get nested() { + if (!this._nested) { + this._nested = this._createNested(); + } + return this._nested; + } +} +module.exports = SummarizerFactory; +//# sourceMappingURL=summarizer-factory.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs new file mode 100644 index 00000000000..784260e959c --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs @@ -0,0 +1,126 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; +/** + * An object with methods that are called during the traversal of the coverage tree. + * A visitor has the following methods that are called during tree traversal. + * + * * `onStart(root, state)` - called before traversal begins + * * `onSummary(node, state)` - called for every summary node + * * `onDetail(node, state)` - called for every detail node + * * `onSummaryEnd(node, state)` - called after all children have been visited for + * a summary node. + * * `onEnd(root, state)` - called after traversal ends + * + * @param delegate - a partial visitor that only implements the methods of interest + * The visitor object supplies the missing methods as noops. For example, reports + * that only need the final coverage summary need implement `onStart` and nothing + * else. Reports that use only detailed coverage information need implement `onDetail` + * and nothing else. + * @constructor + */ +class Visitor { + constructor(delegate) { + this.delegate = delegate; + } +} +["Start", "End", "Summary", "SummaryEnd", "Detail"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(Visitor.prototype, fn, { + writable: true, + value(node, state) { + if (typeof this.delegate[fn] === "function") { + this.delegate[fn](node, state); + } + }, + }); +}); +class CompositeVisitor extends Visitor { + constructor(visitors) { + super(); + if (!Array.isArray(visitors)) { + visitors = [visitors]; + } + this.visitors = visitors.map((v) => { + if (v instanceof Visitor) { + return v; + } + return new Visitor(v); + }); + } +} +["Start", "Summary", "SummaryEnd", "Detail", "End"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(CompositeVisitor.prototype, fn, { + value(node, state) { + this.visitors.forEach((v) => { + v[fn](node, state); + }); + }, + }); +}); +class BaseNode { + isRoot() { + return !this.getParent(); + } + /** + * visit all nodes depth-first from this node down. Note that `onStart` + * and `onEnd` are never called on the visitor even if the current + * node is the root of the tree. + * @param visitor a full visitor that is called during tree traversal + * @param state optional state that is passed around + */ + visit(visitor, state) { + if (this.isSummary()) { + visitor.onSummary(this, state); + } + else { + visitor.onDetail(this, state); + } + this.getChildren().forEach((child) => { + child.visit(visitor, state); + }); + if (this.isSummary()) { + visitor.onSummaryEnd(this, state); + } + } +} +/** + * abstract base class for a coverage tree. + * @constructor + */ +class BaseTree { + constructor(root) { + this.root = root; + } + /** + * returns the root node of the tree + */ + getRoot() { + return this.root; + } + /** + * visits the tree depth-first with the supplied partial visitor + * @param visitor - a potentially partial visitor + * @param state - the state to be passed around during tree traversal + */ + visit(visitor, state) { + if (!(visitor instanceof Visitor)) { + visitor = new Visitor(visitor); + } + visitor.onStart(this.getRoot(), state); + this.getRoot().visit(visitor, state); + visitor.onEnd(this.getRoot(), state); + } +} +module.exports = { + BaseTree, + BaseNode, + Visitor, + CompositeVisitor, +}; +//# sourceMappingURL=tree.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs new file mode 100644 index 00000000000..6ba3cb2280a --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs @@ -0,0 +1,16 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +module.exports = { + getDefault() { + return { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], + }; + }, +}; +//# sourceMappingURL=watermarks.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs new file mode 100644 index 00000000000..ce0b0e0eb97 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs @@ -0,0 +1,81 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const INDENT = " "; +function attrString(attrs) { + return Object.entries(attrs || {}) + .map(([k, v]) => ` ${k}="${v}"`) + .join(""); +} +/** + * a utility class to produce well-formed, indented XML + * @param {ContentWriter} contentWriter the content writer that this utility wraps + * @constructor + */ +class XMLWriter { + constructor(contentWriter) { + this.cw = contentWriter; + this.stack = []; + } + indent(str) { + return this.stack.map(() => INDENT).join("") + str; + } + /** + * writes the opening XML tag with the supplied attributes + * @param {String} name tag name + * @param {Object} [attrs=null] attrs attributes for the tag + */ + openTag(name, attrs) { + const str = this.indent(`<${name + attrString(attrs)}>`); + this.cw.println(str); + this.stack.push(name); + } + /** + * closes an open XML tag. + * @param {String} name - tag name to close. This must match the writer's + * notion of the tag that is currently open. + */ + closeTag(name) { + if (this.stack.length === 0) { + throw new Error(`Attempt to close tag ${name} when not opened`); + } + const stashed = this.stack.pop(); + const str = ``; + if (stashed !== name) { + throw new Error(`Attempt to close tag ${name} when ${stashed} was the one open`); + } + this.cw.println(this.indent(str)); + } + /** + * writes a tag and its value opening and closing it at the same time + * @param {String} name tag name + * @param {Object} [attrs=null] attrs tag attributes + * @param {String} [content=null] content optional tag content + */ + inlineTag(name, attrs, content) { + let str = "<" + name + attrString(attrs); + if (content) { + str += `>${content}`; + } + else { + str += "/>"; + } + str = this.indent(str); + this.cw.println(str); + } + /** + * closes all open tags and ends the document + */ + closeAll() { + this.stack + .slice() + .reverse() + .forEach((name) => { + this.closeTag(name); + }); + } +} +module.exports = XMLWriter; +//# sourceMappingURL=xml-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/types.js b/v-next/hardhat-vendored/dist/src/coverage/types.js new file mode 100644 index 00000000000..718fd38ae40 --- /dev/null +++ b/v-next/hardhat-vendored/dist/src/coverage/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/node_modules/@types/bn.js b/v-next/hardhat-vendored/node_modules/@types/bn.js new file mode 120000 index 00000000000..112e2ea8381 --- /dev/null +++ b/v-next/hardhat-vendored/node_modules/@types/bn.js @@ -0,0 +1 @@ +../../../../node_modules/.pnpm/@types+bn.js@5.2.0/node_modules/@types/bn.js \ No newline at end of file diff --git a/v-next/hardhat-vendored/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendored/src/coverage/html-escaper/index.cjs new file mode 100644 index 00000000000..d823b800faf --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/html-escaper/index.cjs @@ -0,0 +1,24 @@ +const { replace } = ""; + +// escape +const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; +const ca = /[&<>'"]/g; + +const esca = { + "&": "&", + "<": "<", + ">": ">", + "'": "'", + '"': """, +}; +const pe = (m) => esca[m]; + +/** + * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. + * @param {string} es the input to safely escape + * @returns {string} the escaped input, and it **throws** an error if + * the input type is unexpected, except for boolean and numbers, + * converted as string. + */ +const escape = (es) => replace.call(es, ca, pe); +exports.escape = escape; diff --git a/v-next/hardhat-vendored/src/coverage/index.js b/v-next/hardhat-vendored/src/coverage/index.js new file mode 100644 index 00000000000..e77664e0c22 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/index.js @@ -0,0 +1,8 @@ +import libCoverage from "./lib-coverage/index.cjs"; +export { libCoverage }; + +import libReport from "./lib-report/index.cjs"; +export { libReport }; + +import reports from "./istanbul-reports/index.cjs"; +export { reports }; diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendored/src/coverage/istanbul-reports/index.cjs new file mode 100644 index 00000000000..7db2b63fa9f --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/index.cjs @@ -0,0 +1,24 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); + +module.exports = { + create(name, cfg) { + cfg = cfg || {}; + let Cons; + try { + Cons = require(path.join(__dirname, "lib", name, "index.cjs")); + } catch (e) { + if (e.code !== "MODULE_NOT_FOUND") { + throw e; + } + + Cons = require(name); + } + + return new Cons(cfg); + }, +}; diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/annotator.cjs new file mode 100644 index 00000000000..a9b47a7380a --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/annotator.cjs @@ -0,0 +1,294 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const InsertionText = require("./insertion-text.cjs"); +const lt = "\u0001"; +const gt = "\u0002"; +const RE_LT = //g; +const RE_AMP = /&/g; + +var RE_lt = /\u0001/g; + +var RE_gt = /\u0002/g; + +function title(str) { + return ' title="' + str + '" '; +} + +function customEscape(text) { + text = String(text); + return text + .replace(RE_AMP, "&") + .replace(RE_LT, "<") + .replace(RE_GT, ">") + .replace(RE_lt, "<") + .replace(RE_gt, ">"); +} + +function annotateLines(fileCoverage, structuredText) { + const lineStats = fileCoverage.getLineCoverage(); + if (!lineStats) { + return; + } + Object.entries(lineStats).forEach(([lineNumber, count]) => { + if (structuredText[lineNumber]) { + structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; + structuredText[lineNumber].hits = count; + } + }); +} + +function annotateStatements(fileCoverage, structuredText) { + const statementStats = fileCoverage.s; + const statementMeta = fileCoverage.statementMap; + Object.entries(statementStats).forEach(([stName, count]) => { + const meta = statementMeta[stName]; + const type = count > 0 ? "yes" : "no"; + const startCol = meta.start.column; + let endCol = meta.end.column + 1; + const startLine = meta.start.line; + const endLine = meta.end.line; + const openSpan = + lt + + 'span class="' + + (meta.skip ? "cstat-skip" : "cstat-no") + + '"' + + title("statement not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + }); +} + +function annotateFunctions(fileCoverage, structuredText) { + const fnStats = fileCoverage.f; + const fnMeta = fileCoverage.fnMap; + if (!fnStats) { + return; + } + Object.entries(fnStats).forEach(([fName, count]) => { + const meta = fnMeta[fName]; + const type = count > 0 ? "yes" : "no"; + // Some versions of the instrumenter in the wild populate 'func' + // but not 'decl': + const decl = meta.decl || meta.loc; + const startCol = decl.start.column; + let endCol = decl.end.column + 1; + const startLine = decl.start.line; + const endLine = decl.end.line; + const openSpan = + lt + + 'span class="' + + (meta.skip ? "fstat-skip" : "fstat-no") + + '"' + + title("function not covered") + + gt; + const closeSpan = lt + "/span" + gt; + let text; + + if (type === "no" && structuredText[startLine]) { + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + }); +} + +function annotateBranches(fileCoverage, structuredText) { + const branchStats = fileCoverage.b; + const branchMeta = fileCoverage.branchMap; + if (!branchStats) { + return; + } + + Object.entries(branchStats).forEach(([branchName, branchArray]) => { + const sumCount = branchArray.reduce((p, n) => p + n, 0); + const metaArray = branchMeta[branchName].locations; + let i; + let count; + let meta; + let startCol; + let endCol; + let startLine; + let endLine; + let openSpan; + let closeSpan; + let text; + + // only highlight if partial branches are missing or if there is a + // single uncovered branch. + if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { + // Need to recover the metaArray placeholder item to count an implicit else + if ( + // Check if the branch is a conditional if branch. + branchMeta[branchName].type === "if" && + // Check if the branch has an implicit else. + branchArray.length === 2 && + // Check if the implicit else branch is unaccounted for. + metaArray.length === 1 && + // Check if the implicit else branch is uncovered. + branchArray[1] === 0 + ) { + metaArray[1] = { + start: {}, + end: {}, + }; + } + + for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { + count = branchArray[i]; + meta = metaArray[i]; + startCol = meta.start.column; + endCol = meta.end.column + 1; + startLine = meta.start.line; + endLine = meta.end.line; + openSpan = + lt + + 'span class="branch-' + + i + + " " + + (meta.skip ? "cbranch-skip" : "cbranch-no") + + '"' + + title("branch not covered") + + gt; + closeSpan = lt + "/span" + gt; + + // If the branch is an implicit else from an if statement, + // then the coverage report won't show a statistic. + // Therefore, the previous branch will be used to report that + // there is no coverage on that implicit branch. + if ( + count === 0 && + startLine === undefined && + branchMeta[branchName].type === "if" + ) { + const prevMeta = metaArray[i - 1]; + startCol = prevMeta.start.column; + endCol = prevMeta.end.column + 1; + startLine = prevMeta.start.line; + endLine = prevMeta.end.line; + } + + if (count === 0 && structuredText[startLine]) { + //skip branches taken + if (endLine !== startLine) { + endCol = structuredText[startLine].text.originalLength(); + } + text = structuredText[startLine].text; + if (branchMeta[branchName].type === "if") { + // 'if' is a special case + // since the else branch might not be visible, being nonexistent + text.insertAt( + startCol, + lt + + 'span class="' + + (meta.skip ? "skip-if-branch" : "missing-if-branch") + + '"' + + title((i === 0 ? "if" : "else") + " path not taken") + + gt + + (i === 0 ? "I" : "E") + + lt + + "/span" + + gt, + true, + false, + ); + } else { + text.wrap( + startCol, + openSpan, + startCol < endCol ? endCol : text.originalLength(), + closeSpan, + ); + } + } + } + } + }); +} + +function annotateSourceCode(fileCoverage, sourceStore) { + let codeArray; + let lineCoverageArray; + try { + const sourceText = sourceStore.getSource(fileCoverage.path); + const code = sourceText.split(/(?:\r?\n)|\r/); + let count = 0; + const structured = code.map((str) => { + count += 1; + return { + line: count, + covered: "neutral", + hits: 0, + text: new InsertionText(str, true), + }; + }); + structured.unshift({ + line: 0, + covered: null, + text: new InsertionText(""), + }); + annotateLines(fileCoverage, structured); + //note: order is important, since statements typically result in spanning the whole line and doing branches late + //causes mismatched tags + annotateBranches(fileCoverage, structured); + annotateFunctions(fileCoverage, structured); + annotateStatements(fileCoverage, structured); + structured.shift(); + + codeArray = structured.map( + (item) => customEscape(item.text.toString()) || " ", + ); + + lineCoverageArray = structured.map((item) => ({ + covered: item.covered, + hits: item.hits > 0 ? item.hits + "x" : " ", + })); + + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: structured.length, + }; + } catch (ex) { + codeArray = [ex.message]; + lineCoverageArray = [{ covered: "no", hits: 0 }]; + String(ex.stack || "") + .split(/\r?\n/) + .forEach((line) => { + codeArray.push(line); + lineCoverageArray.push({ covered: "no", hits: 0 }); + }); + return { + annotatedCode: codeArray, + lineCoverage: lineCoverageArray, + maxLines: codeArray.length, + }; + } +} + +module.exports = annotateSourceCode; diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/base.css new file mode 100644 index 00000000000..f418035b469 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js new file mode 100644 index 00000000000..eb527848ee7 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js @@ -0,0 +1,86 @@ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sorter.js new file mode 100644 index 00000000000..83122f78ace --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sorter.js @@ -0,0 +1,209 @@ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css new file mode 100644 index 00000000000..b317a7cda31 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js new file mode 100644 index 00000000000..ef51e038668 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/index.cjs new file mode 100644 index 00000000000..a958877e7f2 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/index.cjs @@ -0,0 +1,409 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const path = require("node:path"); +const html = require("../../../html-escaper/index.cjs"); +const ReportBase = require("../../../lib-report/lib/report-base.cjs"); +const annotator = require("./annotator.cjs"); + +function htmlHead(details) { + return ` + + Code coverage report for ${html.escape(details.entity)} + + + + + + + + `; +} + +function headerTemplate(details) { + function metricsTemplate({ pct, covered, total }, kind) { + return ` +
+ ${pct}% + ${kind} + ${covered}/${total} +
+ `; + } + + function skipTemplate(metrics) { + const statements = metrics.statements.skipped; + const branches = metrics.branches.skipped; + const functions = metrics.functions.skipped; + + const countLabel = (c, label, plural) => + c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; + const skips = [].concat( + countLabel(statements, "statement", "s"), + countLabel(functions, "function", "s"), + countLabel(branches, "branch", "es"), + ); + + if (skips.length === 0) { + return ""; + } + + return ` +
+ ${skips.join(", ")} + Ignored      +
+ `; + } + + return ` + + +${htmlHead(details)} + +
+
+

${details.pathHtml}

+
+ ${metricsTemplate(details.metrics.statements, "Statements")} + ${metricsTemplate(details.metrics.branches, "Branches")} + ${metricsTemplate(details.metrics.functions, "Functions")} + ${metricsTemplate(details.metrics.lines, "Lines")} + ${skipTemplate(details.metrics)} +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+ `; +} + +function footerTemplate(details) { + return ` +
+
+ + + + + + + + `; +} + +function detailTemplate(data) { + const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); + const lineLink = (num) => + `${num}`; + const lineCount = (line) => + `${line.hits}`; + + /* This is rendered in a `
`, need control of all whitespace. */
+  return [
+    "",
+    `${lineNumbers.map(lineLink).join("\n")}`,
+    `${data.lineCoverage
+      .map(lineCount)
+      .join("\n")}`,
+    `
${data.annotatedCode.join(
+      "\n",
+    )}
`, + "", + ].join(""); +} +const summaryTableHeader = [ + '
', + '', + "", + "", + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + "", + "", + "", +].join("\n"); + +function summaryLineTemplate(details) { + const { reportClasses, metrics, file, output } = details; + const percentGraph = (pct) => { + if (!isFinite(pct)) { + return ""; + } + + const cls = ["cover-fill"]; + if (pct === 100) { + cls.push("cover-full"); + } + + pct = Math.floor(pct); + return [ + `
`, + `
`, + ].join(""); + }; + const summaryType = (type, showGraph = false) => { + const info = metrics[type]; + const reportClass = reportClasses[type]; + const result = [ + ``, + ``, + ]; + if (showGraph) { + result.unshift( + ``, + ); + } + + return result; + }; + + return [] + .concat( + "", + ``, + summaryType("statements", true), + summaryType("branches"), + summaryType("functions"), + summaryType("lines"), + "\n", + ) + .join("\n\t"); +} + +const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, + `
${percentGraph(info.pct)}
`, + `
${html.escape(file)}
", "
"].join("\n"); +const emptyClasses = { + statements: "empty", + lines: "empty", + functions: "empty", + branches: "empty", +}; + +const standardLinkMapper = { + getPath(node) { + if (typeof node === "string") { + return node; + } + let filePath = node.getQualifiedName(); + if (node.isSummary()) { + if (filePath !== "") { + filePath += "/index.html"; + } else { + filePath = "index.html"; + } + } else { + filePath += ".html"; + } + return filePath; + }, + + relativePath(source, target) { + const targetPath = this.getPath(target); + const sourcePath = path.dirname(this.getPath(source)); + return path.posix.relative(sourcePath, targetPath); + }, + + assetPath(node, name) { + return this.relativePath(this.getPath(node), name); + }, +}; + +function fixPct(metrics) { + Object.keys(emptyClasses).forEach((key) => { + metrics[key].pct = 0; + }); + return metrics; +} + +class HtmlReport extends ReportBase { + constructor(opts) { + super(); + + this.verbose = opts.verbose; + this.linkMapper = opts.linkMapper || standardLinkMapper; + this.subdir = opts.subdir || ""; + this.date = new Date().toISOString(); + this.skipEmpty = opts.skipEmpty; + } + + getBreadcrumbHtml(node) { + let parent = node.getParent(); + const nodePath = []; + + while (parent) { + nodePath.push(parent); + parent = parent.getParent(); + } + + const linkPath = nodePath.map((ancestor) => { + const target = this.linkMapper.relativePath(node, ancestor); + const name = ancestor.getRelativeName() || "All files"; + return '' + name + ""; + }); + + linkPath.reverse(); + return linkPath.length > 0 + ? linkPath.join(" / ") + " " + node.getRelativeName() + : "All files"; + } + + fillTemplate(node, templateData, context) { + const linkMapper = this.linkMapper; + const summary = node.getCoverageSummary(); + templateData.entity = node.getQualifiedName() || "All files"; + templateData.metrics = summary; + templateData.reportClass = context.classForPercent( + "statements", + summary.statements.pct, + ); + templateData.pathHtml = this.getBreadcrumbHtml(node); + templateData.base = { + css: linkMapper.assetPath(node, "base.css"), + }; + templateData.sorter = { + js: linkMapper.assetPath(node, "sorter.js"), + image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), + }; + templateData.blockNavigation = { + js: linkMapper.assetPath(node, "block-navigation.js"), + }; + templateData.prettify = { + js: linkMapper.assetPath(node, "prettify.js"), + css: linkMapper.assetPath(node, "prettify.css"), + }; + templateData.favicon = linkMapper.assetPath(node, "favicon.png"); + } + + getTemplateData() { + return { datetime: this.date }; + } + + getWriter(context) { + if (!this.subdir) { + return context.writer; + } + return context.writer.writerForDir(this.subdir); + } + + onStart(root, context) { + const assetHeaders = { + ".js": "/* eslint-disable */\n", + }; + + [".", "vendor"].forEach((subdir) => { + const writer = this.getWriter(context); + const srcDir = path.resolve(__dirname, "assets", subdir); + fs.readdirSync(srcDir).forEach((f) => { + const resolvedSource = path.resolve(srcDir, f); + const resolvedDestination = "."; + const stat = fs.statSync(resolvedSource); + let dest; + + if (stat.isFile()) { + dest = resolvedDestination + "/" + f; + if (this.verbose) { + console.log("Write asset: " + dest); + } + writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); + } + }); + }); + } + + onSummary(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + const children = node.getChildren(); + const skipEmpty = this.skipEmpty; + + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write(summaryTableHeader); + children.forEach((child) => { + const metrics = child.getCoverageSummary(); + const isEmpty = metrics.isEmpty(); + if (skipEmpty && isEmpty) { + return; + } + const reportClasses = isEmpty + ? emptyClasses + : { + statements: context.classForPercent( + "statements", + metrics.statements.pct, + ), + lines: context.classForPercent("lines", metrics.lines.pct), + functions: context.classForPercent( + "functions", + metrics.functions.pct, + ), + branches: context.classForPercent("branches", metrics.branches.pct), + }; + const data = { + metrics: isEmpty ? fixPct(metrics) : metrics, + reportClasses, + file: child.getRelativeName(), + output: linkMapper.relativePath(node, child), + }; + cw.write(summaryLineTemplate(data) + "\n"); + }); + cw.write(summaryTableFooter); + cw.write(footerTemplate(templateData)); + cw.close(); + } + + onDetail(node, context) { + const linkMapper = this.linkMapper; + const templateData = this.getTemplateData(); + + this.fillTemplate(node, templateData, context); + const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); + cw.write(headerTemplate(templateData)); + cw.write('
\n');
+    cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
+    cw.write("
\n"); + cw.write(footerTemplate(templateData)); + cw.close(); + } +} + +module.exports = HtmlReport; diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/insertion-text.cjs new file mode 100644 index 00000000000..6f8064245c2 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/insertion-text.cjs @@ -0,0 +1,114 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +function InsertionText(text, consumeBlanks) { + this.text = text; + this.origLength = text.length; + this.offsets = []; + this.consumeBlanks = consumeBlanks; + this.startPos = this.findFirstNonBlank(); + this.endPos = this.findLastNonBlank(); +} + +const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; + +InsertionText.prototype = { + findFirstNonBlank() { + let pos = -1; + const text = this.text; + const len = text.length; + let i; + for (i = 0; i < len; i += 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + findLastNonBlank() { + const text = this.text; + const len = text.length; + let pos = text.length + 1; + let i; + for (i = len - 1; i >= 0; i -= 1) { + if (!text.charAt(i).match(WHITE_RE)) { + pos = i; + break; + } + } + return pos; + }, + originalLength() { + return this.origLength; + }, + + insertAt(col, str, insertBefore, consumeBlanks) { + consumeBlanks = + typeof consumeBlanks === 'undefined' + ? this.consumeBlanks + : consumeBlanks; + col = col > this.originalLength() ? this.originalLength() : col; + col = col < 0 ? 0 : col; + + if (consumeBlanks) { + if (col <= this.startPos) { + col = 0; + } + if (col > this.endPos) { + col = this.origLength; + } + } + + const len = str.length; + const offset = this.findOffset(col, len, insertBefore); + const realPos = col + offset; + const text = this.text; + this.text = text.substring(0, realPos) + str + text.substring(realPos); + return this; + }, + + findOffset(pos, len, insertBefore) { + const offsets = this.offsets; + let offsetObj; + let cumulativeOffset = 0; + let i; + + for (i = 0; i < offsets.length; i += 1) { + offsetObj = offsets[i]; + if ( + offsetObj.pos < pos || + (offsetObj.pos === pos && !insertBefore) + ) { + cumulativeOffset += offsetObj.len; + } + if (offsetObj.pos >= pos) { + break; + } + } + if (offsetObj && offsetObj.pos === pos) { + offsetObj.len += len; + } else { + offsets.splice(i, 0, { pos, len }); + } + return cumulativeOffset; + }, + + wrap(startPos, startText, endPos, endText, consumeBlanks) { + this.insertAt(startPos, startText, true, consumeBlanks); + this.insertAt(endPos, endText, false, consumeBlanks); + return this; + }, + + wrapLine(startText, endText) { + this.wrap(0, startText, this.originalLength(), endText); + }, + + toString() { + return this.text; + } +}; + +module.exports = InsertionText; diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendored/src/coverage/lib-coverage/index.cjs new file mode 100644 index 00000000000..c6074ee2d56 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-coverage/index.cjs @@ -0,0 +1,64 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * istanbul-lib-coverage exports an API that allows you to create and manipulate + * file coverage, coverage maps (a set of file coverage objects) and summary + * coverage objects. File coverage for the same file can be merged as can + * entire coverage maps. + * + * @module Exports + */ +const { FileCoverage } = require("./lib/file-coverage.cjs"); +const { CoverageMap } = require("./lib/coverage-map.cjs"); +const { CoverageSummary } = require("./lib/coverage-summary.cjs"); + +module.exports = { + /** + * creates a coverage summary object + * @param {Object} obj an argument with the same semantics + * as the one passed to the `CoverageSummary` constructor + * @returns {CoverageSummary} + */ + createCoverageSummary(obj) { + if (obj && obj instanceof CoverageSummary) { + return obj; + } + return new CoverageSummary(obj); + }, + /** + * creates a CoverageMap object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the CoverageMap constructor. + * @returns {CoverageMap} + */ + createCoverageMap(obj) { + if (obj && obj instanceof CoverageMap) { + return obj; + } + return new CoverageMap(obj); + }, + /** + * creates a FileCoverage object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the FileCoverage constructor. + * @returns {FileCoverage} + */ + createFileCoverage(obj) { + if (obj && obj instanceof FileCoverage) { + return obj; + } + return new FileCoverage(obj); + }, +}; + +/** classes exported for reuse */ +module.exports.classes = { + /** + * the file coverage constructor + */ + FileCoverage, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-map.cjs new file mode 100644 index 00000000000..d5820c2c740 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-map.cjs @@ -0,0 +1,128 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const { FileCoverage } = require("./file-coverage.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); + +function maybeConstruct(obj, klass) { + if (obj instanceof klass) { + return obj; + } + + return new klass(obj); +} + +function loadMap(source) { + const data = Object.create(null); + if (!source) { + return data; + } + + Object.entries(source).forEach(([k, cov]) => { + data[k] = maybeConstruct(cov, FileCoverage); + }); + + return data; +} + +/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ +class CoverageMap { + /** + * @constructor + * @param {Object} [obj=undefined] obj A coverage map from which to initialize this + * map's contents. This can be the raw global coverage object. + */ + constructor(obj) { + if (obj instanceof CoverageMap) { + this.data = obj.data; + } else { + this.data = loadMap(obj); + } + } + + /** + * merges a second coverage map into this one + * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged + * correctly for the same files and additional file coverage keys are created + * as needed. + */ + merge(obj) { + const other = maybeConstruct(obj, CoverageMap); + Object.values(other.data).forEach((fc) => { + this.addFileCoverage(fc); + }); + } + + /** + * filter the coveragemap based on the callback provided + * @param {Function (filename)} callback - Returns true if the path + * should be included in the coveragemap. False if it should be + * removed. + */ + filter(callback) { + Object.keys(this.data).forEach((k) => { + if (!callback(k)) { + delete this.data[k]; + } + }); + } + + /** + * returns a JSON-serializable POJO for this coverage map + * @returns {Object} + */ + toJSON() { + return this.data; + } + + /** + * returns an array for file paths for which this map has coverage + * @returns {Array{string}} - array of files + */ + files() { + return Object.keys(this.data); + } + + /** + * returns the file coverage for the specified file. + * @param {String} file + * @returns {FileCoverage} + */ + fileCoverageFor(file) { + const fc = this.data[file]; + if (!fc) { + throw new Error(`No file coverage available for: ${file}`); + } + return fc; + } + + addFileCoverage(fc) { + const cov = new FileCoverage(fc); + const { path } = cov; + if (this.data[path]) { + this.data[path].merge(cov); + } else { + this.data[path] = cov; + } + } + + /** + * returns the coverage summary for all the file coverage objects in this map. + * @returns {CoverageSummary} + */ + getCoverageSummary() { + const ret = new CoverageSummary(); + Object.values(this.data).forEach((fc) => { + ret.merge(fc.toSummary()); + }); + + return ret; + } +} + +module.exports = { + CoverageMap, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-summary.cjs new file mode 100644 index 00000000000..1e6a9498936 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-summary.cjs @@ -0,0 +1,112 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); + +function blankSummary() { + const empty = () => ({ + total: 0, + covered: 0, + skipped: 0, + pct: "Unknown", + }); + + return { + lines: empty(), + statements: empty(), + functions: empty(), + branches: empty(), + branchesTrue: empty(), + }; +} + +// asserts that a data object "looks like" a summary coverage object +function assertValidSummary(obj) { + const valid = + obj && obj.lines && obj.statements && obj.functions && obj.branches; + if (!valid) { + throw new Error( + "Invalid summary coverage object, missing keys, found:" + + Object.keys(obj).join(","), + ); + } +} + +/** + * CoverageSummary provides a summary of code coverage . It exposes 4 properties, + * `lines`, `statements`, `branches`, and `functions`. Each of these properties + * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. + * `pct` is a percentage number (0-100). + */ +class CoverageSummary { + /** + * @constructor + * @param {Object|CoverageSummary} [obj=undefined] an optional data object or + * another coverage summary to initialize this object with. + */ + constructor(obj) { + if (!obj) { + this.data = blankSummary(); + } else if (obj instanceof CoverageSummary) { + this.data = obj.data; + } else { + this.data = obj; + } + assertValidSummary(this.data); + } + + /** + * merges a second summary coverage object into this one + * @param {CoverageSummary} obj - another coverage summary object + */ + merge(obj) { + const keys = [ + "lines", + "statements", + "branches", + "functions", + "branchesTrue", + ]; + keys.forEach((key) => { + if (obj[key]) { + this[key].total += obj[key].total; + this[key].covered += obj[key].covered; + this[key].skipped += obj[key].skipped; + this[key].pct = percent(this[key].covered, this[key].total); + } + }); + + return this; + } + + /** + * returns a POJO that is JSON serializable. May be used to get the raw + * summary object. + */ + toJSON() { + return this.data; + } + + /** + * return true if summary has no lines of code + */ + isEmpty() { + return this.lines.total === 0; + } +} + +dataProperties(CoverageSummary, [ + "lines", + "statements", + "functions", + "branches", + "branchesTrue", +]); + +module.exports = { + CoverageSummary, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/data-properties.cjs new file mode 100644 index 00000000000..ad6ac0e1453 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/data-properties.cjs @@ -0,0 +1,12 @@ +"use strict"; + +module.exports = function dataProperties(klass, properties) { + properties.forEach((p) => { + Object.defineProperty(klass.prototype, p, { + enumerable: true, + get() { + return this.data[p]; + }, + }); + }); +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/file-coverage.cjs new file mode 100644 index 00000000000..47f45bbd63f --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/file-coverage.cjs @@ -0,0 +1,442 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const percent = require("./percent.cjs"); +const dataProperties = require("./data-properties.cjs"); +const { CoverageSummary } = require("./coverage-summary.cjs"); + +// returns a data object that represents empty coverage +function emptyCoverage(filePath, reportLogic) { + const cov = { + path: filePath, + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {}, + }; + if (reportLogic) cov.bT = {}; + return cov; +} + +// asserts that a data object "looks like" a coverage object +function assertValidObject(obj) { + const valid = + obj && + obj.path && + obj.statementMap && + obj.fnMap && + obj.branchMap && + obj.s && + obj.f && + obj.b; + if (!valid) { + throw new Error( + "Invalid file coverage object, missing keys, found:" + + Object.keys(obj).join(","), + ); + } +} + +const keyFromLoc = ({ start, end }) => + `${start.line}|${start.column}|${end.line}|${end.column}`; + +const isObj = (o) => !!o && typeof o === "object"; +const isLineCol = (o) => + isObj(o) && typeof o.line === "number" && typeof o.column === "number"; +const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); +const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); + +// When merging, we can have a case where two ranges cover +// the same block of code with `hits=1`, and each carve out a +// different range with `hits=0` to indicate it's uncovered. +// Find the nearest container so that we can properly indicate +// that both sections are hit. +// Returns null if no containing item is found. +const findNearestContainer = (item, map) => { + const itemLoc = getLoc(item); + if (!itemLoc) return null; + // the B item is not an identified range in the A set, BUT + // it may be contained by an identified A range. If so, then + // any hit of that containing A range counts as a hit of this + // B range as well. We have to find the *narrowest* containing + // range to be accurate, since ranges can be hit and un-hit + // in a nested fashion. + let nearestContainingItem = null; + let containerDistance = null; + let containerKey = null; + for (const [i, mapItem] of Object.entries(map)) { + const mapLoc = getLoc(mapItem); + if (!mapLoc) continue; + // contained if all of line distances are > 0 + // or line distance is 0 and col dist is >= 0 + const distance = [ + itemLoc.start.line - mapLoc.start.line, + itemLoc.start.column - mapLoc.start.column, + mapLoc.end.line - itemLoc.end.line, + mapLoc.end.column - itemLoc.end.column, + ]; + if ( + distance[0] < 0 || + distance[2] < 0 || + (distance[0] === 0 && distance[1] < 0) || + (distance[2] === 0 && distance[3] < 0) + ) { + continue; + } + if (nearestContainingItem === null) { + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + continue; + } + // closer line more relevant than closer column + const closerBefore = + distance[0] < containerDistance[0] || + (distance[0] === 0 && distance[1] < containerDistance[1]); + const closerAfter = + distance[2] < containerDistance[2] || + (distance[2] === 0 && distance[3] < containerDistance[3]); + if (closerBefore || closerAfter) { + // closer + containerDistance = distance; + nearestContainingItem = mapItem; + containerKey = i; + } + } + return containerKey; +}; + +// either add two numbers, or all matching entries in a number[] +const addHits = (aHits, bHits) => { + if (typeof aHits === "number" && typeof bHits === "number") { + return aHits + bHits; + } else if (Array.isArray(aHits) && Array.isArray(bHits)) { + return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); + } + return null; +}; + +const addNearestContainerHits = (item, itemHits, map, mapHits) => { + const container = findNearestContainer(item, map); + if (container) { + return addHits(itemHits, mapHits[container]); + } else { + return itemHits; + } +}; + +const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { + const aItems = {}; + for (const [key, itemHits] of Object.entries(aHits)) { + const item = aMap[key]; + aItems[itemKey(item)] = [itemHits, item]; + } + const bItems = {}; + for (const [key, itemHits] of Object.entries(bHits)) { + const item = bMap[key]; + bItems[itemKey(item)] = [itemHits, item]; + } + const mergedItems = {}; + for (const [key, aValue] of Object.entries(aItems)) { + let aItemHits = aValue[0]; + const aItem = aValue[1]; + const bValue = bItems[key]; + if (!bValue) { + // not an identified range in b, but might be contained by one + aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); + } else { + // is an identified range in b, so add the hits together + aItemHits = addHits(aItemHits, bValue[0]); + } + mergedItems[key] = [aItemHits, aItem]; + } + // now find the items in b that are not in a. already added matches. + for (const [key, bValue] of Object.entries(bItems)) { + let bItemHits = bValue[0]; + const bItem = bValue[1]; + if (mergedItems[key]) continue; + // not an identified range in b, but might be contained by one + bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); + mergedItems[key] = [bItemHits, bItem]; + } + + const hits = {}; + const map = {}; + + Object.values(mergedItems).forEach(([itemHits, item], i) => { + hits[i] = itemHits; + map[i] = item; + }); + + return [hits, map]; +}; + +/** + * provides a read-only view of coverage for a single file. + * The deep structure of this object is documented elsewhere. It has the following + * properties: + * + * * `path` - the file path for which coverage is being tracked + * * `statementMap` - map of statement locations keyed by statement index + * * `fnMap` - map of function metadata keyed by function index + * * `branchMap` - map of branch metadata keyed by branch index + * * `s` - hit counts for statements + * * `f` - hit count for functions + * * `b` - hit count for branches + */ +class FileCoverage { + /** + * @constructor + * @param {Object|FileCoverage|String} pathOrObj is a string that initializes + * and empty coverage object with the specified file path or a data object that + * has all the required properties for a file coverage object. + */ + constructor(pathOrObj, reportLogic = false) { + if (!pathOrObj) { + throw new Error("Coverage must be initialized with a path or an object"); + } + if (typeof pathOrObj === "string") { + this.data = emptyCoverage(pathOrObj, reportLogic); + } else if (pathOrObj instanceof FileCoverage) { + this.data = pathOrObj.data; + } else if (typeof pathOrObj === "object") { + this.data = pathOrObj; + } else { + throw new Error("Invalid argument to coverage constructor"); + } + assertValidObject(this.data); + } + + /** + * returns computed line coverage from statement coverage. + * This is a map of hits keyed by line number in the source. + */ + getLineCoverage() { + const statementMap = this.data.statementMap; + const statements = this.data.s; + const lineMap = Object.create(null); + + Object.entries(statements).forEach(([st, count]) => { + /* istanbul ignore if: is this even possible? */ + if (!statementMap[st]) { + return; + } + const { line } = statementMap[st].start; + const prevVal = lineMap[line]; + if (prevVal === undefined || prevVal < count) { + lineMap[line] = count; + } + }); + return lineMap; + } + + /** + * returns an array of uncovered line numbers. + * @returns {Array} an array of line numbers for which no hits have been + * collected. + */ + getUncoveredLines() { + const lc = this.getLineCoverage(); + const ret = []; + Object.entries(lc).forEach(([l, hits]) => { + if (hits === 0) { + ret.push(l); + } + }); + return ret; + } + + /** + * returns a map of branch coverage by source line number. + * @returns {Object} an object keyed by line number. Each object + * has a `covered`, `total` and `coverage` (percentage) property. + */ + getBranchCoverageByLine() { + const branchMap = this.branchMap; + const branches = this.b; + const ret = {}; + Object.entries(branchMap).forEach(([k, map]) => { + const line = map.line || map.loc.start.line; + const branchData = branches[k]; + ret[line] = ret[line] || []; + ret[line].push(...branchData); + }); + Object.entries(ret).forEach(([k, dataArray]) => { + const covered = dataArray.filter((item) => item > 0); + const coverage = (covered.length / dataArray.length) * 100; + ret[k] = { + covered: covered.length, + total: dataArray.length, + coverage, + }; + }); + return ret; + } + + /** + * return a JSON-serializable POJO for this file coverage object + */ + toJSON() { + return this.data; + } + + /** + * merges a second coverage object into this one, updating hit counts + * @param {FileCoverage} other - the coverage object to be merged into this one. + * Note that the other object should have the same structure as this one (same file). + */ + merge(other) { + if (other.all === true) { + return; + } + + if (this.all === true) { + this.data = other.data; + return; + } + + let [hits, map] = mergeProp( + this.s, + this.statementMap, + other.s, + other.statementMap, + ); + this.data.s = hits; + this.data.statementMap = map; + + const keyFromLocProp = (x) => keyFromLoc(x.loc); + const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); + + [hits, map] = mergeProp( + this.f, + this.fnMap, + other.f, + other.fnMap, + keyFromLocProp, + ); + this.data.f = hits; + this.data.fnMap = map; + + [hits, map] = mergeProp( + this.b, + this.branchMap, + other.b, + other.branchMap, + keyFromLocationsProp, + ); + this.data.b = hits; + this.data.branchMap = map; + + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT && other.bT) { + [hits, map] = mergeProp( + this.bT, + this.branchMap, + other.bT, + other.branchMap, + keyFromLocationsProp, + ); + this.data.bT = hits; + } + } + + computeSimpleTotals(property) { + let stats = this[property]; + + if (typeof stats === "function") { + stats = stats.call(this); + } + + const ret = { + total: Object.keys(stats).length, + covered: Object.values(stats).filter((v) => !!v).length, + skipped: 0, + }; + ret.pct = percent(ret.covered, ret.total); + return ret; + } + + computeBranchTotals(property) { + const stats = this[property]; + const ret = { total: 0, covered: 0, skipped: 0 }; + + Object.values(stats).forEach((branches) => { + ret.covered += branches.filter((hits) => hits > 0).length; + ret.total += branches.length; + }); + ret.pct = percent(ret.covered, ret.total); + return ret; + } + + /** + * resets hit counts for all statements, functions and branches + * in this coverage object resulting in zero coverage. + */ + resetHits() { + const statements = this.s; + const functions = this.f; + const branches = this.b; + const branchesTrue = this.bT; + Object.keys(statements).forEach((s) => { + statements[s] = 0; + }); + Object.keys(functions).forEach((f) => { + functions[f] = 0; + }); + Object.keys(branches).forEach((b) => { + branches[b].fill(0); + }); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (branchesTrue) { + Object.keys(branchesTrue).forEach((bT) => { + branchesTrue[bT].fill(0); + }); + } + } + + /** + * returns a CoverageSummary for this file coverage object + * @returns {CoverageSummary} + */ + toSummary() { + const ret = {}; + ret.lines = this.computeSimpleTotals("getLineCoverage"); + ret.functions = this.computeSimpleTotals("f", "fnMap"); + ret.statements = this.computeSimpleTotals("s", "statementMap"); + ret.branches = this.computeBranchTotals("b"); + // Tracking additional information about branch truthiness + // can be optionally enabled: + if (this.bT) { + ret.branchesTrue = this.computeBranchTotals("bT"); + } + return new CoverageSummary(ret); + } +} + +// expose coverage data attributes +dataProperties(FileCoverage, [ + "path", + "statementMap", + "fnMap", + "branchMap", + "s", + "f", + "b", + "bT", + "all", +]); + +module.exports = { + FileCoverage, + // exported for testing + findNearestContainer, + addHits, + addNearestContainerHits, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/percent.cjs new file mode 100644 index 00000000000..ecb468d56b9 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/percent.cjs @@ -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"; + +module.exports = function percent(covered, total) { + let tmp; + if (total > 0) { + tmp = (1000 * 100 * covered) / total; + return Math.floor(tmp / 10) / 100; + } else { + return 100.0; + } +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs new file mode 100644 index 00000000000..e69de29bb2d diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/index.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/index.cjs new file mode 100644 index 00000000000..f7aad0370c1 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/index.cjs @@ -0,0 +1,40 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * @module Exports + */ + +const Context = require("./lib/context.cjs"); +const watermarks = require("./lib/watermarks.cjs"); +const ReportBase = require("./lib/report-base.cjs"); + +module.exports = { + /** + * returns a reporting context for the supplied options + * @param {Object} [opts=null] opts + * @returns {Context} + */ + createContext(opts) { + return new Context(opts); + }, + + /** + * returns the default watermarks that would be used when not + * overridden + * @returns {Object} an object with `statements`, `functions`, `branches`, + * and `line` keys. Each value is a 2 element array that has the low and + * high watermark as percentages. + */ + getDefaultWatermarks() { + return watermarks.getDefault(); + }, + + /** + * Base class for all reports + */ + ReportBase, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/context.cjs new file mode 100644 index 00000000000..92ab1478486 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/context.cjs @@ -0,0 +1,132 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const fs = require("node:fs"); +const FileWriter = require("./file-writer.cjs"); +const XMLWriter = require("./xml-writer.cjs"); +const tree = require("./tree.cjs"); +const watermarks = require("./watermarks.cjs"); +const SummarizerFactory = require("./summarizer-factory.cjs"); + +function defaultSourceLookup(path) { + try { + return fs.readFileSync(path, "utf8"); + } catch (ex) { + throw new Error(`Unable to lookup source: ${path} (${ex.message})`); + } +} + +function normalizeWatermarks(specified = {}) { + Object.entries(watermarks.getDefault()).forEach(([k, value]) => { + const specValue = specified[k]; + if (!Array.isArray(specValue) || specValue.length !== 2) { + specified[k] = value; + } + }); + + return specified; +} + +/** + * A reporting context that is passed to report implementations + * @param {Object} [opts=null] opts options + * @param {String} [opts.dir='coverage'] opts.dir the reporting directory + * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for + * statements, lines, branches and functions + * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a + * function that returns source code given a file path. Defaults to + * filesystem lookups based on path. + * @constructor + */ +class Context { + constructor(opts) { + this.dir = opts.dir || "coverage"; + this.watermarks = normalizeWatermarks(opts.watermarks); + this.sourceFinder = opts.sourceFinder || defaultSourceLookup; + this._summarizerFactory = new SummarizerFactory( + opts.coverageMap, + opts.defaultSummarizer, + ); + this.data = {}; + } + + /** + * returns a FileWriter implementation for reporting use. Also available + * as the `writer` property on the context. + * @returns {Writer} + */ + getWriter() { + return this.writer; + } + + /** + * returns the source code for the specified file path or throws if + * the source could not be found. + * @param {String} filePath the file path as found in a file coverage object + * @returns {String} the source code + */ + getSource(filePath) { + return this.sourceFinder(filePath); + } + + /** + * returns the coverage class given a coverage + * types and a percentage value. + * @param {String} type - the coverage type, one of `statements`, `functions`, + * `branches`, or `lines` + * @param {Number} value - the percentage value + * @returns {String} one of `high`, `medium` or `low` + */ + classForPercent(type, value) { + const watermarks = this.watermarks[type]; + if (!watermarks) { + return "unknown"; + } + if (value < watermarks[0]) { + return "low"; + } + if (value >= watermarks[1]) { + return "high"; + } + return "medium"; + } + + /** + * returns an XML writer for the supplied content writer + * @param {ContentWriter} contentWriter the content writer to which the returned XML writer + * writes data + * @returns {XMLWriter} + */ + getXMLWriter(contentWriter) { + return new XMLWriter(contentWriter); + } + + /** + * returns a full visitor given a partial one. + * @param {Object} partialVisitor a partial visitor only having the functions of + * interest to the caller. These functions are called with a scope that is the + * supplied object. + * @returns {Visitor} + */ + getVisitor(partialVisitor) { + return new tree.Visitor(partialVisitor); + } + + getTree(name = "defaultSummarizer") { + return this._summarizerFactory[name]; + } +} + +Object.defineProperty(Context.prototype, "writer", { + enumerable: true, + get() { + if (!this.data.writer) { + this.data.writer = new FileWriter(this.dir); + } + return this.data.writer; + }, +}); + +module.exports = Context; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/file-writer.cjs new file mode 100644 index 00000000000..658de8f06f8 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/file-writer.cjs @@ -0,0 +1,184 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require("node:path"); +const fs = require("node:fs"); +const { mkdir } = require("node:fs/promises"); + +/** + * Base class for writing content + * @class ContentWriter + * @constructor + */ +class ContentWriter { + /** + * returns the colorized version of a string. Typically, + * content writers that write to files will return the + * same string and ones writing to a tty will wrap it in + * appropriate escape sequences. + * @param {String} str the string to colorize + * @param {String} clazz one of `high`, `medium` or `low` + * @returns {String} the colorized form of the string + */ + colorize(str /*, clazz*/) { + return str; + } + + /** + * writes a string appended with a newline to the destination + * @param {String} str the string to write + */ + println(str) { + this.write(`${str}\n`); + } + + /** + * closes this content writer. Should be called after all writes are complete. + */ + close() {} +} + +/** + * a content writer that writes to a file + * @param {Number} fd - the file descriptor + * @extends ContentWriter + * @constructor + */ +class FileContentWriter extends ContentWriter { + constructor(fd) { + super(); + + this.fd = fd; + } + + write(str) { + fs.writeSync(this.fd, str); + } + + close() { + fs.closeSync(this.fd); + } +} + +// allow stdout to be captured for tests. +let capture = false; +let output = ""; + +/** + * a content writer that writes to the console + * @extends ContentWriter + * @constructor + */ +class ConsoleWriter extends ContentWriter { + write(str) { + if (capture) { + output += str; + } else { + process.stdout.write(str); + } + } + + colorize(str, clazz) { + const colors = { + low: "31;1", + medium: "33;1", + high: "32;1", + }; + + return str; + } +} + +/** + * utility for writing files under a specific directory + * @class FileWriter + * @param {String} baseDir the base directory under which files should be written + * @constructor + */ +class FileWriter { + constructor(baseDir) { + if (!baseDir) { + throw new Error("baseDir must be specified"); + } + this.baseDir = baseDir; + } + + /** + * static helpers for capturing stdout report output; + * super useful for tests! + */ + static startCapture() { + capture = true; + } + + static stopCapture() { + capture = false; + } + + static getOutput() { + return output; + } + + static resetOutput() { + output = ""; + } + + /** + * returns a FileWriter that is rooted at the supplied subdirectory + * @param {String} subdir the subdirectory under which to root the + * returned FileWriter + * @returns {FileWriter} + */ + writerForDir(subdir) { + if (path.isAbsolute(subdir)) { + throw new Error( + `Cannot create subdir writer for absolute path: ${subdir}`, + ); + } + return new FileWriter(`${this.baseDir}/${subdir}`); + } + + /** + * copies a file from a source directory to a destination name + * @param {String} source path to source file + * @param {String} dest relative path to destination file + * @param {String} [header=undefined] optional text to prepend to destination + * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) + */ + copyFile(source, dest, header) { + if (path.isAbsolute(dest)) { + throw new Error(`Cannot write to absolute path: ${dest}`); + } + dest = path.resolve(this.baseDir, dest); + mkdir(path.dirname(dest), { recursive: true }); + let contents; + if (header) { + contents = header + fs.readFileSync(source, "utf8"); + } else { + contents = fs.readFileSync(source); + } + fs.writeFileSync(dest, contents); + } + + /** + * returns a content writer for writing content to the supplied file. + * @param {String|null} file the relative path to the file or the special + * values `"-"` or `null` for writing to the console + * @returns {ContentWriter} + */ + writeFile(file) { + if (file === null || file === "-") { + return new ConsoleWriter(); + } + if (path.isAbsolute(file)) { + throw new Error(`Cannot write to absolute path: ${file}`); + } + file = path.resolve(this.baseDir, file); + mkdir(path.dirname(file), { recursive: true }); + return new FileContentWriter(fs.openSync(file, "w")); + } +} + +module.exports = FileWriter; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/path.cjs new file mode 100644 index 00000000000..89f8033883b --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/path.cjs @@ -0,0 +1,169 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const path = require("node:path"); +let parsePath = path.parse; +let SEP = path.sep; +const origParser = parsePath; +const origSep = SEP; + +function makeRelativeNormalizedPath(str, sep) { + const parsed = parsePath(str); + let root = parsed.root; + let dir; + let file = parsed.base; + let quoted; + let pos; + + // handle a weird windows case separately + if (sep === "\\") { + pos = root.indexOf(":\\"); + if (pos >= 0) { + root = root.substring(0, pos + 2); + } + } + dir = parsed.dir.substring(root.length); + + if (str === "") { + return []; + } + + if (sep !== "/") { + quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); + dir = dir.replace(quoted, "/"); + file = file.replace(quoted, "/"); // excessively paranoid? + } + + if (dir !== "") { + dir = `${dir}/${file}`; + } else { + dir = file; + } + if (dir.substring(0, 1) === "/") { + dir = dir.substring(1); + } + dir = dir.split(/\/+/); + return dir; +} + +class Path { + constructor(strOrArray) { + if (Array.isArray(strOrArray)) { + this.v = strOrArray; + } else if (typeof strOrArray === "string") { + this.v = makeRelativeNormalizedPath(strOrArray, SEP); + } else { + throw new Error( + `Invalid Path argument must be string or array:${strOrArray}`, + ); + } + } + + toString() { + return this.v.join("/"); + } + + hasParent() { + return this.v.length > 0; + } + + parent() { + if (!this.hasParent()) { + throw new Error("Unable to get parent for 0 elem path"); + } + const p = this.v.slice(); + p.pop(); + return new Path(p); + } + + elements() { + return this.v.slice(); + } + + name() { + return this.v.slice(-1)[0]; + } + + contains(other) { + let i; + if (other.length > this.length) { + return false; + } + for (i = 0; i < other.length; i += 1) { + if (this.v[i] !== other.v[i]) { + return false; + } + } + return true; + } + + ancestorOf(other) { + return other.contains(this) && other.length !== this.length; + } + + descendantOf(other) { + return this.contains(other) && other.length !== this.length; + } + + commonPrefixPath(other) { + const len = this.length > other.length ? other.length : this.length; + let i; + const ret = []; + + for (i = 0; i < len; i += 1) { + if (this.v[i] === other.v[i]) { + ret.push(this.v[i]); + } else { + break; + } + } + return new Path(ret); + } + + static compare(a, b) { + const al = a.length; + const bl = b.length; + + if (al < bl) { + return -1; + } + + if (al > bl) { + return 1; + } + + const astr = a.toString(); + const bstr = b.toString(); + return astr < bstr ? -1 : astr > bstr ? 1 : 0; + } +} + +["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { + Object.defineProperty(Path.prototype, fn, { + value(...args) { + return this.v[fn](...args); + }, + }); +}); + +Object.defineProperty(Path.prototype, "length", { + enumerable: true, + get() { + return this.v.length; + }, +}); + +module.exports = Path; +Path.tester = { + setParserAndSep(p, sep) { + parsePath = p; + SEP = sep; + }, + reset() { + parsePath = origParser; + SEP = origSep; + }, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/report-base.cjs new file mode 100644 index 00000000000..1575121b53b --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/report-base.cjs @@ -0,0 +1,16 @@ +"use strict"; + +// TODO: switch to class private field when targeting node.js 12 +const _summarizer = Symbol("ReportBase.#summarizer"); + +class ReportBase { + constructor(opts = {}) { + this[_summarizer] = opts.summarizer; + } + + execute(context) { + context.getTree(this[_summarizer]).visit(this, context); + } +} + +module.exports = ReportBase; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/summarizer-factory.cjs new file mode 100644 index 00000000000..cb2c429bc9a --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/summarizer-factory.cjs @@ -0,0 +1,284 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +const coverage = require("../../lib-coverage/index.cjs"); +const Path = require("./path.cjs"); +const { BaseNode, BaseTree } = require("./tree.cjs"); + +class ReportNode extends BaseNode { + constructor(path, fileCoverage) { + super(); + + this.path = path; + this.parent = null; + this.fileCoverage = fileCoverage; + this.children = []; + } + + static createRoot(children) { + const root = new ReportNode(new Path([])); + + children.forEach((child) => { + root.addChild(child); + }); + + return root; + } + + addChild(child) { + child.parent = this; + this.children.push(child); + } + + asRelative(p) { + if (p.substring(0, 1) === "/") { + return p.substring(1); + } + return p; + } + + getQualifiedName() { + return this.asRelative(this.path.toString()); + } + + getRelativeName() { + const parent = this.getParent(); + const myPath = this.path; + let relPath; + let i; + const parentPath = parent ? parent.path : new Path([]); + if (parentPath.ancestorOf(myPath)) { + relPath = new Path(myPath.elements()); + for (i = 0; i < parentPath.length; i += 1) { + relPath.shift(); + } + return this.asRelative(relPath.toString()); + } + return this.asRelative(this.path.toString()); + } + + getParent() { + return this.parent; + } + + getChildren() { + return this.children; + } + + isSummary() { + return !this.fileCoverage; + } + + getFileCoverage() { + return this.fileCoverage; + } + + getCoverageSummary(filesOnly) { + const cacheProp = `c_${filesOnly ? "files" : "full"}`; + let summary; + + if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { + return this[cacheProp]; + } + + if (!this.isSummary()) { + summary = this.getFileCoverage().toSummary(); + } else { + let count = 0; + summary = coverage.createCoverageSummary(); + this.getChildren().forEach((child) => { + if (filesOnly && child.isSummary()) { + return; + } + count += 1; + summary.merge(child.getCoverageSummary(filesOnly)); + }); + if (count === 0 && filesOnly) { + summary = null; + } + } + this[cacheProp] = summary; + return summary; + } +} + +class ReportTree extends BaseTree { + constructor(root, childPrefix) { + super(root); + + const maybePrefix = (node) => { + if (childPrefix && !node.isRoot()) { + node.path.unshift(childPrefix); + } + }; + this.visit({ + onDetail: maybePrefix, + onSummary(node) { + maybePrefix(node); + node.children.sort((a, b) => { + const astr = a.path.toString(); + const bstr = b.path.toString(); + return astr < bstr + ? -1 + : astr > bstr + ? 1 + : /* istanbul ignore next */ 0; + }); + }, + }); + } +} + +function findCommonParent(paths) { + return paths.reduce( + (common, path) => common.commonPrefixPath(path), + paths[0] || new Path([]), + ); +} + +function findOrCreateParent(parentPath, nodeMap, created = () => {}) { + let parent = nodeMap[parentPath.toString()]; + + if (!parent) { + parent = new ReportNode(parentPath); + nodeMap[parentPath.toString()] = parent; + created(parentPath, parent); + } + + return parent; +} + +function toDirParents(list) { + const nodeMap = Object.create(null); + list.forEach((o) => { + const parent = findOrCreateParent(o.path.parent(), nodeMap); + parent.addChild(new ReportNode(o.path, o.fileCoverage)); + }); + + return Object.values(nodeMap); +} + +function addAllPaths(topPaths, nodeMap, path, node) { + const parent = findOrCreateParent( + path.parent(), + nodeMap, + (parentPath, parent) => { + if (parentPath.hasParent()) { + addAllPaths(topPaths, nodeMap, parentPath, parent); + } else { + topPaths.push(parent); + } + }, + ); + + parent.addChild(node); +} + +function foldIntoOneDir(node, parent) { + const { children } = node; + if (children.length === 1 && !children[0].fileCoverage) { + children[0].parent = parent; + return foldIntoOneDir(children[0], parent); + } + node.children = children.map((child) => foldIntoOneDir(child, node)); + return node; +} + +function pkgSummaryPrefix(dirParents, commonParent) { + if (!dirParents.some((dp) => dp.path.length === 0)) { + return; + } + + if (commonParent.length === 0) { + return "root"; + } + + return commonParent.name(); +} + +class SummarizerFactory { + constructor(coverageMap, defaultSummarizer = "pkg") { + this._coverageMap = coverageMap; + this._defaultSummarizer = defaultSummarizer; + this._initialList = coverageMap.files().map((filePath) => ({ + filePath, + path: new Path(filePath), + fileCoverage: coverageMap.fileCoverageFor(filePath), + })); + this._commonParent = findCommonParent( + this._initialList.map((o) => o.path.parent()), + ); + if (this._commonParent.length > 0) { + this._initialList.forEach((o) => { + o.path.splice(0, this._commonParent.length); + }); + } + } + + get defaultSummarizer() { + return this[this._defaultSummarizer]; + } + + get flat() { + if (!this._flat) { + this._flat = new ReportTree( + ReportNode.createRoot( + this._initialList.map( + (node) => new ReportNode(node.path, node.fileCoverage), + ), + ), + ); + } + + return this._flat; + } + + _createPkg() { + const dirParents = toDirParents(this._initialList); + if (dirParents.length === 1) { + return new ReportTree(dirParents[0]); + } + + return new ReportTree( + ReportNode.createRoot(dirParents), + pkgSummaryPrefix(dirParents, this._commonParent), + ); + } + + get pkg() { + if (!this._pkg) { + this._pkg = this._createPkg(); + } + + return this._pkg; + } + + _createNested() { + const nodeMap = Object.create(null); + const topPaths = []; + this._initialList.forEach((o) => { + const node = new ReportNode(o.path, o.fileCoverage); + addAllPaths(topPaths, nodeMap, o.path, node); + }); + + const topNodes = topPaths.map((node) => foldIntoOneDir(node)); + if (topNodes.length === 1) { + return new ReportTree(topNodes[0]); + } + + return new ReportTree(ReportNode.createRoot(topNodes)); + } + + get nested() { + if (!this._nested) { + this._nested = this._createNested(); + } + + return this._nested; + } +} + +module.exports = SummarizerFactory; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/tree.cjs new file mode 100644 index 00000000000..6bac8b98ea4 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/tree.cjs @@ -0,0 +1,137 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * An object with methods that are called during the traversal of the coverage tree. + * A visitor has the following methods that are called during tree traversal. + * + * * `onStart(root, state)` - called before traversal begins + * * `onSummary(node, state)` - called for every summary node + * * `onDetail(node, state)` - called for every detail node + * * `onSummaryEnd(node, state)` - called after all children have been visited for + * a summary node. + * * `onEnd(root, state)` - called after traversal ends + * + * @param delegate - a partial visitor that only implements the methods of interest + * The visitor object supplies the missing methods as noops. For example, reports + * that only need the final coverage summary need implement `onStart` and nothing + * else. Reports that use only detailed coverage information need implement `onDetail` + * and nothing else. + * @constructor + */ +class Visitor { + constructor(delegate) { + this.delegate = delegate; + } +} + +["Start", "End", "Summary", "SummaryEnd", "Detail"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(Visitor.prototype, fn, { + writable: true, + value(node, state) { + if (typeof this.delegate[fn] === "function") { + this.delegate[fn](node, state); + } + }, + }); + }); + +class CompositeVisitor extends Visitor { + constructor(visitors) { + super(); + + if (!Array.isArray(visitors)) { + visitors = [visitors]; + } + this.visitors = visitors.map((v) => { + if (v instanceof Visitor) { + return v; + } + return new Visitor(v); + }); + } +} + +["Start", "Summary", "SummaryEnd", "Detail", "End"] + .map((k) => `on${k}`) + .forEach((fn) => { + Object.defineProperty(CompositeVisitor.prototype, fn, { + value(node, state) { + this.visitors.forEach((v) => { + v[fn](node, state); + }); + }, + }); + }); + +class BaseNode { + isRoot() { + return !this.getParent(); + } + + /** + * visit all nodes depth-first from this node down. Note that `onStart` + * and `onEnd` are never called on the visitor even if the current + * node is the root of the tree. + * @param visitor a full visitor that is called during tree traversal + * @param state optional state that is passed around + */ + visit(visitor, state) { + if (this.isSummary()) { + visitor.onSummary(this, state); + } else { + visitor.onDetail(this, state); + } + + this.getChildren().forEach((child) => { + child.visit(visitor, state); + }); + + if (this.isSummary()) { + visitor.onSummaryEnd(this, state); + } + } +} + +/** + * abstract base class for a coverage tree. + * @constructor + */ +class BaseTree { + constructor(root) { + this.root = root; + } + + /** + * returns the root node of the tree + */ + getRoot() { + return this.root; + } + + /** + * visits the tree depth-first with the supplied partial visitor + * @param visitor - a potentially partial visitor + * @param state - the state to be passed around during tree traversal + */ + visit(visitor, state) { + if (!(visitor instanceof Visitor)) { + visitor = new Visitor(visitor); + } + visitor.onStart(this.getRoot(), state); + this.getRoot().visit(visitor, state); + visitor.onEnd(this.getRoot(), state); + } +} + +module.exports = { + BaseTree, + BaseNode, + Visitor, + CompositeVisitor, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/watermarks.cjs new file mode 100644 index 00000000000..0be610017a9 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/watermarks.cjs @@ -0,0 +1,15 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +module.exports = { + getDefault() { + return { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], + }; + }, +}; diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/lib/xml-writer.cjs new file mode 100644 index 00000000000..aea68a1b53f --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage/lib-report/lib/xml-writer.cjs @@ -0,0 +1,90 @@ +"use strict"; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const INDENT = " "; + +function attrString(attrs) { + return Object.entries(attrs || {}) + .map(([k, v]) => ` ${k}="${v}"`) + .join(""); +} + +/** + * a utility class to produce well-formed, indented XML + * @param {ContentWriter} contentWriter the content writer that this utility wraps + * @constructor + */ +class XMLWriter { + constructor(contentWriter) { + this.cw = contentWriter; + this.stack = []; + } + + indent(str) { + return this.stack.map(() => INDENT).join("") + str; + } + + /** + * writes the opening XML tag with the supplied attributes + * @param {String} name tag name + * @param {Object} [attrs=null] attrs attributes for the tag + */ + openTag(name, attrs) { + const str = this.indent(`<${name + attrString(attrs)}>`); + this.cw.println(str); + this.stack.push(name); + } + + /** + * closes an open XML tag. + * @param {String} name - tag name to close. This must match the writer's + * notion of the tag that is currently open. + */ + closeTag(name) { + if (this.stack.length === 0) { + throw new Error(`Attempt to close tag ${name} when not opened`); + } + const stashed = this.stack.pop(); + const str = ``; + + if (stashed !== name) { + throw new Error( + `Attempt to close tag ${name} when ${stashed} was the one open`, + ); + } + this.cw.println(this.indent(str)); + } + + /** + * writes a tag and its value opening and closing it at the same time + * @param {String} name tag name + * @param {Object} [attrs=null] attrs tag attributes + * @param {String} [content=null] content optional tag content + */ + inlineTag(name, attrs, content) { + let str = "<" + name + attrString(attrs); + if (content) { + str += `>${content}`; + } else { + str += "/>"; + } + str = this.indent(str); + this.cw.println(str); + } + + /** + * closes all open tags and ends the document + */ + closeAll() { + this.stack + .slice() + .reverse() + .forEach((name) => { + this.closeTag(name); + }); + } +} + +module.exports = XMLWriter; From 39ce891e87b68db7615104f3bc755880068cebc5 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:08:57 +0100 Subject: [PATCH 18/32] delete test file --- v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs b/v-next/hardhat-vendored/src/coverage/lib-report/ciao.cjs deleted file mode 100644 index e69de29bb2d..00000000000 From c6f1e72316722a2f17be2311f33ab17acd53f924 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:13:18 +0100 Subject: [PATCH 19/32] remove dist folder --- v-next/hardhat-vendored/.gitignore | 8 +- .../hardhat-vendored/dist/src/copy-assets.js | 11 - .../dist/src/coverage/html-escaper/index.cjs | 23 -- .../dist/src/coverage/index.js | 7 - .../src/coverage/istanbul-reports/index.cjs | 23 -- .../istanbul-reports/lib/html/annotator.cjs | 249 ----------- .../istanbul-reports/lib/html/assets/base.css | 224 ---------- .../lib/html/assets/block-navigation.js | 86 ---- .../lib/html/assets/favicon.png | Bin 445 -> 0 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 138 -> 0 bytes .../lib/html/assets/sorter.js | 209 ---------- .../lib/html/assets/vendor/prettify.css | 1 - .../lib/html/assets/vendor/prettify.js | 1 - .../istanbul-reports/lib/html/index.cjs | 339 --------------- .../lib/html/insertion-text.cjs | 103 ----- .../dist/src/coverage/lib-coverage/index.cjs | 62 --- .../lib-coverage/lib/coverage-map.cjs | 115 ------ .../lib-coverage/lib/coverage-summary.cjs | 101 ----- .../lib-coverage/lib/data-properties.cjs | 12 - .../lib-coverage/lib/file-coverage.cjs | 387 ------------------ .../src/coverage/lib-coverage/lib/percent.cjs | 16 - .../dist/src/coverage/lib-report/ciao.cjs | 3 - .../dist/src/coverage/lib-report/index.cjs | 36 -- .../src/coverage/lib-report/lib/context.cjs | 119 ------ .../coverage/lib-report/lib/file-writer.cjs | 165 -------- .../dist/src/coverage/lib-report/lib/path.cjs | 148 ------- .../coverage/lib-report/lib/report-base.cjs | 13 - .../lib-report/lib/summarizer-factory.cjs | 224 ---------- .../dist/src/coverage/lib-report/lib/tree.cjs | 126 ------ .../coverage/lib-report/lib/watermarks.cjs | 16 - .../coverage/lib-report/lib/xml-writer.cjs | 81 ---- .../dist/src/coverage/types.js | 2 - .../node_modules/@types/bn.js | 1 - 33 files changed, 4 insertions(+), 2907 deletions(-) delete mode 100644 v-next/hardhat-vendored/dist/src/copy-assets.js delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/index.js delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs delete mode 100644 v-next/hardhat-vendored/dist/src/coverage/types.js delete mode 120000 v-next/hardhat-vendored/node_modules/@types/bn.js diff --git a/v-next/hardhat-vendored/.gitignore b/v-next/hardhat-vendored/.gitignore index c8607fe252d..63488e0e6e0 100644 --- a/v-next/hardhat-vendored/.gitignore +++ b/v-next/hardhat-vendored/.gitignore @@ -13,7 +13,7 @@ coverage # all the tmp folders in the fixture projects /test/fixture-projects/tmp/ -!*.js -!*.cjs -!*.css -!*.png +!src/**/*.js +!src/**/*.cjs +!src/**/*.css +!src/**/*.png diff --git a/v-next/hardhat-vendored/dist/src/copy-assets.js b/v-next/hardhat-vendored/dist/src/copy-assets.js deleted file mode 100644 index af80157c693..00000000000 --- a/v-next/hardhat-vendored/dist/src/copy-assets.js +++ /dev/null @@ -1,11 +0,0 @@ -import { cp } from "node:fs/promises"; -import path from "node:path"; -async function copyFolder(from, to) { - const src = path.resolve(from); - const dest = path.resolve(to); - await cp(src, dest, { recursive: true, force: true }); - console.log(`Copied folder from ${src} -> ${dest}`); -} -// eslint-disable-next-line no-restricted-syntax -- allow in this post build script -await copyFolder(path.resolve(process.cwd(), "src", "coverage", "istanbul-reports", "lib", "html", "assets"), path.resolve(process.cwd(), "dist", "src", "coverage", "istanbul-reports", "lib", "html", "assets")); -//# sourceMappingURL=copy-assets.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs deleted file mode 100644 index 1f0f029ec88..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/html-escaper/index.cjs +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -const { replace } = ""; -// escape -const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; -const ca = /[&<>'"]/g; -const esca = { - "&": "&", - "<": "<", - ">": ">", - "'": "'", - '"': """, -}; -const pe = (m) => esca[m]; -/** - * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. - * @param {string} es the input to safely escape - * @returns {string} the escaped input, and it **throws** an error if - * the input type is unexpected, except for boolean and numbers, - * converted as string. - */ -const escape = (es) => replace.call(es, ca, pe); -exports.escape = escape; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/index.js b/v-next/hardhat-vendored/dist/src/coverage/index.js deleted file mode 100644 index 4e2633774c5..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import libCoverage from "./lib-coverage/index.cjs"; -export { libCoverage }; -import libReport from "./lib-report/index.cjs"; -export { libReport }; -import reports from "./istanbul-reports/index.cjs"; -export { reports }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs deleted file mode 100644 index ddfb1ef1c6d..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/index.cjs +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); -module.exports = { - create(name, cfg) { - cfg = cfg || {}; - let Cons; - try { - Cons = require(path.join(__dirname, "lib", name, "index.cjs")); - } - catch (e) { - if (e.code !== "MODULE_NOT_FOUND") { - throw e; - } - Cons = require(name); - } - return new Cons(cfg); - }, -}; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs deleted file mode 100644 index cda3f88caf1..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/annotator.cjs +++ /dev/null @@ -1,249 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const InsertionText = require("./insertion-text.cjs"); -const lt = "\u0001"; -const gt = "\u0002"; -const RE_LT = //g; -const RE_AMP = /&/g; -var RE_lt = /\u0001/g; -var RE_gt = /\u0002/g; -function title(str) { - return ' title="' + str + '" '; -} -function customEscape(text) { - text = String(text); - return text - .replace(RE_AMP, "&") - .replace(RE_LT, "<") - .replace(RE_GT, ">") - .replace(RE_lt, "<") - .replace(RE_gt, ">"); -} -function annotateLines(fileCoverage, structuredText) { - const lineStats = fileCoverage.getLineCoverage(); - if (!lineStats) { - return; - } - Object.entries(lineStats).forEach(([lineNumber, count]) => { - if (structuredText[lineNumber]) { - structuredText[lineNumber].covered = count > 0 ? "yes" : "no"; - structuredText[lineNumber].hits = count; - } - }); -} -function annotateStatements(fileCoverage, structuredText) { - const statementStats = fileCoverage.s; - const statementMeta = fileCoverage.statementMap; - Object.entries(statementStats).forEach(([stName, count]) => { - const meta = statementMeta[stName]; - const type = count > 0 ? "yes" : "no"; - const startCol = meta.start.column; - let endCol = meta.end.column + 1; - const startLine = meta.start.line; - const endLine = meta.end.line; - const openSpan = lt + - 'span class="' + - (meta.skip ? "cstat-skip" : "cstat-no") + - '"' + - title("statement not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); - } - }); -} -function annotateFunctions(fileCoverage, structuredText) { - const fnStats = fileCoverage.f; - const fnMeta = fileCoverage.fnMap; - if (!fnStats) { - return; - } - Object.entries(fnStats).forEach(([fName, count]) => { - const meta = fnMeta[fName]; - const type = count > 0 ? "yes" : "no"; - // Some versions of the instrumenter in the wild populate 'func' - // but not 'decl': - const decl = meta.decl || meta.loc; - const startCol = decl.start.column; - let endCol = decl.end.column + 1; - const startLine = decl.start.line; - const endLine = decl.end.line; - const openSpan = lt + - 'span class="' + - (meta.skip ? "fstat-skip" : "fstat-no") + - '"' + - title("function not covered") + - gt; - const closeSpan = lt + "/span" + gt; - let text; - if (type === "no" && structuredText[startLine]) { - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); - } - }); -} -function annotateBranches(fileCoverage, structuredText) { - const branchStats = fileCoverage.b; - const branchMeta = fileCoverage.branchMap; - if (!branchStats) { - return; - } - Object.entries(branchStats).forEach(([branchName, branchArray]) => { - const sumCount = branchArray.reduce((p, n) => p + n, 0); - const metaArray = branchMeta[branchName].locations; - let i; - let count; - let meta; - let startCol; - let endCol; - let startLine; - let endLine; - let openSpan; - let closeSpan; - let text; - // only highlight if partial branches are missing or if there is a - // single uncovered branch. - if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) { - // Need to recover the metaArray placeholder item to count an implicit else - if ( - // Check if the branch is a conditional if branch. - branchMeta[branchName].type === "if" && - // Check if the branch has an implicit else. - branchArray.length === 2 && - // Check if the implicit else branch is unaccounted for. - metaArray.length === 1 && - // Check if the implicit else branch is uncovered. - branchArray[1] === 0) { - metaArray[1] = { - start: {}, - end: {}, - }; - } - for (i = 0; i < branchArray.length && i < metaArray.length; i += 1) { - count = branchArray[i]; - meta = metaArray[i]; - startCol = meta.start.column; - endCol = meta.end.column + 1; - startLine = meta.start.line; - endLine = meta.end.line; - openSpan = - lt + - 'span class="branch-' + - i + - " " + - (meta.skip ? "cbranch-skip" : "cbranch-no") + - '"' + - title("branch not covered") + - gt; - closeSpan = lt + "/span" + gt; - // If the branch is an implicit else from an if statement, - // then the coverage report won't show a statistic. - // Therefore, the previous branch will be used to report that - // there is no coverage on that implicit branch. - if (count === 0 && - startLine === undefined && - branchMeta[branchName].type === "if") { - const prevMeta = metaArray[i - 1]; - startCol = prevMeta.start.column; - endCol = prevMeta.end.column + 1; - startLine = prevMeta.start.line; - endLine = prevMeta.end.line; - } - if (count === 0 && structuredText[startLine]) { - //skip branches taken - if (endLine !== startLine) { - endCol = structuredText[startLine].text.originalLength(); - } - text = structuredText[startLine].text; - if (branchMeta[branchName].type === "if") { - // 'if' is a special case - // since the else branch might not be visible, being nonexistent - text.insertAt(startCol, lt + - 'span class="' + - (meta.skip ? "skip-if-branch" : "missing-if-branch") + - '"' + - title((i === 0 ? "if" : "else") + " path not taken") + - gt + - (i === 0 ? "I" : "E") + - lt + - "/span" + - gt, true, false); - } - else { - text.wrap(startCol, openSpan, startCol < endCol ? endCol : text.originalLength(), closeSpan); - } - } - } - } - }); -} -function annotateSourceCode(fileCoverage, sourceStore) { - let codeArray; - let lineCoverageArray; - try { - const sourceText = sourceStore.getSource(fileCoverage.path); - const code = sourceText.split(/(?:\r?\n)|\r/); - let count = 0; - const structured = code.map((str) => { - count += 1; - return { - line: count, - covered: "neutral", - hits: 0, - text: new InsertionText(str, true), - }; - }); - structured.unshift({ - line: 0, - covered: null, - text: new InsertionText(""), - }); - annotateLines(fileCoverage, structured); - //note: order is important, since statements typically result in spanning the whole line and doing branches late - //causes mismatched tags - annotateBranches(fileCoverage, structured); - annotateFunctions(fileCoverage, structured); - annotateStatements(fileCoverage, structured); - structured.shift(); - codeArray = structured.map((item) => customEscape(item.text.toString()) || " "); - lineCoverageArray = structured.map((item) => ({ - covered: item.covered, - hits: item.hits > 0 ? item.hits + "x" : " ", - })); - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: structured.length, - }; - } - catch (ex) { - codeArray = [ex.message]; - lineCoverageArray = [{ covered: "no", hits: 0 }]; - String(ex.stack || "") - .split(/\r?\n/) - .forEach((line) => { - codeArray.push(line); - lineCoverageArray.push({ covered: "no", hits: 0 }); - }); - return { - annotatedCode: codeArray, - lineCoverage: lineCoverageArray, - maxLines: codeArray.length, - }; - } -} -module.exports = annotateSourceCode; -//# sourceMappingURL=annotator.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css deleted file mode 100644 index f418035b469..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/base.css +++ /dev/null @@ -1,224 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* yellow */ -.cbranch-no { background: yellow !important; color: #111; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -.highlighted, -.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ - background: #C21F39 !important; -} -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -.medium .chart { border:1px solid #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } - -.coverage-summary td.empty { - opacity: .5; - padding-top: 4px; - padding-bottom: 4px; - line-height: 1; - color: #888; -} - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js deleted file mode 100644 index eb527848ee7..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js +++ /dev/null @@ -1,86 +0,0 @@ -var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; - - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selector that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } - - makeCurrent(nextIndex); - } - - function goToNext() { - var nextIndex = 0; - - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } - - makeCurrent(nextIndex); - } - - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } - - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; -})(); -window.addEventListener('keydown', jumpToCode); diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/favicon.png deleted file mode 100644 index c1525b811a167671e9de1fa78aab9f5c0b61cef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js deleted file mode 100644 index 83122f78ace..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/sorter.js +++ /dev/null @@ -1,209 +0,0 @@ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - - // Try to create a RegExp from the searchValue. If it fails (invalid regex), - // it will be treated as a plain text search - let searchRegex; - try { - searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive - } catch (error) { - searchRegex = null; - } - - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - let isMatch = false; - - if (searchRegex) { - // If a valid regex was created, use it for matching - isMatch = searchRegex.test(row.textContent); - } else { - // Otherwise, fall back to the original plain text search - isMatch = row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()); - } - - row.style.display = isMatch ? '' : 'none'; - } - } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css deleted file mode 100644 index b317a7cda31..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js deleted file mode 100644 index ef51e038668..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs deleted file mode 100644 index a2390d3ad04..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/index.cjs +++ /dev/null @@ -1,339 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const path = require("node:path"); -const html = require("../../../html-escaper/index.cjs"); -const ReportBase = require("../../../lib-report/lib/report-base.cjs"); -const annotator = require("./annotator.cjs"); -function htmlHead(details) { - return ` - - Code coverage report for ${html.escape(details.entity)} - - - - - - - - `; -} -function headerTemplate(details) { - function metricsTemplate({ pct, covered, total }, kind) { - return ` -
- ${pct}% - ${kind} - ${covered}/${total} -
- `; - } - function skipTemplate(metrics) { - const statements = metrics.statements.skipped; - const branches = metrics.branches.skipped; - const functions = metrics.functions.skipped; - const countLabel = (c, label, plural) => c === 0 ? [] : `${c} ${label}${c === 1 ? "" : plural}`; - const skips = [].concat(countLabel(statements, "statement", "s"), countLabel(functions, "function", "s"), countLabel(branches, "branch", "es")); - if (skips.length === 0) { - return ""; - } - return ` -
- ${skips.join(", ")} - Ignored      -
- `; - } - return ` - - -${htmlHead(details)} - -
-
-

${details.pathHtml}

-
- ${metricsTemplate(details.metrics.statements, "Statements")} - ${metricsTemplate(details.metrics.branches, "Branches")} - ${metricsTemplate(details.metrics.functions, "Functions")} - ${metricsTemplate(details.metrics.lines, "Lines")} - ${skipTemplate(details.metrics)} -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
- `; -} -function footerTemplate(details) { - return ` -
-
- - - - - - - - `; -} -function detailTemplate(data) { - const lineNumbers = new Array(data.maxLines).fill().map((_, i) => i + 1); - const lineLink = (num) => `${num}`; - const lineCount = (line) => `${line.hits}`; - /* This is rendered in a `
`, need control of all whitespace. */
-    return [
-        "",
-        `${lineNumbers.map(lineLink).join("\n")}`,
-        `${data.lineCoverage
-            .map(lineCount)
-            .join("\n")}`,
-        `
${data.annotatedCode.join("\n")}
`, - "", - ].join(""); -} -const summaryTableHeader = [ - '
', - '', - "", - "", - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - "", - "", - "", -].join("\n"); -function summaryLineTemplate(details) { - const { reportClasses, metrics, file, output } = details; - const percentGraph = (pct) => { - if (!isFinite(pct)) { - return ""; - } - const cls = ["cover-fill"]; - if (pct === 100) { - cls.push("cover-full"); - } - pct = Math.floor(pct); - return [ - `
`, - `
`, - ].join(""); - }; - const summaryType = (type, showGraph = false) => { - const info = metrics[type]; - const reportClass = reportClasses[type]; - const result = [ - ``, - ``, - ]; - if (showGraph) { - result.unshift(``); - } - return result; - }; - return [] - .concat("", ``, summaryType("statements", true), summaryType("branches"), summaryType("functions"), summaryType("lines"), "\n") - .join("\n\t"); -} -const summaryTableFooter = ["", "
FileStatementsBranchesFunctionsLines
${info.pct}%${info.covered}/${info.total}`, `
${percentGraph(info.pct)}
`, `
${html.escape(file)}
", "
"].join("\n"); -const emptyClasses = { - statements: "empty", - lines: "empty", - functions: "empty", - branches: "empty", -}; -const standardLinkMapper = { - getPath(node) { - if (typeof node === "string") { - return node; - } - let filePath = node.getQualifiedName(); - if (node.isSummary()) { - if (filePath !== "") { - filePath += "/index.html"; - } - else { - filePath = "index.html"; - } - } - else { - filePath += ".html"; - } - return filePath; - }, - relativePath(source, target) { - const targetPath = this.getPath(target); - const sourcePath = path.dirname(this.getPath(source)); - return path.posix.relative(sourcePath, targetPath); - }, - assetPath(node, name) { - return this.relativePath(this.getPath(node), name); - }, -}; -function fixPct(metrics) { - Object.keys(emptyClasses).forEach((key) => { - metrics[key].pct = 0; - }); - return metrics; -} -class HtmlReport extends ReportBase { - constructor(opts) { - super(); - this.verbose = opts.verbose; - this.linkMapper = opts.linkMapper || standardLinkMapper; - this.subdir = opts.subdir || ""; - this.date = new Date().toISOString(); - this.skipEmpty = opts.skipEmpty; - } - getBreadcrumbHtml(node) { - let parent = node.getParent(); - const nodePath = []; - while (parent) { - nodePath.push(parent); - parent = parent.getParent(); - } - const linkPath = nodePath.map((ancestor) => { - const target = this.linkMapper.relativePath(node, ancestor); - const name = ancestor.getRelativeName() || "All files"; - return '' + name + ""; - }); - linkPath.reverse(); - return linkPath.length > 0 - ? linkPath.join(" / ") + " " + node.getRelativeName() - : "All files"; - } - fillTemplate(node, templateData, context) { - const linkMapper = this.linkMapper; - const summary = node.getCoverageSummary(); - templateData.entity = node.getQualifiedName() || "All files"; - templateData.metrics = summary; - templateData.reportClass = context.classForPercent("statements", summary.statements.pct); - templateData.pathHtml = this.getBreadcrumbHtml(node); - templateData.base = { - css: linkMapper.assetPath(node, "base.css"), - }; - templateData.sorter = { - js: linkMapper.assetPath(node, "sorter.js"), - image: linkMapper.assetPath(node, "sort-arrow-sprite.png"), - }; - templateData.blockNavigation = { - js: linkMapper.assetPath(node, "block-navigation.js"), - }; - templateData.prettify = { - js: linkMapper.assetPath(node, "prettify.js"), - css: linkMapper.assetPath(node, "prettify.css"), - }; - templateData.favicon = linkMapper.assetPath(node, "favicon.png"); - } - getTemplateData() { - return { datetime: this.date }; - } - getWriter(context) { - if (!this.subdir) { - return context.writer; - } - return context.writer.writerForDir(this.subdir); - } - onStart(root, context) { - const assetHeaders = { - ".js": "/* eslint-disable */\n", - }; - [".", "vendor"].forEach((subdir) => { - const writer = this.getWriter(context); - const srcDir = path.resolve(__dirname, "assets", subdir); - fs.readdirSync(srcDir).forEach((f) => { - const resolvedSource = path.resolve(srcDir, f); - const resolvedDestination = "."; - const stat = fs.statSync(resolvedSource); - let dest; - if (stat.isFile()) { - dest = resolvedDestination + "/" + f; - if (this.verbose) { - console.log("Write asset: " + dest); - } - writer.copyFile(resolvedSource, dest, assetHeaders[path.extname(f)]); - } - }); - }); - } - onSummary(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - const children = node.getChildren(); - const skipEmpty = this.skipEmpty; - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write(summaryTableHeader); - children.forEach((child) => { - const metrics = child.getCoverageSummary(); - const isEmpty = metrics.isEmpty(); - if (skipEmpty && isEmpty) { - return; - } - const reportClasses = isEmpty - ? emptyClasses - : { - statements: context.classForPercent("statements", metrics.statements.pct), - lines: context.classForPercent("lines", metrics.lines.pct), - functions: context.classForPercent("functions", metrics.functions.pct), - branches: context.classForPercent("branches", metrics.branches.pct), - }; - const data = { - metrics: isEmpty ? fixPct(metrics) : metrics, - reportClasses, - file: child.getRelativeName(), - output: linkMapper.relativePath(node, child), - }; - cw.write(summaryLineTemplate(data) + "\n"); - }); - cw.write(summaryTableFooter); - cw.write(footerTemplate(templateData)); - cw.close(); - } - onDetail(node, context) { - const linkMapper = this.linkMapper; - const templateData = this.getTemplateData(); - this.fillTemplate(node, templateData, context); - const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); - cw.write(headerTemplate(templateData)); - cw.write('
\n');
-        cw.write(detailTemplate(annotator(node.getFileCoverage(), context)));
-        cw.write("
\n"); - cw.write(footerTemplate(templateData)); - cw.close(); - } -} -module.exports = HtmlReport; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs deleted file mode 100644 index 6cc92030ae8..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/istanbul-reports/lib/html/insertion-text.cjs +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -function InsertionText(text, consumeBlanks) { - this.text = text; - this.origLength = text.length; - this.offsets = []; - this.consumeBlanks = consumeBlanks; - this.startPos = this.findFirstNonBlank(); - this.endPos = this.findLastNonBlank(); -} -const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; -InsertionText.prototype = { - findFirstNonBlank() { - let pos = -1; - const text = this.text; - const len = text.length; - let i; - for (i = 0; i < len; i += 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - findLastNonBlank() { - const text = this.text; - const len = text.length; - let pos = text.length + 1; - let i; - for (i = len - 1; i >= 0; i -= 1) { - if (!text.charAt(i).match(WHITE_RE)) { - pos = i; - break; - } - } - return pos; - }, - originalLength() { - return this.origLength; - }, - insertAt(col, str, insertBefore, consumeBlanks) { - consumeBlanks = - typeof consumeBlanks === 'undefined' - ? this.consumeBlanks - : consumeBlanks; - col = col > this.originalLength() ? this.originalLength() : col; - col = col < 0 ? 0 : col; - if (consumeBlanks) { - if (col <= this.startPos) { - col = 0; - } - if (col > this.endPos) { - col = this.origLength; - } - } - const len = str.length; - const offset = this.findOffset(col, len, insertBefore); - const realPos = col + offset; - const text = this.text; - this.text = text.substring(0, realPos) + str + text.substring(realPos); - return this; - }, - findOffset(pos, len, insertBefore) { - const offsets = this.offsets; - let offsetObj; - let cumulativeOffset = 0; - let i; - for (i = 0; i < offsets.length; i += 1) { - offsetObj = offsets[i]; - if (offsetObj.pos < pos || - (offsetObj.pos === pos && !insertBefore)) { - cumulativeOffset += offsetObj.len; - } - if (offsetObj.pos >= pos) { - break; - } - } - if (offsetObj && offsetObj.pos === pos) { - offsetObj.len += len; - } - else { - offsets.splice(i, 0, { pos, len }); - } - return cumulativeOffset; - }, - wrap(startPos, startText, endPos, endText, consumeBlanks) { - this.insertAt(startPos, startText, true, consumeBlanks); - this.insertAt(endPos, endText, false, consumeBlanks); - return this; - }, - wrapLine(startText, endText) { - this.wrap(0, startText, this.originalLength(), endText); - }, - toString() { - return this.text; - } -}; -module.exports = InsertionText; -//# sourceMappingURL=insertion-text.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs deleted file mode 100644 index 86ee436a301..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/index.cjs +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -/** - * istanbul-lib-coverage exports an API that allows you to create and manipulate - * file coverage, coverage maps (a set of file coverage objects) and summary - * coverage objects. File coverage for the same file can be merged as can - * entire coverage maps. - * - * @module Exports - */ -const { FileCoverage } = require("./lib/file-coverage.cjs"); -const { CoverageMap } = require("./lib/coverage-map.cjs"); -const { CoverageSummary } = require("./lib/coverage-summary.cjs"); -module.exports = { - /** - * creates a coverage summary object - * @param {Object} obj an argument with the same semantics - * as the one passed to the `CoverageSummary` constructor - * @returns {CoverageSummary} - */ - createCoverageSummary(obj) { - if (obj && obj instanceof CoverageSummary) { - return obj; - } - return new CoverageSummary(obj); - }, - /** - * creates a CoverageMap object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the CoverageMap constructor. - * @returns {CoverageMap} - */ - createCoverageMap(obj) { - if (obj && obj instanceof CoverageMap) { - return obj; - } - return new CoverageMap(obj); - }, - /** - * creates a FileCoverage object - * @param {Object} obj optional - an argument with the same semantics - * as the one passed to the FileCoverage constructor. - * @returns {FileCoverage} - */ - createFileCoverage(obj) { - if (obj && obj instanceof FileCoverage) { - return obj; - } - return new FileCoverage(obj); - }, -}; -/** classes exported for reuse */ -module.exports.classes = { - /** - * the file coverage constructor - */ - FileCoverage, -}; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs deleted file mode 100644 index bad5422758a..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-map.cjs +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const { FileCoverage } = require("./file-coverage.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); -function maybeConstruct(obj, klass) { - if (obj instanceof klass) { - return obj; - } - return new klass(obj); -} -function loadMap(source) { - const data = Object.create(null); - if (!source) { - return data; - } - Object.entries(source).forEach(([k, cov]) => { - data[k] = maybeConstruct(cov, FileCoverage); - }); - return data; -} -/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */ -class CoverageMap { - /** - * @constructor - * @param {Object} [obj=undefined] obj A coverage map from which to initialize this - * map's contents. This can be the raw global coverage object. - */ - constructor(obj) { - if (obj instanceof CoverageMap) { - this.data = obj.data; - } - else { - this.data = loadMap(obj); - } - } - /** - * merges a second coverage map into this one - * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged - * correctly for the same files and additional file coverage keys are created - * as needed. - */ - merge(obj) { - const other = maybeConstruct(obj, CoverageMap); - Object.values(other.data).forEach((fc) => { - this.addFileCoverage(fc); - }); - } - /** - * filter the coveragemap based on the callback provided - * @param {Function (filename)} callback - Returns true if the path - * should be included in the coveragemap. False if it should be - * removed. - */ - filter(callback) { - Object.keys(this.data).forEach((k) => { - if (!callback(k)) { - delete this.data[k]; - } - }); - } - /** - * returns a JSON-serializable POJO for this coverage map - * @returns {Object} - */ - toJSON() { - return this.data; - } - /** - * returns an array for file paths for which this map has coverage - * @returns {Array{string}} - array of files - */ - files() { - return Object.keys(this.data); - } - /** - * returns the file coverage for the specified file. - * @param {String} file - * @returns {FileCoverage} - */ - fileCoverageFor(file) { - const fc = this.data[file]; - if (!fc) { - throw new Error(`No file coverage available for: ${file}`); - } - return fc; - } - addFileCoverage(fc) { - const cov = new FileCoverage(fc); - const { path } = cov; - if (this.data[path]) { - this.data[path].merge(cov); - } - else { - this.data[path] = cov; - } - } - /** - * returns the coverage summary for all the file coverage objects in this map. - * @returns {CoverageSummary} - */ - getCoverageSummary() { - const ret = new CoverageSummary(); - Object.values(this.data).forEach((fc) => { - ret.merge(fc.toSummary()); - }); - return ret; - } -} -module.exports = { - CoverageMap, -}; -//# sourceMappingURL=coverage-map.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs deleted file mode 100644 index 8762aca9296..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/coverage-summary.cjs +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); -function blankSummary() { - const empty = () => ({ - total: 0, - covered: 0, - skipped: 0, - pct: "Unknown", - }); - return { - lines: empty(), - statements: empty(), - functions: empty(), - branches: empty(), - branchesTrue: empty(), - }; -} -// asserts that a data object "looks like" a summary coverage object -function assertValidSummary(obj) { - const valid = obj && obj.lines && obj.statements && obj.functions && obj.branches; - if (!valid) { - throw new Error("Invalid summary coverage object, missing keys, found:" + - Object.keys(obj).join(",")); - } -} -/** - * CoverageSummary provides a summary of code coverage . It exposes 4 properties, - * `lines`, `statements`, `branches`, and `functions`. Each of these properties - * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. - * `pct` is a percentage number (0-100). - */ -class CoverageSummary { - /** - * @constructor - * @param {Object|CoverageSummary} [obj=undefined] an optional data object or - * another coverage summary to initialize this object with. - */ - constructor(obj) { - if (!obj) { - this.data = blankSummary(); - } - else if (obj instanceof CoverageSummary) { - this.data = obj.data; - } - else { - this.data = obj; - } - assertValidSummary(this.data); - } - /** - * merges a second summary coverage object into this one - * @param {CoverageSummary} obj - another coverage summary object - */ - merge(obj) { - const keys = [ - "lines", - "statements", - "branches", - "functions", - "branchesTrue", - ]; - keys.forEach((key) => { - if (obj[key]) { - this[key].total += obj[key].total; - this[key].covered += obj[key].covered; - this[key].skipped += obj[key].skipped; - this[key].pct = percent(this[key].covered, this[key].total); - } - }); - return this; - } - /** - * returns a POJO that is JSON serializable. May be used to get the raw - * summary object. - */ - toJSON() { - return this.data; - } - /** - * return true if summary has no lines of code - */ - isEmpty() { - return this.lines.total === 0; - } -} -dataProperties(CoverageSummary, [ - "lines", - "statements", - "functions", - "branches", - "branchesTrue", -]); -module.exports = { - CoverageSummary, -}; -//# sourceMappingURL=coverage-summary.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs deleted file mode 100644 index e8a22f8e598..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/data-properties.cjs +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -module.exports = function dataProperties(klass, properties) { - properties.forEach((p) => { - Object.defineProperty(klass.prototype, p, { - enumerable: true, - get() { - return this.data[p]; - }, - }); - }); -}; -//# sourceMappingURL=data-properties.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs deleted file mode 100644 index 72900a820ba..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/file-coverage.cjs +++ /dev/null @@ -1,387 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const percent = require("./percent.cjs"); -const dataProperties = require("./data-properties.cjs"); -const { CoverageSummary } = require("./coverage-summary.cjs"); -// returns a data object that represents empty coverage -function emptyCoverage(filePath, reportLogic) { - const cov = { - path: filePath, - statementMap: {}, - fnMap: {}, - branchMap: {}, - s: {}, - f: {}, - b: {}, - }; - if (reportLogic) - cov.bT = {}; - return cov; -} -// asserts that a data object "looks like" a coverage object -function assertValidObject(obj) { - const valid = obj && - obj.path && - obj.statementMap && - obj.fnMap && - obj.branchMap && - obj.s && - obj.f && - obj.b; - if (!valid) { - throw new Error("Invalid file coverage object, missing keys, found:" + - Object.keys(obj).join(",")); - } -} -const keyFromLoc = ({ start, end }) => `${start.line}|${start.column}|${end.line}|${end.column}`; -const isObj = (o) => !!o && typeof o === "object"; -const isLineCol = (o) => isObj(o) && typeof o.line === "number" && typeof o.column === "number"; -const isLoc = (o) => isObj(o) && isLineCol(o.start) && isLineCol(o.end); -const getLoc = (o) => (isLoc(o) ? o : isLoc(o.loc) ? o.loc : null); -// When merging, we can have a case where two ranges cover -// the same block of code with `hits=1`, and each carve out a -// different range with `hits=0` to indicate it's uncovered. -// Find the nearest container so that we can properly indicate -// that both sections are hit. -// Returns null if no containing item is found. -const findNearestContainer = (item, map) => { - const itemLoc = getLoc(item); - if (!itemLoc) - return null; - // the B item is not an identified range in the A set, BUT - // it may be contained by an identified A range. If so, then - // any hit of that containing A range counts as a hit of this - // B range as well. We have to find the *narrowest* containing - // range to be accurate, since ranges can be hit and un-hit - // in a nested fashion. - let nearestContainingItem = null; - let containerDistance = null; - let containerKey = null; - for (const [i, mapItem] of Object.entries(map)) { - const mapLoc = getLoc(mapItem); - if (!mapLoc) - continue; - // contained if all of line distances are > 0 - // or line distance is 0 and col dist is >= 0 - const distance = [ - itemLoc.start.line - mapLoc.start.line, - itemLoc.start.column - mapLoc.start.column, - mapLoc.end.line - itemLoc.end.line, - mapLoc.end.column - itemLoc.end.column, - ]; - if (distance[0] < 0 || - distance[2] < 0 || - (distance[0] === 0 && distance[1] < 0) || - (distance[2] === 0 && distance[3] < 0)) { - continue; - } - if (nearestContainingItem === null) { - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - continue; - } - // closer line more relevant than closer column - const closerBefore = distance[0] < containerDistance[0] || - (distance[0] === 0 && distance[1] < containerDistance[1]); - const closerAfter = distance[2] < containerDistance[2] || - (distance[2] === 0 && distance[3] < containerDistance[3]); - if (closerBefore || closerAfter) { - // closer - containerDistance = distance; - nearestContainingItem = mapItem; - containerKey = i; - } - } - return containerKey; -}; -// either add two numbers, or all matching entries in a number[] -const addHits = (aHits, bHits) => { - if (typeof aHits === "number" && typeof bHits === "number") { - return aHits + bHits; - } - else if (Array.isArray(aHits) && Array.isArray(bHits)) { - return aHits.map((a, i) => (a || 0) + (bHits[i] || 0)); - } - return null; -}; -const addNearestContainerHits = (item, itemHits, map, mapHits) => { - const container = findNearestContainer(item, map); - if (container) { - return addHits(itemHits, mapHits[container]); - } - else { - return itemHits; - } -}; -const mergeProp = (aHits, aMap, bHits, bMap, itemKey = keyFromLoc) => { - const aItems = {}; - for (const [key, itemHits] of Object.entries(aHits)) { - const item = aMap[key]; - aItems[itemKey(item)] = [itemHits, item]; - } - const bItems = {}; - for (const [key, itemHits] of Object.entries(bHits)) { - const item = bMap[key]; - bItems[itemKey(item)] = [itemHits, item]; - } - const mergedItems = {}; - for (const [key, aValue] of Object.entries(aItems)) { - let aItemHits = aValue[0]; - const aItem = aValue[1]; - const bValue = bItems[key]; - if (!bValue) { - // not an identified range in b, but might be contained by one - aItemHits = addNearestContainerHits(aItem, aItemHits, bMap, bHits); - } - else { - // is an identified range in b, so add the hits together - aItemHits = addHits(aItemHits, bValue[0]); - } - mergedItems[key] = [aItemHits, aItem]; - } - // now find the items in b that are not in a. already added matches. - for (const [key, bValue] of Object.entries(bItems)) { - let bItemHits = bValue[0]; - const bItem = bValue[1]; - if (mergedItems[key]) - continue; - // not an identified range in b, but might be contained by one - bItemHits = addNearestContainerHits(bItem, bItemHits, aMap, aHits); - mergedItems[key] = [bItemHits, bItem]; - } - const hits = {}; - const map = {}; - Object.values(mergedItems).forEach(([itemHits, item], i) => { - hits[i] = itemHits; - map[i] = item; - }); - return [hits, map]; -}; -/** - * provides a read-only view of coverage for a single file. - * The deep structure of this object is documented elsewhere. It has the following - * properties: - * - * * `path` - the file path for which coverage is being tracked - * * `statementMap` - map of statement locations keyed by statement index - * * `fnMap` - map of function metadata keyed by function index - * * `branchMap` - map of branch metadata keyed by branch index - * * `s` - hit counts for statements - * * `f` - hit count for functions - * * `b` - hit count for branches - */ -class FileCoverage { - /** - * @constructor - * @param {Object|FileCoverage|String} pathOrObj is a string that initializes - * and empty coverage object with the specified file path or a data object that - * has all the required properties for a file coverage object. - */ - constructor(pathOrObj, reportLogic = false) { - if (!pathOrObj) { - throw new Error("Coverage must be initialized with a path or an object"); - } - if (typeof pathOrObj === "string") { - this.data = emptyCoverage(pathOrObj, reportLogic); - } - else if (pathOrObj instanceof FileCoverage) { - this.data = pathOrObj.data; - } - else if (typeof pathOrObj === "object") { - this.data = pathOrObj; - } - else { - throw new Error("Invalid argument to coverage constructor"); - } - assertValidObject(this.data); - } - /** - * returns computed line coverage from statement coverage. - * This is a map of hits keyed by line number in the source. - */ - getLineCoverage() { - const statementMap = this.data.statementMap; - const statements = this.data.s; - const lineMap = Object.create(null); - Object.entries(statements).forEach(([st, count]) => { - /* istanbul ignore if: is this even possible? */ - if (!statementMap[st]) { - return; - } - const { line } = statementMap[st].start; - const prevVal = lineMap[line]; - if (prevVal === undefined || prevVal < count) { - lineMap[line] = count; - } - }); - return lineMap; - } - /** - * returns an array of uncovered line numbers. - * @returns {Array} an array of line numbers for which no hits have been - * collected. - */ - getUncoveredLines() { - const lc = this.getLineCoverage(); - const ret = []; - Object.entries(lc).forEach(([l, hits]) => { - if (hits === 0) { - ret.push(l); - } - }); - return ret; - } - /** - * returns a map of branch coverage by source line number. - * @returns {Object} an object keyed by line number. Each object - * has a `covered`, `total` and `coverage` (percentage) property. - */ - getBranchCoverageByLine() { - const branchMap = this.branchMap; - const branches = this.b; - const ret = {}; - Object.entries(branchMap).forEach(([k, map]) => { - const line = map.line || map.loc.start.line; - const branchData = branches[k]; - ret[line] = ret[line] || []; - ret[line].push(...branchData); - }); - Object.entries(ret).forEach(([k, dataArray]) => { - const covered = dataArray.filter((item) => item > 0); - const coverage = (covered.length / dataArray.length) * 100; - ret[k] = { - covered: covered.length, - total: dataArray.length, - coverage, - }; - }); - return ret; - } - /** - * return a JSON-serializable POJO for this file coverage object - */ - toJSON() { - return this.data; - } - /** - * merges a second coverage object into this one, updating hit counts - * @param {FileCoverage} other - the coverage object to be merged into this one. - * Note that the other object should have the same structure as this one (same file). - */ - merge(other) { - if (other.all === true) { - return; - } - if (this.all === true) { - this.data = other.data; - return; - } - let [hits, map] = mergeProp(this.s, this.statementMap, other.s, other.statementMap); - this.data.s = hits; - this.data.statementMap = map; - const keyFromLocProp = (x) => keyFromLoc(x.loc); - const keyFromLocationsProp = (x) => keyFromLoc(x.locations[0]); - [hits, map] = mergeProp(this.f, this.fnMap, other.f, other.fnMap, keyFromLocProp); - this.data.f = hits; - this.data.fnMap = map; - [hits, map] = mergeProp(this.b, this.branchMap, other.b, other.branchMap, keyFromLocationsProp); - this.data.b = hits; - this.data.branchMap = map; - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT && other.bT) { - [hits, map] = mergeProp(this.bT, this.branchMap, other.bT, other.branchMap, keyFromLocationsProp); - this.data.bT = hits; - } - } - computeSimpleTotals(property) { - let stats = this[property]; - if (typeof stats === "function") { - stats = stats.call(this); - } - const ret = { - total: Object.keys(stats).length, - covered: Object.values(stats).filter((v) => !!v).length, - skipped: 0, - }; - ret.pct = percent(ret.covered, ret.total); - return ret; - } - computeBranchTotals(property) { - const stats = this[property]; - const ret = { total: 0, covered: 0, skipped: 0 }; - Object.values(stats).forEach((branches) => { - ret.covered += branches.filter((hits) => hits > 0).length; - ret.total += branches.length; - }); - ret.pct = percent(ret.covered, ret.total); - return ret; - } - /** - * resets hit counts for all statements, functions and branches - * in this coverage object resulting in zero coverage. - */ - resetHits() { - const statements = this.s; - const functions = this.f; - const branches = this.b; - const branchesTrue = this.bT; - Object.keys(statements).forEach((s) => { - statements[s] = 0; - }); - Object.keys(functions).forEach((f) => { - functions[f] = 0; - }); - Object.keys(branches).forEach((b) => { - branches[b].fill(0); - }); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (branchesTrue) { - Object.keys(branchesTrue).forEach((bT) => { - branchesTrue[bT].fill(0); - }); - } - } - /** - * returns a CoverageSummary for this file coverage object - * @returns {CoverageSummary} - */ - toSummary() { - const ret = {}; - ret.lines = this.computeSimpleTotals("getLineCoverage"); - ret.functions = this.computeSimpleTotals("f", "fnMap"); - ret.statements = this.computeSimpleTotals("s", "statementMap"); - ret.branches = this.computeBranchTotals("b"); - // Tracking additional information about branch truthiness - // can be optionally enabled: - if (this.bT) { - ret.branchesTrue = this.computeBranchTotals("bT"); - } - return new CoverageSummary(ret); - } -} -// expose coverage data attributes -dataProperties(FileCoverage, [ - "path", - "statementMap", - "fnMap", - "branchMap", - "s", - "f", - "b", - "bT", - "all", -]); -module.exports = { - FileCoverage, - // exported for testing - findNearestContainer, - addHits, - addNearestContainerHits, -}; -//# sourceMappingURL=file-coverage.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs deleted file mode 100644 index 7e0b1ee99e0..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-coverage/lib/percent.cjs +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -module.exports = function percent(covered, total) { - let tmp; - if (total > 0) { - tmp = (1000 * 100 * covered) / total; - return Math.floor(tmp / 10) / 100; - } - else { - return 100.0; - } -}; -//# sourceMappingURL=percent.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs deleted file mode 100644 index 9ccf034704a..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/ciao.cjs +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=ciao.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs deleted file mode 100644 index 658f3228b3d..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/index.cjs +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -/** - * @module Exports - */ -const Context = require("./lib/context.cjs"); -const watermarks = require("./lib/watermarks.cjs"); -const ReportBase = require("./lib/report-base.cjs"); -module.exports = { - /** - * returns a reporting context for the supplied options - * @param {Object} [opts=null] opts - * @returns {Context} - */ - createContext(opts) { - return new Context(opts); - }, - /** - * returns the default watermarks that would be used when not - * overridden - * @returns {Object} an object with `statements`, `functions`, `branches`, - * and `line` keys. Each value is a 2 element array that has the low and - * high watermark as percentages. - */ - getDefaultWatermarks() { - return watermarks.getDefault(); - }, - /** - * Base class for all reports - */ - ReportBase, -}; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs deleted file mode 100644 index 5eb918c4098..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/context.cjs +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const fs = require("node:fs"); -const FileWriter = require("./file-writer.cjs"); -const XMLWriter = require("./xml-writer.cjs"); -const tree = require("./tree.cjs"); -const watermarks = require("./watermarks.cjs"); -const SummarizerFactory = require("./summarizer-factory.cjs"); -function defaultSourceLookup(path) { - try { - return fs.readFileSync(path, "utf8"); - } - catch (ex) { - throw new Error(`Unable to lookup source: ${path} (${ex.message})`); - } -} -function normalizeWatermarks(specified = {}) { - Object.entries(watermarks.getDefault()).forEach(([k, value]) => { - const specValue = specified[k]; - if (!Array.isArray(specValue) || specValue.length !== 2) { - specified[k] = value; - } - }); - return specified; -} -/** - * A reporting context that is passed to report implementations - * @param {Object} [opts=null] opts options - * @param {String} [opts.dir='coverage'] opts.dir the reporting directory - * @param {Object} [opts.watermarks=null] opts.watermarks watermarks for - * statements, lines, branches and functions - * @param {Function} [opts.sourceFinder=fsLookup] opts.sourceFinder a - * function that returns source code given a file path. Defaults to - * filesystem lookups based on path. - * @constructor - */ -class Context { - constructor(opts) { - this.dir = opts.dir || "coverage"; - this.watermarks = normalizeWatermarks(opts.watermarks); - this.sourceFinder = opts.sourceFinder || defaultSourceLookup; - this._summarizerFactory = new SummarizerFactory(opts.coverageMap, opts.defaultSummarizer); - this.data = {}; - } - /** - * returns a FileWriter implementation for reporting use. Also available - * as the `writer` property on the context. - * @returns {Writer} - */ - getWriter() { - return this.writer; - } - /** - * returns the source code for the specified file path or throws if - * the source could not be found. - * @param {String} filePath the file path as found in a file coverage object - * @returns {String} the source code - */ - getSource(filePath) { - return this.sourceFinder(filePath); - } - /** - * returns the coverage class given a coverage - * types and a percentage value. - * @param {String} type - the coverage type, one of `statements`, `functions`, - * `branches`, or `lines` - * @param {Number} value - the percentage value - * @returns {String} one of `high`, `medium` or `low` - */ - classForPercent(type, value) { - const watermarks = this.watermarks[type]; - if (!watermarks) { - return "unknown"; - } - if (value < watermarks[0]) { - return "low"; - } - if (value >= watermarks[1]) { - return "high"; - } - return "medium"; - } - /** - * returns an XML writer for the supplied content writer - * @param {ContentWriter} contentWriter the content writer to which the returned XML writer - * writes data - * @returns {XMLWriter} - */ - getXMLWriter(contentWriter) { - return new XMLWriter(contentWriter); - } - /** - * returns a full visitor given a partial one. - * @param {Object} partialVisitor a partial visitor only having the functions of - * interest to the caller. These functions are called with a scope that is the - * supplied object. - * @returns {Visitor} - */ - getVisitor(partialVisitor) { - return new tree.Visitor(partialVisitor); - } - getTree(name = "defaultSummarizer") { - return this._summarizerFactory[name]; - } -} -Object.defineProperty(Context.prototype, "writer", { - enumerable: true, - get() { - if (!this.data.writer) { - this.data.writer = new FileWriter(this.dir); - } - return this.data.writer; - }, -}); -module.exports = Context; -//# sourceMappingURL=context.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs deleted file mode 100644 index a79f541a0b6..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/file-writer.cjs +++ /dev/null @@ -1,165 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const path = require("node:path"); -const fs = require("node:fs"); -const { mkdir } = require("node:fs/promises"); -/** - * Base class for writing content - * @class ContentWriter - * @constructor - */ -class ContentWriter { - /** - * returns the colorized version of a string. Typically, - * content writers that write to files will return the - * same string and ones writing to a tty will wrap it in - * appropriate escape sequences. - * @param {String} str the string to colorize - * @param {String} clazz one of `high`, `medium` or `low` - * @returns {String} the colorized form of the string - */ - colorize(str /*, clazz*/) { - return str; - } - /** - * writes a string appended with a newline to the destination - * @param {String} str the string to write - */ - println(str) { - this.write(`${str}\n`); - } - /** - * closes this content writer. Should be called after all writes are complete. - */ - close() { } -} -/** - * a content writer that writes to a file - * @param {Number} fd - the file descriptor - * @extends ContentWriter - * @constructor - */ -class FileContentWriter extends ContentWriter { - constructor(fd) { - super(); - this.fd = fd; - } - write(str) { - fs.writeSync(this.fd, str); - } - close() { - fs.closeSync(this.fd); - } -} -// allow stdout to be captured for tests. -let capture = false; -let output = ""; -/** - * a content writer that writes to the console - * @extends ContentWriter - * @constructor - */ -class ConsoleWriter extends ContentWriter { - write(str) { - if (capture) { - output += str; - } - else { - process.stdout.write(str); - } - } - colorize(str, clazz) { - const colors = { - low: "31;1", - medium: "33;1", - high: "32;1", - }; - return str; - } -} -/** - * utility for writing files under a specific directory - * @class FileWriter - * @param {String} baseDir the base directory under which files should be written - * @constructor - */ -class FileWriter { - constructor(baseDir) { - if (!baseDir) { - throw new Error("baseDir must be specified"); - } - this.baseDir = baseDir; - } - /** - * static helpers for capturing stdout report output; - * super useful for tests! - */ - static startCapture() { - capture = true; - } - static stopCapture() { - capture = false; - } - static getOutput() { - return output; - } - static resetOutput() { - output = ""; - } - /** - * returns a FileWriter that is rooted at the supplied subdirectory - * @param {String} subdir the subdirectory under which to root the - * returned FileWriter - * @returns {FileWriter} - */ - writerForDir(subdir) { - if (path.isAbsolute(subdir)) { - throw new Error(`Cannot create subdir writer for absolute path: ${subdir}`); - } - return new FileWriter(`${this.baseDir}/${subdir}`); - } - /** - * copies a file from a source directory to a destination name - * @param {String} source path to source file - * @param {String} dest relative path to destination file - * @param {String} [header=undefined] optional text to prepend to destination - * (e.g., an "this file is autogenerated" comment, copyright notice, etc.) - */ - copyFile(source, dest, header) { - if (path.isAbsolute(dest)) { - throw new Error(`Cannot write to absolute path: ${dest}`); - } - dest = path.resolve(this.baseDir, dest); - mkdir(path.dirname(dest), { recursive: true }); - let contents; - if (header) { - contents = header + fs.readFileSync(source, "utf8"); - } - else { - contents = fs.readFileSync(source); - } - fs.writeFileSync(dest, contents); - } - /** - * returns a content writer for writing content to the supplied file. - * @param {String|null} file the relative path to the file or the special - * values `"-"` or `null` for writing to the console - * @returns {ContentWriter} - */ - writeFile(file) { - if (file === null || file === "-") { - return new ConsoleWriter(); - } - if (path.isAbsolute(file)) { - throw new Error(`Cannot write to absolute path: ${file}`); - } - file = path.resolve(this.baseDir, file); - mkdir(path.dirname(file), { recursive: true }); - return new FileContentWriter(fs.openSync(file, "w")); - } -} -module.exports = FileWriter; -//# sourceMappingURL=file-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs deleted file mode 100644 index 3bf30e53640..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/path.cjs +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const path = require("node:path"); -let parsePath = path.parse; -let SEP = path.sep; -const origParser = parsePath; -const origSep = SEP; -function makeRelativeNormalizedPath(str, sep) { - const parsed = parsePath(str); - let root = parsed.root; - let dir; - let file = parsed.base; - let quoted; - let pos; - // handle a weird windows case separately - if (sep === "\\") { - pos = root.indexOf(":\\"); - if (pos >= 0) { - root = root.substring(0, pos + 2); - } - } - dir = parsed.dir.substring(root.length); - if (str === "") { - return []; - } - if (sep !== "/") { - quoted = new RegExp(sep.replace(/\W/g, "\\$&"), "g"); - dir = dir.replace(quoted, "/"); - file = file.replace(quoted, "/"); // excessively paranoid? - } - if (dir !== "") { - dir = `${dir}/${file}`; - } - else { - dir = file; - } - if (dir.substring(0, 1) === "/") { - dir = dir.substring(1); - } - dir = dir.split(/\/+/); - return dir; -} -class Path { - constructor(strOrArray) { - if (Array.isArray(strOrArray)) { - this.v = strOrArray; - } - else if (typeof strOrArray === "string") { - this.v = makeRelativeNormalizedPath(strOrArray, SEP); - } - else { - throw new Error(`Invalid Path argument must be string or array:${strOrArray}`); - } - } - toString() { - return this.v.join("/"); - } - hasParent() { - return this.v.length > 0; - } - parent() { - if (!this.hasParent()) { - throw new Error("Unable to get parent for 0 elem path"); - } - const p = this.v.slice(); - p.pop(); - return new Path(p); - } - elements() { - return this.v.slice(); - } - name() { - return this.v.slice(-1)[0]; - } - contains(other) { - let i; - if (other.length > this.length) { - return false; - } - for (i = 0; i < other.length; i += 1) { - if (this.v[i] !== other.v[i]) { - return false; - } - } - return true; - } - ancestorOf(other) { - return other.contains(this) && other.length !== this.length; - } - descendantOf(other) { - return this.contains(other) && other.length !== this.length; - } - commonPrefixPath(other) { - const len = this.length > other.length ? other.length : this.length; - let i; - const ret = []; - for (i = 0; i < len; i += 1) { - if (this.v[i] === other.v[i]) { - ret.push(this.v[i]); - } - else { - break; - } - } - return new Path(ret); - } - static compare(a, b) { - const al = a.length; - const bl = b.length; - if (al < bl) { - return -1; - } - if (al > bl) { - return 1; - } - const astr = a.toString(); - const bstr = b.toString(); - return astr < bstr ? -1 : astr > bstr ? 1 : 0; - } -} -["push", "pop", "shift", "unshift", "splice"].forEach((fn) => { - Object.defineProperty(Path.prototype, fn, { - value(...args) { - return this.v[fn](...args); - }, - }); -}); -Object.defineProperty(Path.prototype, "length", { - enumerable: true, - get() { - return this.v.length; - }, -}); -module.exports = Path; -Path.tester = { - setParserAndSep(p, sep) { - parsePath = p; - SEP = sep; - }, - reset() { - parsePath = origParser; - SEP = origSep; - }, -}; -//# sourceMappingURL=path.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs deleted file mode 100644 index 70ba85a2c68..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/report-base.cjs +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -// TODO: switch to class private field when targeting node.js 12 -const _summarizer = Symbol("ReportBase.#summarizer"); -class ReportBase { - constructor(opts = {}) { - this[_summarizer] = opts.summarizer; - } - execute(context) { - context.getTree(this[_summarizer]).visit(this, context); - } -} -module.exports = ReportBase; -//# sourceMappingURL=report-base.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs deleted file mode 100644 index 795a0d73ee1..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/summarizer-factory.cjs +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -const coverage = require("../../lib-coverage/index.cjs"); -const Path = require("./path.cjs"); -const { BaseNode, BaseTree } = require("./tree.cjs"); -class ReportNode extends BaseNode { - constructor(path, fileCoverage) { - super(); - this.path = path; - this.parent = null; - this.fileCoverage = fileCoverage; - this.children = []; - } - static createRoot(children) { - const root = new ReportNode(new Path([])); - children.forEach((child) => { - root.addChild(child); - }); - return root; - } - addChild(child) { - child.parent = this; - this.children.push(child); - } - asRelative(p) { - if (p.substring(0, 1) === "/") { - return p.substring(1); - } - return p; - } - getQualifiedName() { - return this.asRelative(this.path.toString()); - } - getRelativeName() { - const parent = this.getParent(); - const myPath = this.path; - let relPath; - let i; - const parentPath = parent ? parent.path : new Path([]); - if (parentPath.ancestorOf(myPath)) { - relPath = new Path(myPath.elements()); - for (i = 0; i < parentPath.length; i += 1) { - relPath.shift(); - } - return this.asRelative(relPath.toString()); - } - return this.asRelative(this.path.toString()); - } - getParent() { - return this.parent; - } - getChildren() { - return this.children; - } - isSummary() { - return !this.fileCoverage; - } - getFileCoverage() { - return this.fileCoverage; - } - getCoverageSummary(filesOnly) { - const cacheProp = `c_${filesOnly ? "files" : "full"}`; - let summary; - if (Object.prototype.hasOwnProperty.call(this, cacheProp)) { - return this[cacheProp]; - } - if (!this.isSummary()) { - summary = this.getFileCoverage().toSummary(); - } - else { - let count = 0; - summary = coverage.createCoverageSummary(); - this.getChildren().forEach((child) => { - if (filesOnly && child.isSummary()) { - return; - } - count += 1; - summary.merge(child.getCoverageSummary(filesOnly)); - }); - if (count === 0 && filesOnly) { - summary = null; - } - } - this[cacheProp] = summary; - return summary; - } -} -class ReportTree extends BaseTree { - constructor(root, childPrefix) { - super(root); - const maybePrefix = (node) => { - if (childPrefix && !node.isRoot()) { - node.path.unshift(childPrefix); - } - }; - this.visit({ - onDetail: maybePrefix, - onSummary(node) { - maybePrefix(node); - node.children.sort((a, b) => { - const astr = a.path.toString(); - const bstr = b.path.toString(); - return astr < bstr - ? -1 - : astr > bstr - ? 1 - : /* istanbul ignore next */ 0; - }); - }, - }); - } -} -function findCommonParent(paths) { - return paths.reduce((common, path) => common.commonPrefixPath(path), paths[0] || new Path([])); -} -function findOrCreateParent(parentPath, nodeMap, created = () => { }) { - let parent = nodeMap[parentPath.toString()]; - if (!parent) { - parent = new ReportNode(parentPath); - nodeMap[parentPath.toString()] = parent; - created(parentPath, parent); - } - return parent; -} -function toDirParents(list) { - const nodeMap = Object.create(null); - list.forEach((o) => { - const parent = findOrCreateParent(o.path.parent(), nodeMap); - parent.addChild(new ReportNode(o.path, o.fileCoverage)); - }); - return Object.values(nodeMap); -} -function addAllPaths(topPaths, nodeMap, path, node) { - const parent = findOrCreateParent(path.parent(), nodeMap, (parentPath, parent) => { - if (parentPath.hasParent()) { - addAllPaths(topPaths, nodeMap, parentPath, parent); - } - else { - topPaths.push(parent); - } - }); - parent.addChild(node); -} -function foldIntoOneDir(node, parent) { - const { children } = node; - if (children.length === 1 && !children[0].fileCoverage) { - children[0].parent = parent; - return foldIntoOneDir(children[0], parent); - } - node.children = children.map((child) => foldIntoOneDir(child, node)); - return node; -} -function pkgSummaryPrefix(dirParents, commonParent) { - if (!dirParents.some((dp) => dp.path.length === 0)) { - return; - } - if (commonParent.length === 0) { - return "root"; - } - return commonParent.name(); -} -class SummarizerFactory { - constructor(coverageMap, defaultSummarizer = "pkg") { - this._coverageMap = coverageMap; - this._defaultSummarizer = defaultSummarizer; - this._initialList = coverageMap.files().map((filePath) => ({ - filePath, - path: new Path(filePath), - fileCoverage: coverageMap.fileCoverageFor(filePath), - })); - this._commonParent = findCommonParent(this._initialList.map((o) => o.path.parent())); - if (this._commonParent.length > 0) { - this._initialList.forEach((o) => { - o.path.splice(0, this._commonParent.length); - }); - } - } - get defaultSummarizer() { - return this[this._defaultSummarizer]; - } - get flat() { - if (!this._flat) { - this._flat = new ReportTree(ReportNode.createRoot(this._initialList.map((node) => new ReportNode(node.path, node.fileCoverage)))); - } - return this._flat; - } - _createPkg() { - const dirParents = toDirParents(this._initialList); - if (dirParents.length === 1) { - return new ReportTree(dirParents[0]); - } - return new ReportTree(ReportNode.createRoot(dirParents), pkgSummaryPrefix(dirParents, this._commonParent)); - } - get pkg() { - if (!this._pkg) { - this._pkg = this._createPkg(); - } - return this._pkg; - } - _createNested() { - const nodeMap = Object.create(null); - const topPaths = []; - this._initialList.forEach((o) => { - const node = new ReportNode(o.path, o.fileCoverage); - addAllPaths(topPaths, nodeMap, o.path, node); - }); - const topNodes = topPaths.map((node) => foldIntoOneDir(node)); - if (topNodes.length === 1) { - return new ReportTree(topNodes[0]); - } - return new ReportTree(ReportNode.createRoot(topNodes)); - } - get nested() { - if (!this._nested) { - this._nested = this._createNested(); - } - return this._nested; - } -} -module.exports = SummarizerFactory; -//# sourceMappingURL=summarizer-factory.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs deleted file mode 100644 index 784260e959c..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/tree.cjs +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -"use strict"; -/** - * An object with methods that are called during the traversal of the coverage tree. - * A visitor has the following methods that are called during tree traversal. - * - * * `onStart(root, state)` - called before traversal begins - * * `onSummary(node, state)` - called for every summary node - * * `onDetail(node, state)` - called for every detail node - * * `onSummaryEnd(node, state)` - called after all children have been visited for - * a summary node. - * * `onEnd(root, state)` - called after traversal ends - * - * @param delegate - a partial visitor that only implements the methods of interest - * The visitor object supplies the missing methods as noops. For example, reports - * that only need the final coverage summary need implement `onStart` and nothing - * else. Reports that use only detailed coverage information need implement `onDetail` - * and nothing else. - * @constructor - */ -class Visitor { - constructor(delegate) { - this.delegate = delegate; - } -} -["Start", "End", "Summary", "SummaryEnd", "Detail"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(Visitor.prototype, fn, { - writable: true, - value(node, state) { - if (typeof this.delegate[fn] === "function") { - this.delegate[fn](node, state); - } - }, - }); -}); -class CompositeVisitor extends Visitor { - constructor(visitors) { - super(); - if (!Array.isArray(visitors)) { - visitors = [visitors]; - } - this.visitors = visitors.map((v) => { - if (v instanceof Visitor) { - return v; - } - return new Visitor(v); - }); - } -} -["Start", "Summary", "SummaryEnd", "Detail", "End"] - .map((k) => `on${k}`) - .forEach((fn) => { - Object.defineProperty(CompositeVisitor.prototype, fn, { - value(node, state) { - this.visitors.forEach((v) => { - v[fn](node, state); - }); - }, - }); -}); -class BaseNode { - isRoot() { - return !this.getParent(); - } - /** - * visit all nodes depth-first from this node down. Note that `onStart` - * and `onEnd` are never called on the visitor even if the current - * node is the root of the tree. - * @param visitor a full visitor that is called during tree traversal - * @param state optional state that is passed around - */ - visit(visitor, state) { - if (this.isSummary()) { - visitor.onSummary(this, state); - } - else { - visitor.onDetail(this, state); - } - this.getChildren().forEach((child) => { - child.visit(visitor, state); - }); - if (this.isSummary()) { - visitor.onSummaryEnd(this, state); - } - } -} -/** - * abstract base class for a coverage tree. - * @constructor - */ -class BaseTree { - constructor(root) { - this.root = root; - } - /** - * returns the root node of the tree - */ - getRoot() { - return this.root; - } - /** - * visits the tree depth-first with the supplied partial visitor - * @param visitor - a potentially partial visitor - * @param state - the state to be passed around during tree traversal - */ - visit(visitor, state) { - if (!(visitor instanceof Visitor)) { - visitor = new Visitor(visitor); - } - visitor.onStart(this.getRoot(), state); - this.getRoot().visit(visitor, state); - visitor.onEnd(this.getRoot(), state); - } -} -module.exports = { - BaseTree, - BaseNode, - Visitor, - CompositeVisitor, -}; -//# sourceMappingURL=tree.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs deleted file mode 100644 index 6ba3cb2280a..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/watermarks.cjs +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -module.exports = { - getDefault() { - return { - statements: [50, 80], - functions: [50, 80], - branches: [50, 80], - lines: [50, 80], - }; - }, -}; -//# sourceMappingURL=watermarks.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs deleted file mode 100644 index ce0b0e0eb97..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/lib-report/lib/xml-writer.cjs +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -const INDENT = " "; -function attrString(attrs) { - return Object.entries(attrs || {}) - .map(([k, v]) => ` ${k}="${v}"`) - .join(""); -} -/** - * a utility class to produce well-formed, indented XML - * @param {ContentWriter} contentWriter the content writer that this utility wraps - * @constructor - */ -class XMLWriter { - constructor(contentWriter) { - this.cw = contentWriter; - this.stack = []; - } - indent(str) { - return this.stack.map(() => INDENT).join("") + str; - } - /** - * writes the opening XML tag with the supplied attributes - * @param {String} name tag name - * @param {Object} [attrs=null] attrs attributes for the tag - */ - openTag(name, attrs) { - const str = this.indent(`<${name + attrString(attrs)}>`); - this.cw.println(str); - this.stack.push(name); - } - /** - * closes an open XML tag. - * @param {String} name - tag name to close. This must match the writer's - * notion of the tag that is currently open. - */ - closeTag(name) { - if (this.stack.length === 0) { - throw new Error(`Attempt to close tag ${name} when not opened`); - } - const stashed = this.stack.pop(); - const str = ``; - if (stashed !== name) { - throw new Error(`Attempt to close tag ${name} when ${stashed} was the one open`); - } - this.cw.println(this.indent(str)); - } - /** - * writes a tag and its value opening and closing it at the same time - * @param {String} name tag name - * @param {Object} [attrs=null] attrs tag attributes - * @param {String} [content=null] content optional tag content - */ - inlineTag(name, attrs, content) { - let str = "<" + name + attrString(attrs); - if (content) { - str += `>${content}`; - } - else { - str += "/>"; - } - str = this.indent(str); - this.cw.println(str); - } - /** - * closes all open tags and ends the document - */ - closeAll() { - this.stack - .slice() - .reverse() - .forEach((name) => { - this.closeTag(name); - }); - } -} -module.exports = XMLWriter; -//# sourceMappingURL=xml-writer.cjs.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/dist/src/coverage/types.js b/v-next/hardhat-vendored/dist/src/coverage/types.js deleted file mode 100644 index 718fd38ae40..00000000000 --- a/v-next/hardhat-vendored/dist/src/coverage/types.js +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/v-next/hardhat-vendored/node_modules/@types/bn.js b/v-next/hardhat-vendored/node_modules/@types/bn.js deleted file mode 120000 index 112e2ea8381..00000000000 --- a/v-next/hardhat-vendored/node_modules/@types/bn.js +++ /dev/null @@ -1 +0,0 @@ -../../../../node_modules/.pnpm/@types+bn.js@5.2.0/node_modules/@types/bn.js \ No newline at end of file From f78a2244769c0b72316d41366d97523ff1f77d83 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:18:29 +0100 Subject: [PATCH 20/32] fix package name and imports --- pnpm-lock.yaml | 6 +++--- v-next/hardhat-vendored/package.json | 6 +++--- v-next/hardhat/package.json | 2 +- v-next/hardhat/tsconfig.json | 3 +++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df3ef48afd8..e8f02bbc9b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,9 +152,9 @@ importers: '@nomicfoundation/hardhat-utils': specifier: workspace:^3.0.2 version: link:../hardhat-utils - '@nomicfoundation/hardhat-vendors': + '@nomicfoundation/hardhat-vendored': specifier: workspace:^3.0.0 - version: link:../hardhat-vendors + version: link:../hardhat-vendored '@nomicfoundation/hardhat-zod-utils': specifier: workspace:^3.0.1 version: link:../hardhat-zod-utils @@ -1380,7 +1380,7 @@ importers: specifier: ~5.8.0 version: 5.8.3 - v-next/hardhat-vendors: + v-next/hardhat-vendored: devDependencies: '@nomicfoundation/hardhat-node-test-reporter': specifier: workspace:^3.0.0 diff --git a/v-next/hardhat-vendored/package.json b/v-next/hardhat-vendored/package.json index 2652066bd14..56365e6b990 100644 --- a/v-next/hardhat-vendored/package.json +++ b/v-next/hardhat-vendored/package.json @@ -1,12 +1,12 @@ { - "name": "@nomicfoundation/hardhat-vendors", + "name": "@nomicfoundation/hardhat-vendored", "version": "3.0.0", "description": "Internal dependencies used by Hardhat that have been vendored to prevent bloating the main package", - "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-vendors", + "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-vendored", "repository": { "type": "git", "url": "https://github.com/NomicFoundation/hardhat", - "directory": "v-next/hardhat-vendors" + "directory": "v-next/hardhat-vendored" }, "author": "Nomic Foundation", "license": "MIT", diff --git a/v-next/hardhat/package.json b/v-next/hardhat/package.json index c0603c6745a..e7907cefb69 100644 --- a/v-next/hardhat/package.json +++ b/v-next/hardhat/package.json @@ -90,7 +90,7 @@ "@nomicfoundation/edr": "0.12.0-next.7", "@nomicfoundation/hardhat-errors": "workspace:^3.0.2", "@nomicfoundation/hardhat-utils": "workspace:^3.0.2", - "@nomicfoundation/hardhat-vendors": "workspace:^3.0.0", + "@nomicfoundation/hardhat-vendored": "workspace:^3.0.0", "@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.1", "@nomicfoundation/solidity-analyzer": "^0.1.1", "@sentry/core": "^9.4.0", diff --git a/v-next/hardhat/tsconfig.json b/v-next/hardhat/tsconfig.json index 1304945c475..4c467a04557 100644 --- a/v-next/hardhat/tsconfig.json +++ b/v-next/hardhat/tsconfig.json @@ -15,6 +15,9 @@ }, { "path": "../hardhat-zod-utils" + }, + { + "path": "../hardhat-vendored" } ], "exclude": [ From b28430af364b87f791eede898bdcff9cb87c5754 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:53:28 +0100 Subject: [PATCH 21/32] rename folder to avoid gitignore --- v-next/hardhat-vendored/.gitignore | 5 --- .../html-escaper/index.cjs | 0 .../{coverage => coverage-module}/index.js | 0 .../istanbul-reports/index.cjs | 0 .../istanbul-reports/lib/html/annotator.cjs | 0 .../istanbul-reports/lib/html/assets/base.css | 0 .../lib/html/assets/block-navigation.js | 0 .../lib/html/assets/favicon.png | Bin .../lib/html/assets/sort-arrow-sprite.png | Bin .../lib/html/assets/sorter.js | 0 .../lib/html/assets/vendor/prettify.css | 0 .../lib/html/assets/vendor/prettify.js | 0 .../istanbul-reports/lib/html/index.cjs | 0 .../lib/html/insertion-text.cjs | 0 .../lib-coverage/index.cjs | 0 .../lib-coverage/lib/coverage-map.cjs | 0 .../lib-coverage/lib/coverage-summary.cjs | 0 .../lib-coverage/lib/data-properties.cjs | 0 .../lib-coverage/lib/file-coverage.cjs | 0 .../lib-coverage/lib/percent.cjs | 0 .../lib-report/index.cjs | 0 .../lib-report/lib/context.cjs | 0 .../lib-report/lib/file-writer.cjs | 0 .../lib-report/lib/path.cjs | 0 .../lib-report/lib/report-base.cjs | 0 .../lib-report/lib/summarizer-factory.cjs | 0 .../lib-report/lib/tree.cjs | 0 .../lib-report/lib/watermarks.cjs | 0 .../lib-report/lib/xml-writer.cjs | 0 .../src/coverage-module/types.ts | 33 ++++++++++++++++++ v-next/hardhat-vendored/tsconfig.json | 3 +- 31 files changed, 34 insertions(+), 7 deletions(-) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/html-escaper/index.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/index.js (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/index.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/annotator.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/base.css (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/block-navigation.js (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/favicon.png (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/sort-arrow-sprite.png (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/sorter.js (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/vendor/prettify.css (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/assets/vendor/prettify.js (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/index.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/istanbul-reports/lib/html/insertion-text.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-coverage/index.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-coverage/lib/coverage-map.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-coverage/lib/coverage-summary.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-coverage/lib/data-properties.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-coverage/lib/file-coverage.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-coverage/lib/percent.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/index.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/context.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/file-writer.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/path.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/report-base.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/summarizer-factory.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/tree.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/watermarks.cjs (100%) rename v-next/hardhat-vendored/src/{coverage => coverage-module}/lib-report/lib/xml-writer.cjs (100%) create mode 100644 v-next/hardhat-vendored/src/coverage-module/types.ts diff --git a/v-next/hardhat-vendored/.gitignore b/v-next/hardhat-vendored/.gitignore index 63488e0e6e0..0e1706cfcd7 100644 --- a/v-next/hardhat-vendored/.gitignore +++ b/v-next/hardhat-vendored/.gitignore @@ -12,8 +12,3 @@ coverage # all the tmp folders in the fixture projects /test/fixture-projects/tmp/ - -!src/**/*.js -!src/**/*.cjs -!src/**/*.css -!src/**/*.png diff --git a/v-next/hardhat-vendored/src/coverage/html-escaper/index.cjs b/v-next/hardhat-vendored/src/coverage-module/html-escaper/index.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/html-escaper/index.cjs rename to v-next/hardhat-vendored/src/coverage-module/html-escaper/index.cjs diff --git a/v-next/hardhat-vendored/src/coverage/index.js b/v-next/hardhat-vendored/src/coverage-module/index.js similarity index 100% rename from v-next/hardhat-vendored/src/coverage/index.js rename to v-next/hardhat-vendored/src/coverage-module/index.js diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/index.cjs b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/index.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/index.cjs rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/index.cjs diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/annotator.cjs b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/annotator.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/annotator.cjs rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/annotator.cjs diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/base.css b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/base.css similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/base.css rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/base.css diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/block-navigation.js similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/block-navigation.js rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/block-navigation.js diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/favicon.png b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/favicon.png similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/favicon.png rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/favicon.png diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sort-arrow-sprite.png similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sort-arrow-sprite.png rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sort-arrow-sprite.png diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sorter.js similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/sorter.js rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sorter.js diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.css similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.css rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.css diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.js similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/assets/vendor/prettify.js rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.js diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/index.cjs b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/index.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/index.cjs rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/index.cjs diff --git a/v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/insertion-text.cjs b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/insertion-text.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/istanbul-reports/lib/html/insertion-text.cjs rename to v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/insertion-text.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/index.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-coverage/index.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-coverage/index.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-coverage/index.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-map.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/coverage-map.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-map.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/coverage-map.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-summary.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/coverage-summary.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-coverage/lib/coverage-summary.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/coverage-summary.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/data-properties.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/data-properties.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-coverage/lib/data-properties.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/data-properties.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/file-coverage.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/file-coverage.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-coverage/lib/file-coverage.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/file-coverage.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-coverage/lib/percent.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/percent.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-coverage/lib/percent.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-coverage/lib/percent.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/index.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/index.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/index.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/index.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/context.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/context.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/context.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/context.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/file-writer.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/file-writer.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/file-writer.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/file-writer.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/path.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/path.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/path.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/path.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/report-base.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/report-base.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/report-base.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/report-base.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/summarizer-factory.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/summarizer-factory.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/summarizer-factory.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/summarizer-factory.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/tree.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/tree.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/tree.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/tree.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/watermarks.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/watermarks.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/watermarks.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/watermarks.cjs diff --git a/v-next/hardhat-vendored/src/coverage/lib-report/lib/xml-writer.cjs b/v-next/hardhat-vendored/src/coverage-module/lib-report/lib/xml-writer.cjs similarity index 100% rename from v-next/hardhat-vendored/src/coverage/lib-report/lib/xml-writer.cjs rename to v-next/hardhat-vendored/src/coverage-module/lib-report/lib/xml-writer.cjs diff --git a/v-next/hardhat-vendored/src/coverage-module/types.ts b/v-next/hardhat-vendored/src/coverage-module/types.ts new file mode 100644 index 00000000000..33e9f5b5655 --- /dev/null +++ b/v-next/hardhat-vendored/src/coverage-module/types.ts @@ -0,0 +1,33 @@ +export interface Location { + line: number; + column: number; +} + +export interface Range { + start: Location; + end: Location; +} + +export interface FunctionMapping { + name: string; + decl: Range; + loc: Range; + line: number; +} + +export interface BranchMapping { + loc: Range; + type: string; + locations: Range[]; + line: number; +} + +export interface FileCoverageData { + path: string; + statementMap: { [key: string]: Range }; + fnMap: { [key: string]: FunctionMapping }; + branchMap: { [key: string]: BranchMapping }; + s: { [key: string]: number }; + f: { [key: string]: number }; + b: { [key: string]: number[] }; +} diff --git a/v-next/hardhat-vendored/tsconfig.json b/v-next/hardhat-vendored/tsconfig.json index bb8c328bb79..9e2ba282479 100644 --- a/v-next/hardhat-vendored/tsconfig.json +++ b/v-next/hardhat-vendored/tsconfig.json @@ -4,6 +4,5 @@ "isolatedDeclarations": false, "allowJs": true }, - "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts"], - "references": [] + "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts"] } From 8c92ef98f2804f1c2dba44e3add24f25ae0d2a58 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:54:53 +0100 Subject: [PATCH 22/32] fix copy-assets --- v-next/hardhat-vendored/src/copy-assets.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v-next/hardhat-vendored/src/copy-assets.ts b/v-next/hardhat-vendored/src/copy-assets.ts index d25dc2610ca..0a5bdb3705b 100644 --- a/v-next/hardhat-vendored/src/copy-assets.ts +++ b/v-next/hardhat-vendored/src/copy-assets.ts @@ -14,7 +14,7 @@ await copyFolder( path.resolve( process.cwd(), "src", - "coverage", + "coverage-module", "istanbul-reports", "lib", "html", @@ -24,7 +24,7 @@ await copyFolder( process.cwd(), "dist", "src", - "coverage", + "coverage-module", "istanbul-reports", "lib", "html", From 022c6ae7b515a9652891dbd5a4e72a48225df624 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:59:44 +0100 Subject: [PATCH 23/32] fix exports after changing folder name --- v-next/hardhat-vendored/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v-next/hardhat-vendored/package.json b/v-next/hardhat-vendored/package.json index 56365e6b990..47785970966 100644 --- a/v-next/hardhat-vendored/package.json +++ b/v-next/hardhat-vendored/package.json @@ -12,8 +12,8 @@ "license": "MIT", "type": "module", "exports": { - "./coverage": "./dist/src/coverage/index.js", - "./coverage/types": "./dist/src/coverage/types.js" + "./coverage": "./dist/src/coverage-module/index.js", + "./coverage/types": "./dist/src/coverage-module/types.js" }, "keywords": [ "hardhat" From a50b3b86b407f20c9e3f690c37d135f30804c562 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 27 Oct 2025 16:09:13 +0100 Subject: [PATCH 24/32] show colored lines in coverage report --- .../coverage/coverage-manager.ts | 58 ++++++++----------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts index 28dbc6b5d6c..2c34a10876a 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts @@ -5,7 +5,7 @@ import type { Statement, Tag, } from "./types.js"; -import type { FileCoverageData } from "@nomicfoundation/hardhat-vendors/coverage/types"; +import type { FileCoverageData } from "@nomicfoundation/hardhat-vendored/coverage/types"; import path from "node:path"; @@ -15,7 +15,6 @@ import { getAllFilesMatching, mkdir, readJsonFile, - readUtf8File, remove, writeJsonFile, writeUtf8File, @@ -24,7 +23,7 @@ import { libCoverage, libReport, reports, -} from "@nomicfoundation/hardhat-vendors/coverage"; +} from "@nomicfoundation/hardhat-vendored/coverage"; import debug from "debug"; const log = debug("hardhat:core:coverage:coverage-manager"); @@ -573,43 +572,32 @@ export class CoverageManagerImplementation implements CoverageManager { for (const [p, fileCoverageInput] of Object.entries(report)) { const testedFilePath = path.isAbsolute(p) ? p : path.join(baseDir, p); - const sourceLines = (await readUtf8File(testedFilePath)).split(/\r?\n/); - - // Build the set of line candidates we want to color - const linesToColor = Array.from( - new Set([ - ...fileCoverageInput.lineExecutionCounts.keys(), - ...fileCoverageInput.unexecutedLines, - ]), - ); - - const statementMap: FileCoverageData["statementMap"] = {}; - const s: FileCoverageData["s"] = {}; - - for (const lineNo of linesToColor) { - const id = `${lineNo}`; - const endCol = sourceLines[lineNo - 1]?.length ?? 0; - - statementMap[id] = { - start: { line: lineNo, column: 0 }, - end: { line: lineNo, column: endCol }, - }; - - const hits = fileCoverageInput.lineExecutionCounts.get(lineNo) ?? 0; - s[id] = hits > 0 ? 1 : 0; // green if hit, red if not - } - - const fileCoverage: FileCoverageData = { + const fc: FileCoverageData = { path: testedFilePath, - statementMap, - s, - fnMap: {}, - f: {}, + statementMap: {}, + fnMap: {}, // Cannot be derived from current report data branchMap: {}, + s: {}, + f: {}, // Cannot be derived from current report data b: {}, }; - coverageMap.addFileCoverage(fileCoverage); + for (const [line, count] of fileCoverageInput.lineExecutionCounts) { + fc.statementMap[line] = { + start: { line, column: 0 }, + end: { line, column: 0 }, + }; + + if (fileCoverageInput.partiallyExecutedLines.has(line)) { + fc.s[line] = 0; // mark as not covered + continue; + } + + // TODO: bug line count + fc.s[line] = count > 0 ? 1 : 0; // mark as covered if hit at least once + } + + coverageMap.addFileCoverage(fc); } await mkdir(htmlReportPath); From 0b89710481fff2ce420348f4381fac5003e84683 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:11:53 +0100 Subject: [PATCH 25/32] update tsconfig in new vendored package --- v-next/hardhat-vendored/tsconfig.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/v-next/hardhat-vendored/tsconfig.json b/v-next/hardhat-vendored/tsconfig.json index 9e2ba282479..62009fa15a1 100644 --- a/v-next/hardhat-vendored/tsconfig.json +++ b/v-next/hardhat-vendored/tsconfig.json @@ -1,8 +1,13 @@ { "extends": "../config/tsconfig.base.json", "compilerOptions": { + "allowJs": true, "isolatedDeclarations": false, - "allowJs": true + "skipDefaultLibCheck": true, + "sourceMap": true, + "composite": true, + "incremental": true, + "typeRoots": ["${configDir}/node_modules/@types"] }, "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts"] } From 50f3b4cfb3acb28f359ca0b31ce27c5ea5b5af40 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:33:48 +0100 Subject: [PATCH 26/32] minor fixes --- v-next/hardhat-vendored/CHANGELOG.md | 0 v-next/hardhat-vendored/README.md | 5 +++++ v-next/hardhat-vendored/tsconfig.json | 4 ++++ v-next/hardhat/package.json | 1 - 4 files changed, 9 insertions(+), 1 deletion(-) delete mode 100644 v-next/hardhat-vendored/CHANGELOG.md diff --git a/v-next/hardhat-vendored/CHANGELOG.md b/v-next/hardhat-vendored/CHANGELOG.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/v-next/hardhat-vendored/README.md b/v-next/hardhat-vendored/README.md index e69de29bb2d..eefc9c0fc08 100644 --- a/v-next/hardhat-vendored/README.md +++ b/v-next/hardhat-vendored/README.md @@ -0,0 +1,5 @@ +# hardhat-vendored + +> ⚠️ This package is an internal Hardhat component and it's not meant to be used directly. + +This package contains vendored code used by Hardhat 3 and its plugins. diff --git a/v-next/hardhat-vendored/tsconfig.json b/v-next/hardhat-vendored/tsconfig.json index 62009fa15a1..0ec21022bf2 100644 --- a/v-next/hardhat-vendored/tsconfig.json +++ b/v-next/hardhat-vendored/tsconfig.json @@ -2,7 +2,11 @@ "extends": "../config/tsconfig.base.json", "compilerOptions": { "allowJs": true, + "outDir": "${configDir}/dist", + "declaration": true, + "declarationMap": true, "isolatedDeclarations": false, + "noEmitOnError": true, "skipDefaultLibCheck": true, "sourceMap": true, "composite": true, diff --git a/v-next/hardhat/package.json b/v-next/hardhat/package.json index e7907cefb69..a1fe55fa1b4 100644 --- a/v-next/hardhat/package.json +++ b/v-next/hardhat/package.json @@ -63,7 +63,6 @@ "files": [ "dist/src/", "src/", - "assets/", "templates/", "console.sol", "coverage.sol", From 3602408a65ff736832c9ddbb1430a110f2ddd9d3 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 3 Nov 2025 15:39:39 +0100 Subject: [PATCH 27/32] lint:fix --- .../lib/html/assets/block-navigation.js | 136 ++- .../lib/html/assets/sorter.js | 385 ++++--- .../lib/html/assets/vendor/prettify.js | 1008 ++++++++++++++++- v-next/hardhat-vendored/test/index.ts | 0 v-next/hardhat-vendored/tsconfig.json | 2 +- 5 files changed, 1267 insertions(+), 264 deletions(-) create mode 100644 v-next/hardhat-vendored/test/index.ts diff --git a/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/block-navigation.js b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/block-navigation.js index eb527848ee7..87318286218 100644 --- a/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/block-navigation.js +++ b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/block-navigation.js @@ -1,86 +1,84 @@ var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = [".cbranch-no", ".cstat-no", ".fstat-no"]; - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; + // Elements to highlight in the file listing view + var fileListingElements = ["td.pct.low"]; - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + // We don't want to select elements that are direct descendants of another match + var notSelector = ":not(" + missingCoverageClasses.join("):not(") + ") > "; // becomes `:not(a):not(b) > ` - // Selector that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(", ") + + ", " + + notSelector + + missingCoverageClasses.join(", " + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); - var currentIndex; + var currentIndex; - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } + function toggleClass(index) { + missingCoverageElements.item(currentIndex).classList.remove("highlighted"); + missingCoverageElements.item(index).classList.add("highlighted"); + } - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: "smooth", + block: "center", + inline: "center", + }); + } - makeCurrent(nextIndex); + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== "number" || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; } - function goToNext() { - var nextIndex = 0; + makeCurrent(nextIndex); + } - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } + function goToNext() { + var nextIndex = 0; - makeCurrent(nextIndex); + if ( + typeof currentIndex === "number" && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; } - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } + makeCurrent(nextIndex); + } - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; + return function jump(event) { + if ( + document.getElementById("fileSearch") === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; })(); -window.addEventListener('keydown', jumpToCode); +window.addEventListener("keydown", jumpToCode); diff --git a/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sorter.js b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sorter.js index 83122f78ace..d81817f4a29 100644 --- a/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sorter.js +++ b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/sorter.js @@ -1,209 +1,208 @@ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; +var addSorting = (function () { + "use strict"; + var cols, + currentSort = { + index: 0, + desc: false, + }; - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); + // returns the summary table element + function getTable() { + return document.querySelector(".coverage-summary"); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector("thead tr"); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector("tbody"); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll("th")[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById("fileSearch").value; + const rows = document.getElementsByTagName("tbody")[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, "i"); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - - // Try to create a RegExp from the searchValue. If it fails (invalid regex), - // it will be treated as a plain text search - let searchRegex; - try { - searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive - } catch (error) { - searchRegex = null; - } - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - let isMatch = false; - - if (searchRegex) { - // If a valid regex was created, use it for matching - isMatch = searchRegex.test(row.textContent); - } else { - // Otherwise, fall back to the original plain text search - isMatch = row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()); - } - - row.style.display = isMatch ? '' : 'none'; - } + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? "" : "none"; } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById("filterTemplate"); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById("fileSearch").oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll("th"), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute("data-col"), + sortable: !colNode.getAttribute("data-nosort"), + type: colNode.getAttribute("data-type") || "string", + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === "number"; + colNode.innerHTML = colNode.innerHTML + ''; + } } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll("td"), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute("data-value"); + if (col.type === "number") { + val = Number(val); + } + data[col.key] = val; } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll("tr"), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function (a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector(".coverage-summary tbody"), + rowNodes = tableBody.querySelectorAll("tr"), + rows = [], + i; + + if (desc) { + finalSorter = function (a, b) { + return -1 * sorter(a, b); + }; } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, "").replace(/ sorted-desc$/, ""); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? " sorted-desc" + : " sorted"; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector(".sorter").parentElement; + if (el.addEventListener) { + el.addEventListener("click", ithSorter(i)); + } else { + el.attachEvent("onclick", ithSorter(i)); } + } } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; })(); -window.addEventListener('load', addSorting); +window.addEventListener("load", addSorting); diff --git a/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.js b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.js index ef51e038668..3a089bd521f 100644 --- a/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.js +++ b/v-next/hardhat-vendored/src/coverage-module/istanbul-reports/lib/html/assets/vendor/prettify.js @@ -1 +1,1007 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); +window.PR_SHOULD_USE_CONTINUATION = true; +(function () { + var h = ["break,continue,do,else,for,if,return,while"]; + var u = [ + h, + "auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile", + ]; + var p = [ + u, + "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof", + ]; + var l = [ + p, + "alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where", + ]; + var x = [ + p, + "abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient", + ]; + var R = [ + x, + "as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var", + ]; + var r = + "all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes"; + var w = [ + p, + "debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN", + ]; + var s = + "caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"; + var I = [ + h, + "and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None", + ]; + var f = [ + h, + "alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END", + ]; + var H = [h, "case,done,elif,esac,eval,fi,function,in,local,set,then,until"]; + var A = [l, R, w, s + I, f, H]; + var e = + /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/; + var C = "str"; + var z = "kwd"; + var j = "com"; + var O = "typ"; + var G = "lit"; + var L = "pun"; + var F = "pln"; + var m = "tag"; + var E = "dec"; + var J = "src"; + var P = "atn"; + var n = "atv"; + var N = "nocode"; + var M = + "(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*"; + function k(Z) { + var ad = 0; + var S = false; + var ac = false; + for (var V = 0, U = Z.length; V < U; ++V) { + var ae = Z[V]; + if (ae.ignoreCase) { + ac = true; + } else { + if ( + /[a-z]/i.test( + ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ""), + ) + ) { + S = true; + ac = false; + break; + } + } + } + var Y = { b: 8, t: 9, n: 10, v: 11, f: 12, r: 13 }; + function ab(ah) { + var ag = ah.charCodeAt(0); + if (ag !== 92) { + return ag; + } + var af = ah.charAt(1); + ag = Y[af]; + if (ag) { + return ag; + } else { + if ("0" <= af && af <= "7") { + return parseInt(ah.substring(1), 8); + } else { + if (af === "u" || af === "x") { + return parseInt(ah.substring(2), 16); + } else { + return ah.charCodeAt(1); + } + } + } + } + function T(af) { + if (af < 32) { + return (af < 16 ? "\\x0" : "\\x") + af.toString(16); + } + var ag = String.fromCharCode(af); + if (ag === "\\" || ag === "-" || ag === "[" || ag === "]") { + ag = "\\" + ag; + } + return ag; + } + function X(am) { + var aq = am + .substring(1, am.length - 1) + .match( + new RegExp( + "\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", + "g", + ), + ); + var ak = []; + var af = []; + var ao = aq[0] === "^"; + for (var ar = ao ? 1 : 0, aj = aq.length; ar < aj; ++ar) { + var ah = aq[ar]; + if (/\\[bdsw]/i.test(ah)) { + ak.push(ah); + } else { + var ag = ab(ah); + var al; + if (ar + 2 < aj && "-" === aq[ar + 1]) { + al = ab(aq[ar + 2]); + ar += 2; + } else { + al = ag; + } + af.push([ag, al]); + if (!(al < 65 || ag > 122)) { + if (!(al < 65 || ag > 90)) { + af.push([Math.max(65, ag) | 32, Math.min(al, 90) | 32]); + } + if (!(al < 97 || ag > 122)) { + af.push([Math.max(97, ag) & ~32, Math.min(al, 122) & ~32]); + } + } + } + } + af.sort(function (av, au) { + return av[0] - au[0] || au[1] - av[1]; + }); + var ai = []; + var ap = [NaN, NaN]; + for (var ar = 0; ar < af.length; ++ar) { + var at = af[ar]; + if (at[0] <= ap[1] + 1) { + ap[1] = Math.max(ap[1], at[1]); + } else { + ai.push((ap = at)); + } + } + var an = ["["]; + if (ao) { + an.push("^"); + } + an.push.apply(an, ak); + for (var ar = 0; ar < ai.length; ++ar) { + var at = ai[ar]; + an.push(T(at[0])); + if (at[1] > at[0]) { + if (at[1] + 1 > at[0]) { + an.push("-"); + } + an.push(T(at[1])); + } + } + an.push("]"); + return an.join(""); + } + function W(al) { + var aj = al.source.match( + new RegExp( + "(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", + "g", + ), + ); + var ah = aj.length; + var an = []; + for (var ak = 0, am = 0; ak < ah; ++ak) { + var ag = aj[ak]; + if (ag === "(") { + ++am; + } else { + if ("\\" === ag.charAt(0)) { + var af = +ag.substring(1); + if (af && af <= am) { + an[af] = -1; + } + } + } + } + for (var ak = 1; ak < an.length; ++ak) { + if (-1 === an[ak]) { + an[ak] = ++ad; + } + } + for (var ak = 0, am = 0; ak < ah; ++ak) { + var ag = aj[ak]; + if (ag === "(") { + ++am; + if (an[am] === undefined) { + aj[ak] = "(?:"; + } + } else { + if ("\\" === ag.charAt(0)) { + var af = +ag.substring(1); + if (af && af <= am) { + aj[ak] = "\\" + an[am]; + } + } + } + } + for (var ak = 0, am = 0; ak < ah; ++ak) { + if ("^" === aj[ak] && "^" !== aj[ak + 1]) { + aj[ak] = ""; + } + } + if (al.ignoreCase && S) { + for (var ak = 0; ak < ah; ++ak) { + var ag = aj[ak]; + var ai = ag.charAt(0); + if (ag.length >= 2 && ai === "[") { + aj[ak] = X(ag); + } else { + if (ai !== "\\") { + aj[ak] = ag.replace(/[a-zA-Z]/g, function (ao) { + var ap = ao.charCodeAt(0); + return "[" + String.fromCharCode(ap & ~32, ap | 32) + "]"; + }); + } + } + } + } + return aj.join(""); + } + var aa = []; + for (var V = 0, U = Z.length; V < U; ++V) { + var ae = Z[V]; + if (ae.global || ae.multiline) { + throw new Error("" + ae); + } + aa.push("(?:" + W(ae) + ")"); + } + return new RegExp(aa.join("|"), ac ? "gi" : "g"); + } + function a(V) { + var U = /(?:^|\s)nocode(?:\s|$)/; + var X = []; + var T = 0; + var Z = []; + var W = 0; + var S; + if (V.currentStyle) { + S = V.currentStyle.whiteSpace; + } else { + if (window.getComputedStyle) { + S = document.defaultView + .getComputedStyle(V, null) + .getPropertyValue("white-space"); + } + } + var Y = S && "pre" === S.substring(0, 3); + function aa(ab) { + switch (ab.nodeType) { + case 1: + if (U.test(ab.className)) { + return; + } + for (var ae = ab.firstChild; ae; ae = ae.nextSibling) { + aa(ae); + } + var ad = ab.nodeName; + if ("BR" === ad || "LI" === ad) { + X[W] = "\n"; + Z[W << 1] = T++; + Z[(W++ << 1) | 1] = ab; + } + break; + case 3: + case 4: + var ac = ab.nodeValue; + if (ac.length) { + if (!Y) { + ac = ac.replace(/[ \t\r\n]+/g, " "); + } else { + ac = ac.replace(/\r\n?/g, "\n"); + } + X[W] = ac; + Z[W << 1] = T; + T += ac.length; + Z[(W++ << 1) | 1] = ab; + } + break; + } + } + aa(V); + return { sourceCode: X.join("").replace(/\n$/, ""), spans: Z }; + } + function B(S, U, W, T) { + if (!U) { + return; + } + var V = { sourceCode: U, basePos: S }; + W(V); + T.push.apply(T, V.decorations); + } + var v = /\S/; + function o(S) { + var V = undefined; + for (var U = S.firstChild; U; U = U.nextSibling) { + var T = U.nodeType; + V = T === 1 ? (V ? S : U) : T === 3 ? (v.test(U.nodeValue) ? S : V) : V; + } + return V === S ? undefined : V; + } + function g(U, T) { + var S = {}; + var V; + (function () { + var ad = U.concat(T); + var ah = []; + var ag = {}; + for (var ab = 0, Z = ad.length; ab < Z; ++ab) { + var Y = ad[ab]; + var ac = Y[3]; + if (ac) { + for (var ae = ac.length; --ae >= 0; ) { + S[ac.charAt(ae)] = Y; + } + } + var af = Y[1]; + var aa = "" + af; + if (!ag.hasOwnProperty(aa)) { + ah.push(af); + ag[aa] = null; + } + } + ah.push(/[\0-\uffff]/); + V = k(ah); + })(); + var X = T.length; + var W = function (ah) { + var Z = ah.sourceCode, + Y = ah.basePos; + var ad = [Y, F]; + var af = 0; + var an = Z.match(V) || []; + var aj = {}; + for (var ae = 0, aq = an.length; ae < aq; ++ae) { + var ag = an[ae]; + var ap = aj[ag]; + var ai = void 0; + var am; + if (typeof ap === "string") { + am = false; + } else { + var aa = S[ag.charAt(0)]; + if (aa) { + ai = ag.match(aa[1]); + ap = aa[0]; + } else { + for (var ao = 0; ao < X; ++ao) { + aa = T[ao]; + ai = ag.match(aa[1]); + if (ai) { + ap = aa[0]; + break; + } + } + if (!ai) { + ap = F; + } + } + am = ap.length >= 5 && "lang-" === ap.substring(0, 5); + if (am && !(ai && typeof ai[1] === "string")) { + am = false; + ap = J; + } + if (!am) { + aj[ag] = ap; + } + } + var ab = af; + af += ag.length; + if (!am) { + ad.push(Y + ab, ap); + } else { + var al = ai[1]; + var ak = ag.indexOf(al); + var ac = ak + al.length; + if (ai[2]) { + ac = ag.length - ai[2].length; + ak = ac - al.length; + } + var ar = ap.substring(5); + B(Y + ab, ag.substring(0, ak), W, ad); + B(Y + ab + ak, al, q(ar, al), ad); + B(Y + ab + ac, ag.substring(ac), W, ad); + } + } + ah.decorations = ad; + }; + return W; + } + function i(T) { + var W = [], + S = []; + if (T.tripleQuotedStrings) { + W.push([ + C, + /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/, + null, + "'\"", + ]); + } else { + if (T.multiLineStrings) { + W.push([ + C, + /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/, + null, + "'\"`", + ]); + } else { + W.push([ + C, + /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, + null, + "\"'", + ]); + } + } + if (T.verbatimStrings) { + S.push([C, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]); + } + var Y = T.hashComments; + if (Y) { + if (T.cStyleComments) { + if (Y > 1) { + W.push([j, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, "#"]); + } else { + W.push([ + j, + /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/, + null, + "#", + ]); + } + S.push([ + C, + /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, + null, + ]); + } else { + W.push([j, /^#[^\r\n]*/, null, "#"]); + } + } + if (T.cStyleComments) { + S.push([j, /^\/\/[^\r\n]*/, null]); + S.push([j, /^\/\*[\s\S]*?(?:\*\/|$)/, null]); + } + if (T.regexLiterals) { + var X = + "/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/"; + S.push(["lang-regex", new RegExp("^" + M + "(" + X + ")")]); + } + var V = T.types; + if (V) { + S.push([O, V]); + } + var U = ("" + T.keywords).replace(/^ | $/g, ""); + if (U.length) { + S.push([ + z, + new RegExp("^(?:" + U.replace(/[\s,]+/g, "|") + ")\\b"), + null, + ]); + } + W.push([F, /^\s+/, null, " \r\n\t\xA0"]); + S.push( + [G, /^@[a-z_$][a-z_$@0-9]*/i, null], + [O, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null], + [F, /^[a-z_$][a-z_$@0-9]*/i, null], + [ + G, + new RegExp( + "^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*", + "i", + ), + null, + "0123456789", + ], + [F, /^\\[\s\S]?/, null], + [L, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null], + ); + return g(W, S); + } + var K = i({ + keywords: A, + hashComments: true, + cStyleComments: true, + multiLineStrings: true, + regexLiterals: true, + }); + function Q(V, ag) { + var U = /(?:^|\s)nocode(?:\s|$)/; + var ab = /\r\n?|\n/; + var ac = V.ownerDocument; + var S; + if (V.currentStyle) { + S = V.currentStyle.whiteSpace; + } else { + if (window.getComputedStyle) { + S = ac.defaultView + .getComputedStyle(V, null) + .getPropertyValue("white-space"); + } + } + var Z = S && "pre" === S.substring(0, 3); + var af = ac.createElement("LI"); + while (V.firstChild) { + af.appendChild(V.firstChild); + } + var W = [af]; + function ae(al) { + switch (al.nodeType) { + case 1: + if (U.test(al.className)) { + break; + } + if ("BR" === al.nodeName) { + ad(al); + if (al.parentNode) { + al.parentNode.removeChild(al); + } + } else { + for (var an = al.firstChild; an; an = an.nextSibling) { + ae(an); + } + } + break; + case 3: + case 4: + if (Z) { + var am = al.nodeValue; + var aj = am.match(ab); + if (aj) { + var ai = am.substring(0, aj.index); + al.nodeValue = ai; + var ah = am.substring(aj.index + aj[0].length); + if (ah) { + var ak = al.parentNode; + ak.insertBefore(ac.createTextNode(ah), al.nextSibling); + } + ad(al); + if (!ai) { + al.parentNode.removeChild(al); + } + } + } + break; + } + } + function ad(ak) { + while (!ak.nextSibling) { + ak = ak.parentNode; + if (!ak) { + return; + } + } + function ai(al, ar) { + var aq = ar ? al.cloneNode(false) : al; + var ao = al.parentNode; + if (ao) { + var ap = ai(ao, 1); + var an = al.nextSibling; + ap.appendChild(aq); + for (var am = an; am; am = an) { + an = am.nextSibling; + ap.appendChild(am); + } + } + return aq; + } + var ah = ai(ak.nextSibling, 0); + for (var aj; (aj = ah.parentNode) && aj.nodeType === 1; ) { + ah = aj; + } + W.push(ah); + } + for (var Y = 0; Y < W.length; ++Y) { + ae(W[Y]); + } + if (ag === (ag | 0)) { + W[0].setAttribute("value", ag); + } + var aa = ac.createElement("OL"); + aa.className = "linenums"; + var X = Math.max(0, (ag - 1) | 0) || 0; + for (var Y = 0, T = W.length; Y < T; ++Y) { + af = W[Y]; + af.className = "L" + ((Y + X) % 10); + if (!af.firstChild) { + af.appendChild(ac.createTextNode("\xA0")); + } + aa.appendChild(af); + } + V.appendChild(aa); + } + function D(ac) { + var aj = /\bMSIE\b/.test(navigator.userAgent); + var am = /\n/g; + var al = ac.sourceCode; + var an = al.length; + var V = 0; + var aa = ac.spans; + var T = aa.length; + var ah = 0; + var X = ac.decorations; + var Y = X.length; + var Z = 0; + X[Y] = an; + var ar, aq; + for (aq = ar = 0; aq < Y; ) { + if (X[aq] !== X[aq + 2]) { + X[ar++] = X[aq++]; + X[ar++] = X[aq++]; + } else { + aq += 2; + } + } + Y = ar; + for (aq = ar = 0; aq < Y; ) { + var at = X[aq]; + var ab = X[aq + 1]; + var W = aq + 2; + while (W + 2 <= Y && X[W + 1] === ab) { + W += 2; + } + X[ar++] = at; + X[ar++] = ab; + aq = W; + } + Y = X.length = ar; + var ae = null; + while (ah < T) { + var af = aa[ah]; + var S = aa[ah + 2] || an; + var ag = X[Z]; + var ap = X[Z + 2] || an; + var W = Math.min(S, ap); + var ak = aa[ah + 1]; + var U; + if (ak.nodeType !== 1 && (U = al.substring(V, W))) { + if (aj) { + U = U.replace(am, "\r"); + } + ak.nodeValue = U; + var ai = ak.ownerDocument; + var ao = ai.createElement("SPAN"); + ao.className = X[Z + 1]; + var ad = ak.parentNode; + ad.replaceChild(ao, ak); + ao.appendChild(ak); + if (V < S) { + aa[ah + 1] = ak = ai.createTextNode(al.substring(W, S)); + ad.insertBefore(ak, ao.nextSibling); + } + } + V = W; + if (V >= S) { + ah += 2; + } + if (V >= ap) { + Z += 2; + } + } + } + var t = {}; + function c(U, V) { + for (var S = V.length; --S >= 0; ) { + var T = V[S]; + if (!t.hasOwnProperty(T)) { + t[T] = U; + } else { + if (window.console) { + console.warn("cannot override language handler %s", T); + } + } + } + } + function q(T, S) { + if (!(T && t.hasOwnProperty(T))) { + T = /^\s*]*(?:>|$)/], + [j, /^<\!--[\s\S]*?(?:-\->|$)/], + ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], + ["lang-", /^<%([\s\S]+?)(?:%>|$)/], + [L, /^(?:<[%?]|[%?]>)/], + ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], + ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], + ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], + ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i], + ], + ), + ["default-markup", "htm", "html", "mxml", "xhtml", "xml", "xsl"], + ); + c( + g( + [ + [F, /^[\s]+/, null, " \t\r\n"], + [n, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, "\"'"], + ], + [ + [m, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i], + [P, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i], + ["lang-uq.val", /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/], + [L, /^[=<>\/]+/], + ["lang-js", /^on\w+\s*=\s*\"([^\"]+)\"/i], + ["lang-js", /^on\w+\s*=\s*\'([^\']+)\'/i], + ["lang-js", /^on\w+\s*=\s*([^\"\'>\s]+)/i], + ["lang-css", /^style\s*=\s*\"([^\"]+)\"/i], + ["lang-css", /^style\s*=\s*\'([^\']+)\'/i], + ["lang-css", /^style\s*=\s*([^\"\'>\s]+)/i], + ], + ), + ["in.tag"], + ); + c(g([], [[n, /^[\s\S]+/]]), ["uq.val"]); + c(i({ keywords: l, hashComments: true, cStyleComments: true, types: e }), [ + "c", + "cc", + "cpp", + "cxx", + "cyc", + "m", + ]); + c(i({ keywords: "null,true,false" }), ["json"]); + c( + i({ + keywords: R, + hashComments: true, + cStyleComments: true, + verbatimStrings: true, + types: e, + }), + ["cs"], + ); + c(i({ keywords: x, cStyleComments: true }), ["java"]); + c(i({ keywords: H, hashComments: true, multiLineStrings: true }), [ + "bsh", + "csh", + "sh", + ]); + c( + i({ + keywords: I, + hashComments: true, + multiLineStrings: true, + tripleQuotedStrings: true, + }), + ["cv", "py"], + ); + c( + i({ + keywords: s, + hashComments: true, + multiLineStrings: true, + regexLiterals: true, + }), + ["perl", "pl", "pm"], + ); + c( + i({ + keywords: f, + hashComments: true, + multiLineStrings: true, + regexLiterals: true, + }), + ["rb"], + ); + c(i({ keywords: w, cStyleComments: true, regexLiterals: true }), ["js"]); + c( + i({ + keywords: r, + hashComments: 3, + cStyleComments: true, + multilineStrings: true, + tripleQuotedStrings: true, + regexLiterals: true, + }), + ["coffee"], + ); + c(g([], [[C, /^[\s\S]+/]]), ["regex"]); + function d(V) { + var U = V.langExtension; + try { + var S = a(V.sourceNode); + var T = S.sourceCode; + V.sourceCode = T; + V.spans = S.spans; + V.basePos = 0; + q(U, T)(V); + D(V); + } catch (W) { + if ("console" in window) { + console.log(W && W.stack ? W.stack : W); + } + } + } + function y(W, V, U) { + var S = document.createElement("PRE"); + S.innerHTML = W; + if (U) { + Q(S, U); + } + var T = { langExtension: V, numberLines: U, sourceNode: S }; + d(T); + return S.innerHTML; + } + function b(ad) { + function Y(af) { + return document.getElementsByTagName(af); + } + var ac = [Y("pre"), Y("code"), Y("xmp")]; + var T = []; + for (var aa = 0; aa < ac.length; ++aa) { + for (var Z = 0, V = ac[aa].length; Z < V; ++Z) { + T.push(ac[aa][Z]); + } + } + ac = null; + var W = Date; + if (!W.now) { + W = { + now: function () { + return +new Date(); + }, + }; + } + var X = 0; + var S; + var ab = /\blang(?:uage)?-([\w.]+)(?!\S)/; + var ae = /\bprettyprint\b/; + function U() { + var ag = window.PR_SHOULD_USE_CONTINUATION ? W.now() + 250 : Infinity; + for (; X < T.length && W.now() < ag; X++) { + var aj = T[X]; + var ai = aj.className; + if (ai.indexOf("prettyprint") >= 0) { + var ah = ai.match(ab); + var am; + if (!ah && (am = o(aj)) && "CODE" === am.tagName) { + ah = am.className.match(ab); + } + if (ah) { + ah = ah[1]; + } + var al = false; + for (var ak = aj.parentNode; ak; ak = ak.parentNode) { + if ( + (ak.tagName === "pre" || + ak.tagName === "code" || + ak.tagName === "xmp") && + ak.className && + ak.className.indexOf("prettyprint") >= 0 + ) { + al = true; + break; + } + } + if (!al) { + var af = aj.className.match(/\blinenums\b(?::(\d+))?/); + af = af ? (af[1] && af[1].length ? +af[1] : true) : false; + if (af) { + Q(aj, af); + } + S = { langExtension: ah, sourceNode: aj, numberLines: af }; + d(S); + } + } + } + if (X < T.length) { + setTimeout(U, 250); + } else { + if (ad) { + ad(); + } + } + } + U(); + } + window.prettyPrintOne = y; + window.prettyPrint = b; + window.PR = { + createSimpleLexer: g, + registerLangHandler: c, + sourceDecorator: i, + PR_ATTRIB_NAME: P, + PR_ATTRIB_VALUE: n, + PR_COMMENT: j, + PR_DECLARATION: E, + PR_KEYWORD: z, + PR_LITERAL: G, + PR_NOCODE: N, + PR_PLAIN: F, + PR_PUNCTUATION: L, + PR_SOURCE: J, + PR_STRING: C, + PR_TAG: m, + PR_TYPE: O, + }; +})(); +PR.registerLangHandler( + PR.createSimpleLexer( + [], + [ + [PR.PR_DECLARATION, /^]*(?:>|$)/], + [PR.PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/], + [PR.PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/], + ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], + ["lang-", /^<%([\s\S]+?)(?:%>|$)/], + ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], + [ + "lang-handlebars", + /^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i, + ], + ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], + ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], + ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i], + [PR.PR_DECLARATION, /^{{[#^>/]?\s*[\w.][^}]*}}/], + [PR.PR_DECLARATION, /^{{&?\s*[\w.][^}]*}}/], + [PR.PR_DECLARATION, /^{{{>?\s*[\w.][^}]*}}}/], + [PR.PR_COMMENT, /^{{![^}]*}}/], + ], + ), + ["handlebars", "hbs"], +); +PR.registerLangHandler( + PR.createSimpleLexer( + [[PR.PR_PLAIN, /^[ \t\r\n\f]+/, null, " \t\r\n\f"]], + [ + [ + PR.PR_STRING, + /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, + null, + ], + [ + PR.PR_STRING, + /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, + null, + ], + ["lang-css-str", /^url\(([^\)\"\']*)\)/i], + [ + PR.PR_KEYWORD, + /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i, + null, + ], + [ + "lang-css-kw", + /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i, + ], + [PR.PR_COMMENT, /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], + [PR.PR_COMMENT, /^(?:)/], + [PR.PR_LITERAL, /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i], + [PR.PR_LITERAL, /^#(?:[0-9a-f]{3}){1,2}/i], + [ + PR.PR_PLAIN, + /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i, + ], + [PR.PR_PUNCTUATION, /^[^\s\w\'\"]+/], + ], + ), + ["css"], +); +PR.registerLangHandler( + PR.createSimpleLexer( + [], + [ + [ + PR.PR_KEYWORD, + /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i, + ], + ], + ), + ["css-kw"], +); +PR.registerLangHandler( + PR.createSimpleLexer([], [[PR.PR_STRING, /^[^\)\"\']+/]]), + ["css-str"], +); diff --git a/v-next/hardhat-vendored/test/index.ts b/v-next/hardhat-vendored/test/index.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/v-next/hardhat-vendored/tsconfig.json b/v-next/hardhat-vendored/tsconfig.json index 0ec21022bf2..7d81b7dc797 100644 --- a/v-next/hardhat-vendored/tsconfig.json +++ b/v-next/hardhat-vendored/tsconfig.json @@ -13,5 +13,5 @@ "incremental": true, "typeRoots": ["${configDir}/node_modules/@types"] }, - "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts"] + "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts", "test/**/*.ts"] } From 006f834823bf4fd0386acbbf7cd868c75756ccf4 Mon Sep 17 00:00:00 2001 From: Christopher Dedominici <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 3 Nov 2025 15:55:09 +0100 Subject: [PATCH 28/32] Create gorgeous-swans-try.md --- .changeset/gorgeous-swans-try.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/gorgeous-swans-try.md diff --git a/.changeset/gorgeous-swans-try.md b/.changeset/gorgeous-swans-try.md new file mode 100644 index 00000000000..1d344f1272b --- /dev/null +++ b/.changeset/gorgeous-swans-try.md @@ -0,0 +1,6 @@ +--- +"@nomicfoundation/hardhat": minor +"@nomicfoundation/hardhat-vendored": patch +--- + +Added HTML coverage reporting and a new internal `hardhat-vendored` package ([7528](https://github.com/NomicFoundation/hardhat/pull/7528)). From f771d34801e78b084affccbd6f59c089fea93436 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 3 Nov 2025 15:56:12 +0100 Subject: [PATCH 29/32] ignore spelling in vendored package src code --- cspell.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.yaml b/cspell.yaml index f9fb5e62d59..d43c3d613a0 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -2,3 +2,4 @@ ignorePaths: - .github/config/regression-tests.yml - archive/** - pnpm-lock.yaml + - v-next/hardhat-vendored/src From 9dde2eeba2cea0fb1dc6398689a97d11ed2a2c7b Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 3 Nov 2025 15:58:18 +0100 Subject: [PATCH 30/32] remove dependency from @nomicfoundation/hardhat-node-test-reporter --- pnpm-lock.yaml | 3 --- v-next/hardhat-vendored/package.json | 1 - 2 files changed, 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7ae86bb5cc..b687de23489 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1464,9 +1464,6 @@ importers: v-next/hardhat-vendored: devDependencies: - '@nomicfoundation/hardhat-node-test-reporter': - specifier: workspace:^3.0.0 - version: link:../hardhat-node-test-reporter '@types/bn.js': specifier: ^5.1.5 version: 5.2.0 diff --git a/v-next/hardhat-vendored/package.json b/v-next/hardhat-vendored/package.json index 47785970966..7148ce4e1e7 100644 --- a/v-next/hardhat-vendored/package.json +++ b/v-next/hardhat-vendored/package.json @@ -41,7 +41,6 @@ "README.md" ], "devDependencies": { - "@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0", "@types/bn.js": "^5.1.5", "@types/debug": "^4.1.7", "@types/node": "^20.14.9", From 7542cdc04dfaa05df2a6db8f0ab2b1cee7400e49 Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:05:36 +0100 Subject: [PATCH 31/32] add reference to test reporter --- v-next/hardhat-vendored/tsconfig.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/v-next/hardhat-vendored/tsconfig.json b/v-next/hardhat-vendored/tsconfig.json index 7d81b7dc797..14dcf739765 100644 --- a/v-next/hardhat-vendored/tsconfig.json +++ b/v-next/hardhat-vendored/tsconfig.json @@ -13,5 +13,10 @@ "incremental": true, "typeRoots": ["${configDir}/node_modules/@types"] }, - "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts", "test/**/*.ts"] + "include": ["src/**/*.js", "src/**/*.cjs", "src/**/*.ts", "test/**/*.ts"], + "references": [ + { + "path": "../hardhat-node-test-reporter" + } + ] } From f264363b3c549c7b56931548aac14e1d2e601bbf Mon Sep 17 00:00:00 2001 From: ChrisD <18092467+ChristopherDedominici@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:18:00 +0100 Subject: [PATCH 32/32] add hardhat-node-test-reporter in package.json --- pnpm-lock.yaml | 3 +++ v-next/hardhat-vendored/package.json | 1 + 2 files changed, 4 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b687de23489..c7ae86bb5cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1464,6 +1464,9 @@ importers: v-next/hardhat-vendored: devDependencies: + '@nomicfoundation/hardhat-node-test-reporter': + specifier: workspace:^3.0.0 + version: link:../hardhat-node-test-reporter '@types/bn.js': specifier: ^5.1.5 version: 5.2.0 diff --git a/v-next/hardhat-vendored/package.json b/v-next/hardhat-vendored/package.json index 7148ce4e1e7..47785970966 100644 --- a/v-next/hardhat-vendored/package.json +++ b/v-next/hardhat-vendored/package.json @@ -41,6 +41,7 @@ "README.md" ], "devDependencies": { + "@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0", "@types/bn.js": "^5.1.5", "@types/debug": "^4.1.7", "@types/node": "^20.14.9",