@teamscale/javascript-instrumenter 0.0.1-beta.32 → 0.0.1-beta.35
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.
- package/dist/package.json +2 -2
- package/dist/src/App.d.ts +1 -1
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +9 -5
- package/dist/src/instrumenter/Cleaner.d.ts.map +1 -1
- package/dist/src/instrumenter/Cleaner.js +4 -24
- package/dist/src/instrumenter/Instrumenter.d.ts +1 -1
- package/dist/src/instrumenter/Instrumenter.d.ts.map +1 -1
- package/dist/src/instrumenter/Instrumenter.js +4 -2
- package/dist/src/instrumenter/Task.d.ts +7 -1
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +22 -29
- package/dist/src/instrumenter/TaskBuilder.d.ts +8 -8
- package/dist/src/instrumenter/TaskBuilder.d.ts.map +1 -1
- package/dist/src/instrumenter/TaskBuilder.js +9 -9
- package/dist/vaccine.js +1 -1
- package/package.json +2 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.35",
|
|
4
4
|
"description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/glob": "^7.1.3",
|
|
33
33
|
"@types/istanbul-lib-instrument": "^1.7.4",
|
|
34
34
|
"@types/jest": "^27.0.1",
|
|
35
|
-
"@types/mkdirp": "^1.0.
|
|
35
|
+
"@types/mkdirp": "^1.0.2",
|
|
36
36
|
"@types/node": "^15.0.1",
|
|
37
37
|
"@types/source-map": "^0.5.7",
|
|
38
38
|
"@types/ws": "^7.4.4",
|
package/dist/src/App.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TaskResult } from './instrumenter/Task';
|
|
2
2
|
import { ConfigurationParameters } from './instrumenter/TaskBuilder';
|
|
3
|
-
import Logger from
|
|
3
|
+
import Logger from 'bunyan';
|
|
4
4
|
/**
|
|
5
5
|
* Entry points of the instrumenter, including command line argument parsing.
|
|
6
6
|
*/
|
package/dist/src/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAe,MAAM,4BAA4B,CAAC;AAKlF,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAa9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAe,MAAM,4BAA4B,CAAC;AAKlF,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAa9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAkC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA8B1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;;;;OAKG;WACW,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAO1G,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAIxC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAajC"}
|
package/dist/src/App.js
CHANGED
|
@@ -78,10 +78,12 @@ class App {
|
|
|
78
78
|
default: 'localhost:54678'
|
|
79
79
|
});
|
|
80
80
|
parser.add_argument('-x', '--exclude-origin', {
|
|
81
|
-
|
|
81
|
+
nargs: '*',
|
|
82
|
+
help: 'Glob pattern(s) of files in the source origin to not produce coverage for. Multiple patterns can be separated by space.'
|
|
82
83
|
});
|
|
83
84
|
parser.add_argument('-k', '--include-origin', {
|
|
84
|
-
|
|
85
|
+
nargs: '*',
|
|
86
|
+
help: 'Glob pattern(s) of files in the source origin to produce coverage for. Multiple patterns can be separated by space.'
|
|
85
87
|
});
|
|
86
88
|
parser.add_argument('inputs', { nargs: '+', help: 'The input file(s) to instrument.' });
|
|
87
89
|
return parser;
|
|
@@ -93,7 +95,8 @@ class App {
|
|
|
93
95
|
const logfilePath = 'logs/instrumenter.log';
|
|
94
96
|
mkdirp_1.default.sync(path.dirname(logfilePath));
|
|
95
97
|
const logLevel = config.debug ? 'debug' : 'error';
|
|
96
|
-
return bunyan_1.default.createLogger({
|
|
98
|
+
return bunyan_1.default.createLogger({
|
|
99
|
+
name: 'Instrumenter',
|
|
97
100
|
streams: [
|
|
98
101
|
{
|
|
99
102
|
level: logLevel,
|
|
@@ -108,13 +111,14 @@ class App {
|
|
|
108
111
|
level: logLevel,
|
|
109
112
|
path: logfilePath
|
|
110
113
|
}
|
|
111
|
-
]
|
|
114
|
+
]
|
|
115
|
+
});
|
|
112
116
|
}
|
|
113
117
|
/**
|
|
114
118
|
* A logger for testing.
|
|
115
119
|
*/
|
|
116
120
|
static buildDummyLogger() {
|
|
117
|
-
return bunyan_1.default.createLogger({ name:
|
|
121
|
+
return bunyan_1.default.createLogger({ name: 'Instrumenter' });
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
120
124
|
* The instrumenter can also be started by providing the configuration dictionary explicitly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cleaner.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Cleaner.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"Cleaner.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Cleaner.ts"],"names":[],"mappings":"AAGA,OAAO,EAKN,cAAc,EAEd,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,GAClD,MAAM,CAYR"}
|
|
@@ -17,11 +17,8 @@ const types_1 = require("@babel/types");
|
|
|
17
17
|
function cleanSourceCode(code, esModules, makeCoverable) {
|
|
18
18
|
const ast = (0, parser_1.parse)(code, { sourceType: esModules ? 'module' : 'script' });
|
|
19
19
|
(0, traverse_1.default)(ast, {
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
path.remove();
|
|
23
|
-
}
|
|
24
|
-
else if (isCoverageIncrementNode(path)) {
|
|
20
|
+
UpdateExpression(path) {
|
|
21
|
+
if (isCoverageIncrementNode(path)) {
|
|
25
22
|
if (path.node.loc && !makeCoverable(path.node.loc)) {
|
|
26
23
|
path.remove();
|
|
27
24
|
}
|
|
@@ -35,23 +32,7 @@ exports.cleanSourceCode = cleanSourceCode;
|
|
|
35
32
|
* Checks if the given `path.node` to a statement like `cov_104fq7oo4i().f[0]++;`
|
|
36
33
|
*/
|
|
37
34
|
function isCoverageIncrementNode(path) {
|
|
38
|
-
|
|
39
|
-
if (!(0, types_1.isUpdateExpression)(expr)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return extractCoverageCallExpression(expr) !== undefined;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Is the given expression statement a coverage increment that
|
|
46
|
-
* is not supported by our approach?
|
|
47
|
-
*
|
|
48
|
-
* For example, branch coverage is not supported.
|
|
49
|
-
*/
|
|
50
|
-
function isUnsupportedCounterTypeIncrement(path) {
|
|
51
|
-
if (!(0, types_1.isUpdateExpression)(path.node.expression)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return extractBranchCounterExpression(path.node.expression) !== undefined;
|
|
35
|
+
return extractCoverageCallExpression(path.node) !== undefined;
|
|
55
36
|
}
|
|
56
37
|
/**
|
|
57
38
|
* Returns the call expression from `cov_2pvvu1hl8v().b[2][0]++;` if
|
|
@@ -94,8 +75,7 @@ function extractCoverageCallExpression(expr) {
|
|
|
94
75
|
* If this is not the case return `undefined`, and the call expression itself otherwise.
|
|
95
76
|
*/
|
|
96
77
|
function extractCoverageObjectCall(callExpression) {
|
|
97
|
-
if (callExpression && (0, types_1.isIdentifier)(callExpression.callee)
|
|
98
|
-
&& callExpression.callee.name.startsWith('cov_')) {
|
|
78
|
+
if (callExpression && (0, types_1.isIdentifier)(callExpression.callee) && callExpression.callee.name.startsWith('cov_')) {
|
|
99
79
|
return callExpression;
|
|
100
80
|
}
|
|
101
81
|
return undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CollectorSpecifier, InstrumentationTask, OriginSourcePattern, TaskElement, TaskResult } from './Task';
|
|
2
|
-
import Logger from
|
|
2
|
+
import Logger from 'bunyan';
|
|
3
3
|
export declare const IS_INSTRUMENTED_TOKEN = "/** $IS_JS_PROFILER_INSTRUMENTED=true **/";
|
|
4
4
|
/**
|
|
5
5
|
* An instrumenter that can conduct a {@code InstrumentationTask}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAGnB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAUhB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MA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GAChC,OAAO,CAAC,UAAU,CAAC;YA8FR,6BAA6B;YAmC7B,aAAa;IAe3B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAQxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAe1B"}
|
|
@@ -54,9 +54,11 @@ class IstanbulInstrumenter {
|
|
|
54
54
|
async instrument(task) {
|
|
55
55
|
// We limit the number of instrumentations in parallel to one to
|
|
56
56
|
// not overuse memory (NodeJS has only limited mem to use).
|
|
57
|
-
return async_1.default
|
|
57
|
+
return async_1.default
|
|
58
|
+
.mapLimit(task.elements, 1, async (taskElement) => {
|
|
58
59
|
return await this.instrumentOne(task.collector, taskElement, task.originSourcePattern);
|
|
59
|
-
})
|
|
60
|
+
})
|
|
61
|
+
.then(results => {
|
|
60
62
|
return results.reduce((prev, curr) => {
|
|
61
63
|
return prev.withIncrement(curr);
|
|
62
64
|
}, Task_1.TaskResult.neutral());
|
|
@@ -47,7 +47,13 @@ export declare class OriginSourcePattern {
|
|
|
47
47
|
* An exclude is stronger than an include.
|
|
48
48
|
*/
|
|
49
49
|
private readonly exclude;
|
|
50
|
-
constructor(include: string | undefined, exclude: string | undefined);
|
|
50
|
+
constructor(include: string[] | undefined, exclude: string[] | undefined);
|
|
51
|
+
/**
|
|
52
|
+
* Normalizes all patterns (normally either include or exclude patterns), and returns all
|
|
53
|
+
* valid normalized patterns. Returns undefined if the patterns list is undefined, or all
|
|
54
|
+
* items inside the list are undefined.
|
|
55
|
+
*/
|
|
56
|
+
private normalizePatterns;
|
|
51
57
|
/**
|
|
52
58
|
* Does the given pattern require to include the given set of files?
|
|
53
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],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,EAAE,MAAM,CAAC;IAE5C,uDAAuD;IACvD,SAAgB,mBAAmB,EAAE,MAAM,CAAC;IAE5C,sDAAsD;IACtD,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,6DAA6D;IAC7D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,+EAA+E;IAC/E,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAGhC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM;IAkBjB;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAYnD;;OAEG;WACW,OAAO,IAAI,UAAU;IAInC;;;;OAIG;WACW,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU;IAKzC;;;;OAIG;WACW,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;CAI9C;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC7D,2CAA2C;IAC3C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;gBAE9B,iBAAiB,EAAE,MAAM;CAIrC"}
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
@@ -29,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
6
|
exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.OriginSourcePattern = exports.CollectorSpecifier = exports.TaskElement = exports.SourceMapReference = void 0;
|
|
30
7
|
const typescript_optional_1 = require("typescript-optional");
|
|
31
8
|
const commons_1 = require("@cqse/commons");
|
|
32
|
-
const
|
|
9
|
+
const micromatch_1 = __importDefault(require("micromatch"));
|
|
33
10
|
const path_1 = __importDefault(require("path"));
|
|
34
11
|
/**
|
|
35
12
|
* An abstract source map type.
|
|
@@ -78,8 +55,25 @@ exports.CollectorSpecifier = CollectorSpecifier;
|
|
|
78
55
|
*/
|
|
79
56
|
class OriginSourcePattern {
|
|
80
57
|
constructor(include, exclude) {
|
|
81
|
-
this.include =
|
|
82
|
-
this.exclude =
|
|
58
|
+
this.include = this.normalizePatterns(include);
|
|
59
|
+
this.exclude = this.normalizePatterns(exclude);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Normalizes all patterns (normally either include or exclude patterns), and returns all
|
|
63
|
+
* valid normalized patterns. Returns undefined if the patterns list is undefined, or all
|
|
64
|
+
* items inside the list are undefined.
|
|
65
|
+
*/
|
|
66
|
+
normalizePatterns(patterns) {
|
|
67
|
+
if (patterns === undefined || patterns.length === 0) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const normalizedPatterns = patterns
|
|
71
|
+
.map(pattern => OriginSourcePattern.normalizeGlobPattern(pattern))
|
|
72
|
+
.filter(pattern => pattern !== undefined);
|
|
73
|
+
if (patterns.length === 0) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return normalizedPatterns;
|
|
83
77
|
}
|
|
84
78
|
/**
|
|
85
79
|
* Does the given pattern require to include the given set of files?
|
|
@@ -94,19 +88,18 @@ class OriginSourcePattern {
|
|
|
94
88
|
* or (2) `true` if at least one of the files is supposed to be included.
|
|
95
89
|
*/
|
|
96
90
|
isAnyIncluded(originFiles) {
|
|
97
|
-
var _a;
|
|
98
91
|
if (originFiles.length === 0) {
|
|
99
92
|
return true;
|
|
100
93
|
}
|
|
101
94
|
const normalizedOriginFiles = originFiles.map(OriginSourcePattern.normalizePath);
|
|
102
95
|
if (this.exclude) {
|
|
103
|
-
const matchedToExclude =
|
|
96
|
+
const matchedToExclude = (0, micromatch_1.default)(normalizedOriginFiles, this.exclude);
|
|
104
97
|
if (originFiles.length === matchedToExclude.length) {
|
|
105
98
|
return false;
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
if (this.include) {
|
|
109
|
-
const matchedToInclude =
|
|
102
|
+
const matchedToInclude = (0, micromatch_1.default)(normalizedOriginFiles, this.include || ['**']);
|
|
110
103
|
return matchedToInclude.length > 0;
|
|
111
104
|
}
|
|
112
105
|
return true;
|
|
@@ -7,8 +7,8 @@ export declare type ConfigurationParameters = {
|
|
|
7
7
|
to?: string;
|
|
8
8
|
source_map?: string;
|
|
9
9
|
collector: string;
|
|
10
|
-
include_origin?: string;
|
|
11
|
-
exclude_origin?: string;
|
|
10
|
+
include_origin?: string[];
|
|
11
|
+
exclude_origin?: string[];
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* A builder for an instrumentation task.
|
|
@@ -19,16 +19,16 @@ export declare class TaskBuilder {
|
|
|
19
19
|
/** The collector to send the coverage to. */
|
|
20
20
|
private collector;
|
|
21
21
|
/** An include pattern. */
|
|
22
|
-
private
|
|
22
|
+
private originSourceIncludePatterns;
|
|
23
23
|
/** An exclude pattern. */
|
|
24
|
-
private
|
|
24
|
+
private originSourceExcludePatterns;
|
|
25
25
|
constructor();
|
|
26
26
|
/** Set the collector by extracting the information from a given string */
|
|
27
27
|
setCollectorFromString(collectorSpecification: string): this;
|
|
28
|
-
/** Set the include pattern */
|
|
29
|
-
|
|
30
|
-
/** Set the exclude
|
|
31
|
-
|
|
28
|
+
/** Set the include pattern. If multiple patterns are present, concatenates them via the OR operator. */
|
|
29
|
+
setOriginSourceIncludePatterns(patterns: string[] | undefined): this;
|
|
30
|
+
/** Set the exclude pattern(s). If multiple patterns are present, concatenates them via the OR operator. */
|
|
31
|
+
setOriginSourceExcludePatterns(patterns: string[] | undefined): this;
|
|
32
32
|
/** Add a task element */
|
|
33
33
|
addElement(fromFilePath: string, toFilePath: string, fromFileSourceMap?: SourceMapReference): this;
|
|
34
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,EAElB,MAAM,QAAQ,CAAC;AAMhB,2DAA2D;AAC3D,oBAAY,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,CAA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;;;;OAOG;IACH,OAAO,CAAC,4CAA4C;IAgCpD;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IASlC;;OAEG;IACI,KAAK,IAAI,mBAAmB;CAInC"}
|
|
@@ -58,14 +58,14 @@ class TaskBuilder {
|
|
|
58
58
|
this.collector = new Task_1.CollectorSpecifier(collectorSpecification);
|
|
59
59
|
return this;
|
|
60
60
|
}
|
|
61
|
-
/** Set the include pattern */
|
|
62
|
-
|
|
63
|
-
this.
|
|
61
|
+
/** Set the include pattern. If multiple patterns are present, concatenates them via the OR operator. */
|
|
62
|
+
setOriginSourceIncludePatterns(patterns) {
|
|
63
|
+
this.originSourceIncludePatterns = patterns;
|
|
64
64
|
return this;
|
|
65
65
|
}
|
|
66
|
-
/** Set the exclude
|
|
67
|
-
|
|
68
|
-
this.
|
|
66
|
+
/** Set the exclude pattern(s). If multiple patterns are present, concatenates them via the OR operator. */
|
|
67
|
+
setOriginSourceExcludePatterns(patterns) {
|
|
68
|
+
this.originSourceExcludePatterns = patterns;
|
|
69
69
|
return this;
|
|
70
70
|
}
|
|
71
71
|
/** Add a task element */
|
|
@@ -85,8 +85,8 @@ class TaskBuilder {
|
|
|
85
85
|
const target = config.to;
|
|
86
86
|
const sourceMap = config.source_map;
|
|
87
87
|
this.setCollectorFromString(config.collector);
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
88
|
+
this.setOriginSourceIncludePatterns(config.include_origin);
|
|
89
|
+
this.setOriginSourceExcludePatterns(config.exclude_origin);
|
|
90
90
|
// Handle an explicitly specified source map
|
|
91
91
|
const sourceMapInfo = loadSourceMap(sourceMap);
|
|
92
92
|
// Depending on whether or not an in place instrumentation is needed
|
|
@@ -163,7 +163,7 @@ class TaskBuilder {
|
|
|
163
163
|
* Build the instrumentation task.
|
|
164
164
|
*/
|
|
165
165
|
build() {
|
|
166
|
-
const pattern = new Task_1.OriginSourcePattern(this.
|
|
166
|
+
const pattern = new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns);
|
|
167
167
|
return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), this.elements, pattern);
|
|
168
168
|
}
|
|
169
169
|
}
|
package/dist/vaccine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var
|
|
1
|
+
(()=>{var y=Object.create;var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var H=e=>f(e,"__esModule",{value:!0});var v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var B=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of I(t))!L.call(e,o)&&o!=="default"&&f(e,o,{get:()=>t[o],enumerable:!(n=A(t,o))||n.enumerable});return e},C=e=>B(H(f(e!=null?y(j(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var R=v((ee,E)=>{E.exports=!1});var M=v(()=>{});function p(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o=new Worker(n);return URL.revokeObjectURL(n),o}function m(){return p('var i=class{constructor(e){this.cachedMessages=[];this.url=e,this.socket=this.createSocket()}createSocket(){let e=new WebSocket(this.url);return e.onopen=()=>this.onopen(),e.onclose=()=>this.onclose(),e}onclose(){this.socket=this.createSocket()}onopen(){this.cachedMessages.forEach(e=>this.socket.send(e)),this.cachedMessages=[]}send(e){this.socket.readyState===WebSocket.OPEN?this.socket.send(e):this.cachedMessages.push(e)}};var u=20,l=1e3,c=class{constructor(e,t){this.milliseconds=e;this.onCountedToZero=t;this.timerHandle=null}restartCountdown(){this.stopCountdown(),this.timerHandle=self.setTimeout(()=>{this.stopCountdown(),this.onCountedToZero()},this.milliseconds)}stopCountdown(){this.timerHandle!==null&&(self.clearTimeout(this.timerHandle),this.timerHandle=null)}},n=class{constructor(e){this.socket=e,this.cachedCoveredPositions=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new c(l,()=>this.flush())}add(e){let t=e.split(":");if(t.length!==5)return;let r=t[0],o=this.cachedCoveredPositions.get(r);o||(o=new Set,this.cachedCoveredPositions.set(r,o)),o.add(`${t[1]}:${t[2]}:${t[3]}:${t[4]}`),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=u&&this.flush()}flush(){this.numberOfCachedPositions!==0&&(this.flushCountdown.stopCountdown(),this.cachedCoveredPositions.forEach((e,t)=>{this.socket.send(`${"c"} ${t} ${Array.from(e).join(" ")}`)}),this.cachedCoveredPositions=new Map,this.numberOfCachedPositions=0)}};console.log("Starting coverage forwarding worker.");var h=new i("ws://$REPORT_TO_HOST:$REPORT_TO_PORT/socket"),a=new n(h);onmessage=s=>{let e=s.data;e.startsWith("s")?h.send(e):e==="unload"?a.flush():a.add(e)};\n')}function u(){return c()}function k(){return typeof window!="undefined"}function c(){return window}function b(e,t){let n=u()[e];return n||(n=t,u()[e]=n),n}var G="s",N="b",S=class{constructor(t,n){this.coverageObj=t;this.path=n}get(t,n,o){let r=t[n];return r!==Object(r)?r:g(this.coverageObj,r,[...this.path,n])}set(t,n,o){let r=[...this.path,n];if(r[0]===G){let i=r[1],s=this.coverageObj.statementMap[i];this.broadcastCodeRangeCoverage(s)}else if(r[0]===N){let i=r[1],s=Number.parseInt(r[2]),a=this.coverageObj.branchMap[i].locations[s];this.broadcastCodeRangeCoverage(a)}return!0}broadcastCodeRangeCoverage(t){let n=this.coverageObj.hash;u()._$Bc(n,t.start.line,t.start.column,t.end.line,t.end.column)}};function g(e,t,n){return new Proxy(t,new S(e,n))}var W=C(R());function U(e){if(!(typeof WorkerGlobalScope=="function"&&self instanceof WorkerGlobalScope)){if(typeof window.addEventListener!="function")return;window.addEventListener("beforeunload",function(){e()},!0),window.addEventListener("unload",function(){e()},!0)}}var O={add:U};var T=C(M()),D=W.default?T.default:O,d=new Set,_=!1;function V(){_||(_=!0,D.add(Y))}function x(e){if(V(),typeof e!="function")throw new Error("Listener is no function");d.add(e);var t={remove:function(){return d.delete(e)},run:function(){return d.delete(e),e()}};return t}function Y(){var e=[];return d.forEach(function(t){e.push(t()),d.delete(t)}),Promise.all(e)}var l;(function(n){n.MESSAGE_TYPE_SOURCEMAP="s",n.MESSAGE_TYPE_COVERAGE="c"})(l||(l={}));var P=b("__TS_AGENT",{});function w(){return P._$BcWorker}function z(e){return P._$BcWorker=e,e}u().makeCoverageInterceptor=function(e){let t=e.hash;if(!w()){let n=z(new m);(function(){let r=function(i){let s=c()[i];c()[i]=function(...a){if(n.postMessage("unload"),s)return s.apply(this,a)},k()&&Object.defineProperty(c(),i,{get:function(){return s},set:function(a){s=a}})};r("onunload"),r("onbeforeunload"),x(()=>n.postMessage("unload"))})()}return function(){let o=b("sentMaps",new Set);e.inputSourceMap&&(o.has(e.path)||(w().postMessage(`${l.MESSAGE_TYPE_SOURCEMAP} ${t}:${JSON.stringify(e.inputSourceMap)}`),o.add(e.path)))}(),function(){let o=new Set;u()._$Bc=(r,i,s,a,$)=>{let h=`${r}:${i}:${s}:${a}:${$}`;o.has(h)||(w().postMessage(h),o.add(h))}}(),g(e,e,[])};})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.35",
|
|
4
4
|
"description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/glob": "^7.1.3",
|
|
33
33
|
"@types/istanbul-lib-instrument": "^1.7.4",
|
|
34
34
|
"@types/jest": "^27.0.1",
|
|
35
|
-
"@types/mkdirp": "^1.0.
|
|
35
|
+
"@types/mkdirp": "^1.0.2",
|
|
36
36
|
"@types/node": "^15.0.1",
|
|
37
37
|
"@types/source-map": "^0.5.7",
|
|
38
38
|
"@types/ws": "^7.4.4",
|