monocart-coverage-reports 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ const { parentPort } = require('worker_threads');
2
+ const { decode } = require('../packages/monocart-coverage-vendor.js');
3
+
4
+ parentPort.on('message', (message) => {
5
+ const result = decode(message);
6
+ parentPort.postMessage(result);
7
+ });
8
+
9
+ parentPort.postMessage('workerReady');
@@ -1,49 +1,35 @@
1
- const {
2
- Worker, isMainThread, parentPort
3
- } = require('worker_threads');
1
+ const path = require('path');
2
+ const { Worker } = require('worker_threads');
4
3
  const Util = require('./util.js');
5
4
 
6
- if (isMainThread) {
5
+ // do NOT use isMainThread because it could be executed in worker too. (worker in worker)
7
6
 
8
- const decodeMappings = (mappings = '') => {
9
- if (typeof text !== 'string') {
10
- mappings = String(mappings);
11
- }
7
+ const decodeMappings = (mappings = '') => {
8
+ if (typeof text !== 'string') {
9
+ mappings = String(mappings);
10
+ }
12
11
 
13
- return new Promise((resolve) => {
12
+ return new Promise((resolve) => {
14
13
 
15
- const worker = new Worker(__filename);
16
-
17
- worker.on('message', (message) => {
18
- if (message === 'workerReady') {
19
- worker.postMessage(mappings);
20
- return;
21
- }
22
- resolve(message);
23
- worker.terminate();
24
- });
25
-
26
- worker.on('error', (e) => {
27
- Util.logError(e.message);
28
- resolve([]);
29
- worker.terminate();
30
- });
14
+ const workerPath = path.resolve(__dirname, 'decode-mappings-worker.js');
15
+ const worker = new Worker(workerPath);
31
16
 
17
+ worker.on('message', (message) => {
18
+ if (message === 'workerReady') {
19
+ worker.postMessage(mappings);
20
+ return;
21
+ }
22
+ resolve(message);
23
+ worker.terminate();
32
24
  });
33
- };
34
-
35
- module.exports = decodeMappings;
36
-
37
- } else {
38
25
 
39
- const { decode } = require('../packages/monocart-coverage-vendor.js');
26
+ worker.on('error', (e) => {
27
+ Util.logError(e.message);
28
+ resolve([]);
29
+ worker.terminate();
30
+ });
40
31
 
41
- parentPort.on('message', (message) => {
42
- const result = decode(message);
43
- parentPort.postMessage(result);
44
32
  });
33
+ };
45
34
 
46
- parentPort.postMessage('workerReady');
47
-
48
- }
49
-
35
+ module.exports = decodeMappings;
package/lib/v8/v8.js CHANGED
@@ -7,7 +7,7 @@ const { mergeScriptCovs } = require('../packages/monocart-coverage-vendor.js');
7
7
  const collectSourceMaps = require('../converter/collect-source-maps.js');
8
8
  const version = require('../../package.json').version;
9
9
 
10
- const initV8ListAndSourcemap = async (v8list, options, inlineSourceMap) => {
10
+ const initV8ListAndSourcemap = async (v8list, options) => {
11
11
 
12
12
  // filter list first
13
13
  const entryFilter = options.entryFilter;
@@ -47,8 +47,8 @@ const initV8ListAndSourcemap = async (v8list, options, inlineSourceMap) => {
47
47
  data.type = 'js';
48
48
  data.functions = item.functions;
49
49
  data.source = item.source;
50
- // useless here
51
- // data.scriptId = item.scriptId;
50
+ // could be existed
51
+ data.sourceMap = item.sourceMap;
52
52
  } else if (item.ranges) {
53
53
  data.type = 'css';
54
54
  data.ranges = item.ranges;
@@ -72,7 +72,7 @@ const initV8ListAndSourcemap = async (v8list, options, inlineSourceMap) => {
72
72
 
73
73
  // collect sourcemap first
74
74
  const time_start = Date.now();
75
- const count = await collectSourceMaps(v8list, options, inlineSourceMap);
75
+ const count = await collectSourceMaps(v8list, options);
76
76
  if (count) {
77
77
  // debug level time
78
78
  Util.logTime(`loaded ${count} sourcemaps`, time_start);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-coverage-reports",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Monocart coverage reports",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -17,12 +17,15 @@
17
17
  "build-docs": "node ./scripts/build-docs.js",
18
18
  "build-test": "node ./scripts/build-test.js",
19
19
  "build": "sf lint && sf b -p && npm run build-test",
20
- "test-node": "npm run test-node-env && npm run test-node-ins",
20
+ "test-node": "npm run test-node-env && npm run test-node-ins && npm run test-node-api && npm run test-node-cdp",
21
21
  "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage node ./test/test-node-env.js && node ./test/generate-node-report.js",
22
22
  "test-node-ins": "node ./test/test-node-ins.js",
23
+ "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage node ./test/test-node-api.js",
24
+ "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
23
25
  "test-browser": "node ./test/test.js",
24
26
  "test": "npm run test-browser && npm run test-node && npm run build-docs",
25
27
  "dev": "sf d v8",
28
+ "open": "node ./scripts/open.js",
26
29
  "patch": "npm run build && sf publish patch -r"
27
30
  },
28
31
  "workspaces": [
@@ -44,12 +47,11 @@
44
47
  "istanbul-lib-report": "~3.0.1",
45
48
  "istanbul-reports": "~3.1.6",
46
49
  "lz-utils": "~2.0.1",
47
- "monocart-code-viewer": "^1.0.12",
48
- "monocart-formatter": "~2.2.0",
50
+ "monocart-code-viewer": "^1.0.13",
51
+ "monocart-formatter": "~2.2.1",
49
52
  "turbogrid": "~3.0.12"
50
53
  },
51
54
  "devDependencies": {
52
- "cross-env": "^7.0.3",
53
55
  "eslint": "^8.56.0",
54
56
  "eslint-config-plus": "^1.0.6",
55
57
  "eslint-plugin-html": "^7.1.0",