@teamscale/javascript-instrumenter 0.0.1-beta.34 → 0.0.1-beta.37
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 +1 -1
- package/dist/src/App.d.ts +1 -1
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +11 -7
- package/dist/src/instrumenter/Cleaner.d.ts.map +1 -1
- package/dist/src/instrumenter/Cleaner.js +1 -2
- 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 +5 -6
- package/dist/src/instrumenter/Task.d.ts +10 -6
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +33 -33
- 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 +1 -1
package/dist/package.json
CHANGED
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
|
@@ -74,14 +74,16 @@ class App {
|
|
|
74
74
|
help: 'External location of source-map files to consider.'
|
|
75
75
|
});
|
|
76
76
|
parser.add_argument('-c', '--collector', {
|
|
77
|
-
help: 'The collector (host:port) to send coverage information to.',
|
|
78
|
-
default: 'localhost:54678'
|
|
77
|
+
help: 'The collector (`host:port` or `wss://host:port/` or `ws://host:port/`) to send coverage information to.',
|
|
78
|
+
default: 'ws://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,EAKN,cAAc,
|
|
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"}
|
|
@@ -75,8 +75,7 @@ function extractCoverageCallExpression(expr) {
|
|
|
75
75
|
* If this is not the case return `undefined`, and the call expression itself otherwise.
|
|
76
76
|
*/
|
|
77
77
|
function extractCoverageObjectCall(callExpression) {
|
|
78
|
-
if (callExpression && (0, types_1.isIdentifier)(callExpression.callee)
|
|
79
|
-
&& callExpression.callee.name.startsWith('cov_')) {
|
|
78
|
+
if (callExpression && (0, types_1.isIdentifier)(callExpression.callee) && callExpression.callee.name.startsWith('cov_')) {
|
|
80
79
|
return callExpression;
|
|
81
80
|
}
|
|
82
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,MAAM,qBAAqB,8CAA8C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACzD;;;;OAIG;IAC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B;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());
|
|
@@ -174,10 +176,7 @@ class IstanbulInstrumenter {
|
|
|
174
176
|
loadVaccine(collector) {
|
|
175
177
|
// We first replace parameters in the file with the
|
|
176
178
|
// actual values, for example, the collector to send the coverage information to.
|
|
177
|
-
return fs
|
|
178
|
-
.readFileSync(this.vaccineFilePath, 'utf8')
|
|
179
|
-
.replace(/\$REPORT_TO_HOST/g, collector.host)
|
|
180
|
-
.replace(/\$REPORT_TO_PORT/g, `${collector.port}`);
|
|
179
|
+
return fs.readFileSync(this.vaccineFilePath, 'utf8').replace(/\$REPORT_TO_URL/g, collector.url);
|
|
181
180
|
}
|
|
182
181
|
/**
|
|
183
182
|
* Should the given file be excluded from the instrumentation,
|
|
@@ -26,11 +26,9 @@ export declare class TaskElement {
|
|
|
26
26
|
* receive the coverage information.
|
|
27
27
|
*/
|
|
28
28
|
export declare class CollectorSpecifier {
|
|
29
|
-
/**
|
|
30
|
-
readonly
|
|
31
|
-
|
|
32
|
-
readonly port: number;
|
|
33
|
-
constructor(collector: string);
|
|
29
|
+
/** The URL specifying the address the collector is reachable at. */
|
|
30
|
+
readonly url: string;
|
|
31
|
+
constructor(specifier: string);
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* Patterns that define which parts of a given bundle to instrument or not.
|
|
@@ -47,7 +45,13 @@ export declare class OriginSourcePattern {
|
|
|
47
45
|
* An exclude is stronger than an include.
|
|
48
46
|
*/
|
|
49
47
|
private readonly exclude;
|
|
50
|
-
constructor(include: string | undefined, exclude: string | undefined);
|
|
48
|
+
constructor(include: string[] | undefined, exclude: string[] | undefined);
|
|
49
|
+
/**
|
|
50
|
+
* Normalizes all patterns (normally either include or exclude patterns), and returns all
|
|
51
|
+
* valid normalized patterns. Returns undefined if the patterns list is undefined, or all
|
|
52
|
+
* items inside the list are undefined.
|
|
53
|
+
*/
|
|
54
|
+
private normalizePatterns;
|
|
51
55
|
/**
|
|
52
56
|
* Does the given pattern require to include the given set of files?
|
|
53
57
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C;;GAEG;AACH,8BAAsB,kBAAkB;CAAG;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,sBAAsB;IACtB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC,2BAA2B;IAC3B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,gEAAgE;IAChE,SAAgB,qBAAqB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;gBAExD,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB;IAMpF;;OAEG;IACI,SAAS,IAAI,OAAO;CAK3B;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C;;GAEG;AACH,8BAAsB,kBAAkB;CAAG;AA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= 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.
|
|
@@ -62,10 +39,17 @@ exports.TaskElement = TaskElement;
|
|
|
62
39
|
* receive the coverage information.
|
|
63
40
|
*/
|
|
64
41
|
class CollectorSpecifier {
|
|
65
|
-
constructor(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
constructor(specifier) {
|
|
43
|
+
if (specifier.indexOf('://') > 0) {
|
|
44
|
+
// A trailing slash will be removed
|
|
45
|
+
this.url = specifier.replace(/\/$/, '');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
commons_1.Contract.requireStringPattern(specifier, '.+:[0-9]+', 'Invalid collector pattern used!');
|
|
49
|
+
const host = specifier.split(':')[0];
|
|
50
|
+
const port = Number.parseInt(specifier.split(':')[1]);
|
|
51
|
+
this.url = `ws://${host}:${port}`;
|
|
52
|
+
}
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
55
|
exports.CollectorSpecifier = CollectorSpecifier;
|
|
@@ -78,8 +62,25 @@ exports.CollectorSpecifier = CollectorSpecifier;
|
|
|
78
62
|
*/
|
|
79
63
|
class OriginSourcePattern {
|
|
80
64
|
constructor(include, exclude) {
|
|
81
|
-
this.include =
|
|
82
|
-
this.exclude =
|
|
65
|
+
this.include = this.normalizePatterns(include);
|
|
66
|
+
this.exclude = this.normalizePatterns(exclude);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Normalizes all patterns (normally either include or exclude patterns), and returns all
|
|
70
|
+
* valid normalized patterns. Returns undefined if the patterns list is undefined, or all
|
|
71
|
+
* items inside the list are undefined.
|
|
72
|
+
*/
|
|
73
|
+
normalizePatterns(patterns) {
|
|
74
|
+
if (patterns === undefined || patterns.length === 0) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
const normalizedPatterns = patterns
|
|
78
|
+
.map(pattern => OriginSourcePattern.normalizeGlobPattern(pattern))
|
|
79
|
+
.filter(pattern => pattern !== undefined);
|
|
80
|
+
if (patterns.length === 0) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
return normalizedPatterns;
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
86
|
* Does the given pattern require to include the given set of files?
|
|
@@ -94,19 +95,18 @@ class OriginSourcePattern {
|
|
|
94
95
|
* or (2) `true` if at least one of the files is supposed to be included.
|
|
95
96
|
*/
|
|
96
97
|
isAnyIncluded(originFiles) {
|
|
97
|
-
var _a;
|
|
98
98
|
if (originFiles.length === 0) {
|
|
99
99
|
return true;
|
|
100
100
|
}
|
|
101
101
|
const normalizedOriginFiles = originFiles.map(OriginSourcePattern.normalizePath);
|
|
102
102
|
if (this.exclude) {
|
|
103
|
-
const matchedToExclude =
|
|
103
|
+
const matchedToExclude = (0, micromatch_1.default)(normalizedOriginFiles, this.exclude);
|
|
104
104
|
if (originFiles.length === matchedToExclude.length) {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
if (this.include) {
|
|
109
|
-
const matchedToInclude =
|
|
109
|
+
const matchedToInclude = (0, micromatch_1.default)(normalizedOriginFiles, this.include || ['**']);
|
|
110
110
|
return matchedToInclude.length > 0;
|
|
111
111
|
}
|
|
112
112
|
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,CAAC,EAAE,MAAM,CAAC;
|
|
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,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAkBF;;GAEG;AACH,qBAAa,WAAW;IACvB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,6CAA6C;IAC7C,OAAO,CAAC,SAAS,CAA4B;IAE7C,0BAA0B;IAC1B,OAAO,CAAC,2BAA2B,CAAuB;IAE1D,0BAA0B;IAC1B,OAAO,CAAC,2BAA2B,CAAuB;;IAO1D,0EAA0E;IAC1E,sBAAsB,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI;IAM5D,yGAAyG;IACzG,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAKpE,2GAA2G;IAC3G,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAKpE,yBAAyB;IACzB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAKlG;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAkCpD;;;;;;;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 y=Object.create;var f=Object.defineProperty;var
|
|
1
|
+
(()=>{var y=Object.create;var f=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var P=e=>f(e,"__esModule",{value:!0});var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var j=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!B.call(e,o)&&o!=="default"&&f(e,o,{get:()=>t[o],enumerable:!(n=L(t,o))||n.enumerable});return e},v=e=>j(P(f(e!=null?y(U(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var O=k((re,R)=>{R.exports=!1});var W=k(()=>{});function m(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o=new Worker(n);return URL.revokeObjectURL(n),o}function g(){return m('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 m=20,p=1e3,d=class{constructor(e,n){this.milliseconds=e;this.onCountedToZero=n;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)}},a=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new d(p,()=>this.flush())}addRange(e,n){let t=this.cachedCoveredRanges.get(e);t||(t=new Set,this.cachedCoveredRanges.set(e,t)),t.add(n),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=m&&this.flush()}flush(){this.numberOfCachedPositions!==0&&(this.flushCountdown.stopCountdown(),this.cachedCoveredRanges.forEach((e,n)=>{let t=[...e].map(o=>`${o.start.line}:${o.start.column}:${o.end.line}:${o.end.column}`);this.socket.send(`${"c"} ${n} ${Array.from(t).join(" ")}`)}),this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0)}};var h="s",u="b";console.log("Starting coverage forwarding worker.");var l=new i("$REPORT_TO_URL/socket"),c=new a(l),r;onmessage=s=>{let e=s.data;e.startsWith("s")?l.send(e):e.startsWith("i")?r=JSON.parse(e.substring(2)):e.startsWith("u")?E(e):e==="unload"?c.flush():console.error(`No handler for message: ${e}`)};function E(s){let e=s.split(" ");if(e.length<3||r===null)return;let n=e[1];if(n===h){let t=e[2],o=r.statementMap[t];c.addRange(r.hash,o)}else if(n===u){let t=e[2],o=Number.parseInt(e[3]),g=r.branchMap[t].locations[o];c.addRange(r.hash,g)}}\n')}var w="s",b="b";var a;(function(r){r.MESSAGE_TYPE_SOURCEMAP="s",r.MESSAGE_TYPE_COVERAGE="c",r.ISTANBUL_COV_OBJECT="i",r.UNRESOLVED_CODE_ENTITY="u"})(a||(a={}));var S=class{constructor(t,n){this.worker=t;this.path=n}get(t,n,o){let r=t[n];return r!==Object(r)?r:E(this.worker,r,[...this.path,n])}set(t,n,o){let r=[...this.path,n],i=r[0];if(i===w){let s=r[1];this.worker.postMessage(`${a.UNRESOLVED_CODE_ENTITY} ${w} ${s}`)}else if(i===b){let s=r[1],u=r[2];this.worker.postMessage(`${a.UNRESOLVED_CODE_ENTITY} ${b} ${s} ${u}`)}return!0}};function E(e,t,n){return new Proxy(t,new S(e,n))}var T=v(O());function G(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 _={add:G};var $=v(W()),H=T.default?$.default:_,c=new Set,M=!1;function V(){M||(M=!0,H.add(Y))}function x(e){if(V(),typeof e!="function")throw new Error("Listener is no function");c.add(e);var t={remove:function(){return c.delete(e)},run:function(){return c.delete(e),e()}};return t}function Y(){var e=[];return c.forEach(function(t){e.push(t()),c.delete(t)}),Promise.all(e)}function d(){return l()}function A(){return typeof window!="undefined"}function l(){return window}function C(e,t){let n=d()[e];return n||(n=t,d()[e]=n),n}var I=C("__TS_AGENT",{});function h(){return I._$BcWorker}function J(e){return I._$BcWorker=e,e}d().makeCoverageInterceptor=function(e){let t=e.hash;if(!h()){let n=J(new g);(function(){let r=function(i){let s=l()[i];l()[i]=function(...u){if(n.postMessage("unload"),s)return s.apply(this,u)},A()&&Object.defineProperty(l(),i,{get:function(){return s},set:function(u){s=u}})};r("onunload"),r("onbeforeunload"),x(()=>n.postMessage("unload"))})()}return function(){h().postMessage(`${a.ISTANBUL_COV_OBJECT} ${JSON.stringify(e)}`);let o=C("sentMaps",new Set);e.inputSourceMap&&(o.has(e.path)||(h().postMessage(`${a.MESSAGE_TYPE_SOURCEMAP} ${t}:${JSON.stringify(e.inputSourceMap)}`),o.add(e.path)))}(),function(){let o=new Set;d()._$Bc=(r,i,s,u,N)=>{let p=`${r}:${i}:${s}:${u}:${N}`;o.has(p)||(h().postMessage(p),o.add(p))}}(),E(h(),e,[])};})();
|
package/package.json
CHANGED