monocart-coverage-reports
Advanced tools
Comparing version 2.5.4 to 2.5.5
@@ -309,3 +309,3 @@ const { | ||
const { | ||
source, sourcePath, ranges, empty | ||
source, ranges, empty | ||
} = item; | ||
@@ -324,5 +324,3 @@ | ||
const time_start_parse = new Date(); | ||
const ast = parseCss(source); | ||
Util.logTime(`parse css: ${sourcePath}`, time_start_parse); | ||
@@ -329,0 +327,0 @@ addCssRules(ast.nodes, coverageList, coveredRanges, empty); |
const fs = require('fs'); | ||
const path = require('path'); | ||
const EC = require('eight-colors'); | ||
@@ -69,12 +70,45 @@ const { fileURLToPath, pathToFileURL } = require('url'); | ||
const resolveSourceMap = (data) => { | ||
if (data) { | ||
const { | ||
sources, sourcesContent, mappings | ||
} = data; | ||
if (!sources || !sourcesContent || !mappings) { | ||
return; | ||
const resolveSourcesContent = async (sources, url) => { | ||
const list = []; | ||
for (const file of sources) { | ||
const sourceUrl = Util.resolveUrl(file, url); | ||
if (sourceUrl) { | ||
const sourcePath = sourceUrl.toString(); | ||
if (sourcePath.startsWith('file:')) { | ||
const content = await Util.readFile(path.resolve(fileURLToPath(sourcePath))); | ||
list.push(content); | ||
continue; | ||
} | ||
} | ||
Util.logDebug(EC.red(`failed to load source content ${file}`)); | ||
} | ||
if (list.length === sources.length) { | ||
return list; | ||
} | ||
}; | ||
const resolveSourceMap = async (data, url) => { | ||
if (!data) { | ||
return; | ||
} | ||
const { | ||
sources, sourcesContent, mappings | ||
} = data; | ||
if (!sources || !mappings) { | ||
return; | ||
} | ||
// exists sources content | ||
if (sourcesContent && sourcesContent.length === sources.length) { | ||
return data; | ||
} | ||
// load sources content by sources | ||
const contents = await resolveSourcesContent(sources, url); | ||
if (contents) { | ||
data.sourcesContent = contents; | ||
return data; | ||
} | ||
}; | ||
@@ -96,3 +130,3 @@ | ||
let count = 0; | ||
const smList = []; | ||
const concurrency = new Concurrency(); | ||
@@ -135,4 +169,7 @@ for (const item of v8list) { | ||
if (smc) { | ||
sourceData.sourceMap = resolveSourceMap(smc.sourcemap); | ||
count += 1; | ||
sourceData.sourceMap = await resolveSourceMap(smc.sourcemap, url); | ||
smList.push({ | ||
url, | ||
inline: true | ||
}); | ||
await saveSourceFile(sourcePath, sourceData); | ||
@@ -160,7 +197,11 @@ continue; | ||
await concurrency.start(async (item) => { | ||
const sourceData = item.sourceData; | ||
const data = await loadSourceMap(item.sourceMapUrl); | ||
const { sourceMapUrl, sourceData } = item; | ||
const { url } = sourceData; | ||
const data = await loadSourceMap(sourceMapUrl); | ||
if (data) { | ||
sourceData.sourceMap = resolveSourceMap(data); | ||
count += 1; | ||
sourceData.sourceMap = await resolveSourceMap(data, url); | ||
smList.push({ | ||
url, | ||
sourceMapUrl | ||
}); | ||
} | ||
@@ -170,3 +211,3 @@ await saveSourceFile(item.sourcePath, sourceData); | ||
return count; | ||
return smList; | ||
@@ -173,0 +214,0 @@ }; |
@@ -1303,2 +1303,3 @@ /** | ||
// ============================ | ||
const time_start_ast = Date.now(); | ||
// move functions and ranges to coverageList | ||
@@ -1322,2 +1323,3 @@ let coverageList = []; | ||
} | ||
Util.logTime(`- parsed ast: ${sourcePath}`, time_start_ast); | ||
@@ -1350,3 +1352,5 @@ // console.log(sourcePath, astInfo.statements.length); | ||
const time_start_unpack = Date.now(); | ||
unpackDistFile(item, state, options); | ||
Util.logTime(`- unpacked dist: ${sourcePath}`, time_start_unpack); | ||
@@ -1357,4 +1361,7 @@ stateList.push(state); | ||
return generateV8DataList(stateList, options); | ||
const time_start_convert = Date.now(); | ||
const dataList = generateV8DataList(stateList, options); | ||
Util.logTime('- generated v8 data list', time_start_convert); | ||
return dataList; | ||
}; | ||
@@ -1361,0 +1368,0 @@ |
@@ -250,3 +250,3 @@ const fs = require('fs'); | ||
} = results; | ||
Util.logTime(`converted v8 data: ${v8DataList.length}`, time_start); | ||
Util.logTime(`converted v8 list: ${v8DataList.length}`, time_start); | ||
@@ -253,0 +253,0 @@ return generateV8ListReports(v8DataList, coverageData, fileSources, options); |
@@ -424,3 +424,3 @@ const Util = { | ||
const unit = units[i]; | ||
v = prefix + (v / min).toFixed(places) + space + unit; | ||
v = prefix + parseFloat((v / min).toFixed(places)) + space + unit; | ||
break; | ||
@@ -427,0 +427,0 @@ } |
@@ -504,6 +504,14 @@ const fs = require('fs'); | ||
logTime: (message, time_start) => { | ||
if (Util.loggingLevel < Util.loggingLevels.debug) { | ||
if (Util.loggingLevel < Util.loggingLevels.info) { | ||
return; | ||
} | ||
const slowDuration = 1000; | ||
const duration = Date.now() - time_start; | ||
if (Util.loggingLevel < Util.loggingLevels.debug) { | ||
if (duration < slowDuration) { | ||
return; | ||
} | ||
} | ||
const durationH = Util.TSF(duration); | ||
@@ -510,0 +518,0 @@ const ls = [`[MCR] ${message}`, ' (']; |
@@ -118,6 +118,7 @@ const path = require('path'); | ||
const time_start = Date.now(); | ||
const count = await collectSourceMaps(v8list, options); | ||
if (count) { | ||
const smList = await collectSourceMaps(v8list, options); | ||
if (smList.length) { | ||
// debug level time | ||
Util.logTime(`loaded sourcemaps: ${count}`, time_start); | ||
Util.logTime(`loaded sourcemaps: ${smList.length}`, time_start); | ||
// console.log(smList); | ||
} | ||
@@ -124,0 +125,0 @@ |
{ | ||
"name": "monocart-coverage-reports", | ||
"version": "2.5.4", | ||
"version": "2.5.5", | ||
"description": "Monocart coverage reports", | ||
@@ -23,3 +23,3 @@ "main": "./lib/index.js", | ||
"build": "sf lint && sf b -p && npm run build-test", | ||
"test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-vm", | ||
"test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-node-vm", | ||
"test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js", | ||
@@ -31,3 +31,3 @@ "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js", | ||
"test-node-koa": "node ./test/test-node-koa.js", | ||
"test-vm": "node ./test/test-vm.js", | ||
"test-node-vm": "node ./test/test-node-vm.js", | ||
"test-istanbul": "node ./test/test-istanbul.js", | ||
@@ -66,4 +66,4 @@ "test-v8": "node ./test/test-v8.js", | ||
"lz-utils": "~2.0.2", | ||
"monocart-code-viewer": "~1.1.0", | ||
"monocart-formatter": "~2.3.1", | ||
"monocart-code-viewer": "~1.1.1", | ||
"monocart-formatter": "~2.3.2", | ||
"turbogrid": "~3.0.13" | ||
@@ -76,3 +76,3 @@ }, | ||
"eslint-plugin-html": "^8.0.0", | ||
"eslint-plugin-vue": "^9.21.1", | ||
"eslint-plugin-vue": "^9.22.0", | ||
"stylelint": "^15.11.0", | ||
@@ -79,0 +79,0 @@ "stylelint-config-plus": "^1.0.4", |
@@ -68,4 +68,4 @@ # Monocart Coverage Reports | ||
- `v8` | ||
- Browser: Build with webpack [V8](https://cenfun.github.io/monocart-coverage-reports/v8) and [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify); Build with [Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild); Collect with [puppeteer](https://cenfun.github.io/monocart-coverage-reports/puppeteer/); [anonymous](https://cenfun.github.io/monocart-coverage-reports/anonymous/) and [css](https://cenfun.github.io/monocart-coverage-reports/css/) | ||
- Node.js: Collect with [env](https://cenfun.github.io/monocart-coverage-reports/v8-node-env), and also V8 [API](https://cenfun.github.io/monocart-coverage-reports/v8-node-api), [Inspector](https://cenfun.github.io/monocart-coverage-reports/v8-node-ins) and [CDP](https://cenfun.github.io/monocart-coverage-reports/v8-node-cdp); Web server example: [koa](https://cenfun.github.io/monocart-coverage-reports/v8-node-koa/) | ||
- Browser: Build with webpack [V8](https://cenfun.github.io/monocart-coverage-reports/v8) and [Minify](https://cenfun.github.io/monocart-coverage-reports/minify); Build with [Rollup](https://cenfun.github.io/monocart-coverage-reports/rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/esbuild); Collect with [puppeteer](https://cenfun.github.io/monocart-coverage-reports/puppeteer/); [anonymous](https://cenfun.github.io/monocart-coverage-reports/anonymous/) and [css](https://cenfun.github.io/monocart-coverage-reports/css/) | ||
- Node.js: Collect with [env](https://cenfun.github.io/monocart-coverage-reports/node-env), and also V8 [API](https://cenfun.github.io/monocart-coverage-reports/node-api), [Inspector](https://cenfun.github.io/monocart-coverage-reports/node-ins) and [CDP](https://cenfun.github.io/monocart-coverage-reports/node-cdp); Web server example: [koa](https://cenfun.github.io/monocart-coverage-reports/node-koa/) | ||
@@ -72,0 +72,0 @@ ![](./assets/v8.gif) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
921455
7626
Updatedmonocart-code-viewer@~1.1.1
Updatedmonocart-formatter@~2.3.2