@teamscale/javascript-instrumenter 0.0.1-beta.2 → 0.0.1-beta.23
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/CHANGELOG.md +11 -0
- package/README.md +6 -39
- package/dist/package.json +2 -2
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +5 -2
- package/dist/src/instrumenter/Instrumenter.js +7 -7
- package/dist/src/instrumenter/Task.d.ts +12 -3
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +38 -11
- package/dist/src/main.js +1 -0
- package/dist/vaccine.js +1 -221
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
We use [Semantic Versioning](https://semver.org/).
|
|
2
|
+
|
|
3
|
+
# New Release
|
|
4
|
+
|
|
5
|
+
# 0.0.1-beta.21
|
|
6
|
+
|
|
7
|
+
- [fix] Include/exclude pattern and the paths to match were not normalized
|
|
8
|
+
|
|
9
|
+
# 0.0.1-beta.20
|
|
10
|
+
|
|
11
|
+
- [feature] Automatic release now for NPM packages and Docker images
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ in the Teamscale Simple Coverage Format and sent to a Teamscale instance.
|
|
|
9
9
|
The Teamscale JavaScript Profiler consists of the [Coverage Collector](https://www.npmjs.com/package/@teamscale/coverage-collector)
|
|
10
10
|
and this JavaScript Instrumenter.
|
|
11
11
|
More details on using them (in combination) can be found
|
|
12
|
-
|
|
12
|
+
in the [Teamscale Documentation](https://docs.teamscale.com/howto/recording-test-coverage-for-javascript/).
|
|
13
13
|
|
|
14
14
|
The Instrumenter instruments a given (set of) JavaScript file(s) such that (1) coverage
|
|
15
15
|
information is produced and (2) forwarded to the Collector.
|
|
@@ -25,34 +25,12 @@ yarn install
|
|
|
25
25
|
yarn build
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
### Preparation: Source Maps
|
|
29
|
-
|
|
30
|
-
Please make sure to enable the generation of source map files to ensure
|
|
31
|
-
that the profiled code can be mapped back to the original.
|
|
32
|
-
|
|
33
|
-
For example, when the tool Vite is used to bundle the code,
|
|
34
|
-
the generation of source map information can be enabled by setting:
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
build: {
|
|
38
|
-
sourcemap: true
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
or
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
build: {
|
|
46
|
-
sourcemap: `inline`
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
28
|
## Workflow Integration
|
|
51
29
|
|
|
52
30
|
There are several options to run the Instrumenter. For example, via `yarn` by running
|
|
53
31
|
|
|
54
32
|
```
|
|
55
|
-
yarn
|
|
33
|
+
yarn instrumenter
|
|
56
34
|
```
|
|
57
35
|
|
|
58
36
|
or via `npx` by running
|
|
@@ -74,30 +52,19 @@ the file must contain source-map information, or the source-map file
|
|
|
74
52
|
must be placed along with the source file in the same directory.
|
|
75
53
|
|
|
76
54
|
```
|
|
77
|
-
yarn
|
|
55
|
+
yarn instrumenter --inplace ./the/path/to/the/file.js
|
|
78
56
|
```
|
|
79
57
|
|
|
80
58
|
```
|
|
81
|
-
yarn
|
|
59
|
+
yarn instrumenter --inplace ./the/path/to/the/file.js --source-map ./the/path/to/the/source.map
|
|
82
60
|
```
|
|
83
61
|
|
|
84
62
|
```
|
|
85
|
-
yarn
|
|
63
|
+
yarn instrumenter ./the/path/to/the/file.js --to ./the/file/path/to/write/to.js
|
|
86
64
|
```
|
|
87
65
|
|
|
88
|
-
### Instrumenting all JavaScript Files in a Folder
|
|
89
|
-
|
|
90
|
-
We think that dealing with sets of files, in particular including or excluding
|
|
91
|
-
files that match particular file masks should be done by other tools.
|
|
92
|
-
In a UNIX environment, you should consider using `find` with corresponding
|
|
93
|
-
filters and an `-exec` argument to run the instrumenter.
|
|
94
|
-
|
|
95
|
-
### Integration with Testing Frameworks
|
|
96
|
-
|
|
97
|
-
This is planned work: Provide a Babel plugin that provides a code transformation
|
|
98
|
-
such that coverage information is collected and this information is forwarded.
|
|
99
|
-
|
|
100
66
|
## Limitations
|
|
101
67
|
|
|
102
68
|
This tool inherits most of the limitations of IstanbulJs, including
|
|
103
69
|
a considerable performance impact.
|
|
70
|
+
|
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.23",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
16
16
|
"build": "tsc --project tsconfig.json && node esbuild.mjs",
|
|
17
|
-
"
|
|
17
|
+
"instrumenter": "node dist/src/main.js",
|
|
18
18
|
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
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;AAGlF,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAG1C;;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;AAGlF,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAG1C;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAa9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAgC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAa1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAS/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
|
@@ -57,10 +57,13 @@ class App {
|
|
|
57
57
|
description: 'Instrumenter of the Teamscale JavaScript Profiler'
|
|
58
58
|
});
|
|
59
59
|
parser.add_argument('-v', '--version', { action: 'version', version: package_json_1.version });
|
|
60
|
-
parser.add_argument('-i', '--in-place', {
|
|
60
|
+
parser.add_argument('-i', '--in-place', {
|
|
61
|
+
action: 'store_true',
|
|
62
|
+
help: 'If set, the original files to instrument are replaced by their instrumented counterparts.'
|
|
63
|
+
});
|
|
61
64
|
parser.add_argument('-d', '--debug', { action: 'store_true' });
|
|
62
65
|
parser.add_argument('-o', '--to', {
|
|
63
|
-
help: '
|
|
66
|
+
help: 'Path (directory or file name) to write the instrumented version to.'
|
|
64
67
|
});
|
|
65
68
|
parser.add_argument('-s', '--source-map', {
|
|
66
69
|
help: 'External location of source-map files to consider.'
|
|
@@ -56,18 +56,18 @@ class IstanbulInstrumenter {
|
|
|
56
56
|
* @param sourcePattern - A pattern to restrict the instrumentation to only a fraction of the task element.
|
|
57
57
|
*/
|
|
58
58
|
instrumentOne(collector, taskElement, sourcePattern) {
|
|
59
|
-
var _a, _b
|
|
59
|
+
var _a, _b;
|
|
60
60
|
const inputFileSource = fs.readFileSync(taskElement.fromFile, 'utf8');
|
|
61
61
|
// We skip files that we have already instrumented
|
|
62
62
|
if (inputFileSource.startsWith(exports.IS_INSTRUMENTED_TOKEN)) {
|
|
63
63
|
if (!taskElement.isInPlace()) {
|
|
64
64
|
fs.writeFileSync(taskElement.toFile, inputFileSource);
|
|
65
65
|
}
|
|
66
|
-
return new Task_1.TaskResult(0, 0, 1, 0, 0, 0);
|
|
66
|
+
return new Task_1.TaskResult(0, 0, 0, 1, 0, 0, 0);
|
|
67
67
|
}
|
|
68
68
|
// Not all file types are supported by the instrumenter
|
|
69
69
|
if (!this.isFileTypeSupported(taskElement.fromFile)) {
|
|
70
|
-
return new Task_1.TaskResult(0, 0, 0, 1, 0, 0);
|
|
70
|
+
return new Task_1.TaskResult(0, 0, 0, 0, 1, 0, 0);
|
|
71
71
|
}
|
|
72
72
|
// Report progress
|
|
73
73
|
this.logger.info(`Instrumenting "${path.basename(taskElement.fromFile)}"`);
|
|
@@ -85,16 +85,16 @@ class IstanbulInstrumenter {
|
|
|
85
85
|
// decide if we should NOT write an instrumented version of it
|
|
86
86
|
// and use the original code instead and write it to the target path.
|
|
87
87
|
//
|
|
88
|
-
if (this.shouldExcludeFromInstrumentation(sourcePattern, taskElement.fromFile, (
|
|
88
|
+
if (this.shouldExcludeFromInstrumentation(sourcePattern, taskElement.fromFile, (_a = inputSourceMap === null || inputSourceMap === void 0 ? void 0 : inputSourceMap.sources) !== null && _a !== void 0 ? _a : [])) {
|
|
89
89
|
fs.writeFileSync(taskElement.toFile, inputFileSource);
|
|
90
|
-
return new Task_1.TaskResult(1, 0, 0, 0, 0, 0);
|
|
90
|
+
return new Task_1.TaskResult(0, 1, 0, 0, 0, 0, 0);
|
|
91
91
|
}
|
|
92
92
|
// The main instrumentation (adding coverage statements) is performed now:
|
|
93
93
|
instrumentedSource = instrumenter
|
|
94
94
|
.instrumentSync(inputFileSource, taskElement.fromFile, inputSourceMap)
|
|
95
95
|
.replace(/return actualCoverage/g, 'return makeCoverageInterceptor(actualCoverage)')
|
|
96
96
|
.replace(/new Function\("return this"\)\(\)/g, "typeof window === 'object' ? window : this");
|
|
97
|
-
this.logger.debug('Instrumentation source maps to:', (
|
|
97
|
+
this.logger.debug('Instrumentation source maps to:', (_b = instrumenter.lastSourceMap()) === null || _b === void 0 ? void 0 : _b.sources);
|
|
98
98
|
// The process also can result in a new source map that we will append in the result.
|
|
99
99
|
//
|
|
100
100
|
// `lastSourceMap` === Sourcemap for the last file that was instrumented.
|
|
@@ -117,7 +117,7 @@ class IstanbulInstrumenter {
|
|
|
117
117
|
//
|
|
118
118
|
const vaccineSource = this.loadVaccine(collector);
|
|
119
119
|
fs.writeFileSync(taskElement.toFile, `${exports.IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${instrumentedSource} \n${finalSourceMap}`);
|
|
120
|
-
return new Task_1.TaskResult(1, 0, 0, 0, 0, 0);
|
|
120
|
+
return new Task_1.TaskResult(1, 0, 0, 0, 0, 0, 0);
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* Loads the vaccine from the vaccine file and adjusts some template parameters.
|
|
@@ -51,12 +51,19 @@ export declare class OriginSourcePattern {
|
|
|
51
51
|
/**
|
|
52
52
|
* Does the given pattern require to include the given set of files?
|
|
53
53
|
*
|
|
54
|
+
* For example, a JavaScript bundle is compiled from several (origin) source files.
|
|
55
|
+
* If one of the files in the bundle is needed, then the full bundle is needed, that is,
|
|
56
|
+
* this function is required to return `true`.
|
|
57
|
+
*
|
|
54
58
|
* @param originFiles - The file set to decide for include or exclude.
|
|
55
59
|
*
|
|
56
|
-
* @returns `
|
|
57
|
-
* or (2) if one of the files is supposed to be included.
|
|
60
|
+
* @returns `false` if (1) all given files are supposed to be excluded,
|
|
61
|
+
* or (2) `true` if at least one of the files is supposed to be included.
|
|
58
62
|
*/
|
|
59
63
|
isAnyIncluded(originFiles: string[]): boolean;
|
|
64
|
+
private static normalizeGlobPattern;
|
|
65
|
+
private static normalizePath;
|
|
66
|
+
private static removeTrailingCurrentWorkingDir;
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
62
69
|
* The actual instrumentation task.
|
|
@@ -87,6 +94,8 @@ export declare class InstrumentationTask {
|
|
|
87
94
|
export declare class TaskResult {
|
|
88
95
|
/** Number of task elements that were performed (instrumented) */
|
|
89
96
|
readonly translated: number;
|
|
97
|
+
/** Number of task elements that were excluded because of corresponding include/exclude patterns. */
|
|
98
|
+
readonly excluded: number;
|
|
90
99
|
/** Number of instrumentations that were taken from a cache */
|
|
91
100
|
readonly translatedFromCache: number;
|
|
92
101
|
/** Number of skips due to a present instrumentation */
|
|
@@ -97,7 +106,7 @@ export declare class TaskResult {
|
|
|
97
106
|
readonly failed: number;
|
|
98
107
|
/** Number of warnings that were produced during the instrumentation process */
|
|
99
108
|
readonly warnings: number;
|
|
100
|
-
constructor(translated: number, translatedFromCache: number, alreadyInstrumented: number, unsupported: number, failed: number, warnings: number);
|
|
109
|
+
constructor(translated: number, excluded: number, translatedFromCache: number, alreadyInstrumented: number, unsupported: number, failed: number, warnings: number);
|
|
101
110
|
/**
|
|
102
111
|
* Returns the sum of the present task results and the given one.
|
|
103
112
|
*
|
|
@@ -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;
|
|
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,2CAA2C;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,gDAAgD;IAChD,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,SAAS,EAAE,MAAM;CAK7B;AAED;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAC/B,mGAAmG;IACnG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS;IAKpE;;;;;;;;;;;OAWG;IACI,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO;IAiBpD,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAQnC,OAAO,CAAC,MAAM,CAAC,aAAa;IAI5B,OAAO,CAAC,MAAM,CAAC,+BAA+B;CAO9C;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC/B;;OAEG;IACH,SAAgB,SAAS,EAAE,kBAAkB,CAAC;IAE9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAE1C;;;OAGG;IACH,SAAgB,mBAAmB,EAAE,mBAAmB,CAAC;gBAE7C,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,mBAAmB,EAAE,mBAAmB;IAM5G;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,EAAE,CAI5B;CACD;AAED;;GAEG;AACH,qBAAa,UAAU;IACtB,iEAAiE;IACjE,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC,oGAAoG;IACpG,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC,8DAA8D;IAC9D,SAAgB,mBAAmB,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"}
|
|
@@ -18,11 +18,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
21
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
25
|
exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.OriginSourcePattern = exports.CollectorSpecifier = exports.TaskElement = exports.SourceMapReference = void 0;
|
|
23
26
|
const typescript_optional_1 = require("typescript-optional");
|
|
24
27
|
const commons_1 = require("@cqse/commons");
|
|
25
28
|
const matching = __importStar(require("micromatch"));
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
26
30
|
/**
|
|
27
31
|
* An abstract source map type.
|
|
28
32
|
*/
|
|
@@ -70,31 +74,52 @@ exports.CollectorSpecifier = CollectorSpecifier;
|
|
|
70
74
|
*/
|
|
71
75
|
class OriginSourcePattern {
|
|
72
76
|
constructor(include, exclude) {
|
|
73
|
-
this.include = include;
|
|
74
|
-
this.exclude = exclude;
|
|
77
|
+
this.include = OriginSourcePattern.normalizeGlobPattern(include);
|
|
78
|
+
this.exclude = OriginSourcePattern.normalizeGlobPattern(exclude);
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* Does the given pattern require to include the given set of files?
|
|
78
82
|
*
|
|
83
|
+
* For example, a JavaScript bundle is compiled from several (origin) source files.
|
|
84
|
+
* If one of the files in the bundle is needed, then the full bundle is needed, that is,
|
|
85
|
+
* this function is required to return `true`.
|
|
86
|
+
*
|
|
79
87
|
* @param originFiles - The file set to decide for include or exclude.
|
|
80
88
|
*
|
|
81
|
-
* @returns `
|
|
82
|
-
* or (2) if one of the files is supposed to be included.
|
|
89
|
+
* @returns `false` if (1) all given files are supposed to be excluded,
|
|
90
|
+
* or (2) `true` if at least one of the files is supposed to be included.
|
|
83
91
|
*/
|
|
84
92
|
isAnyIncluded(originFiles) {
|
|
85
93
|
var _a;
|
|
94
|
+
const normalizedOriginFiles = originFiles.map(OriginSourcePattern.normalizePath);
|
|
86
95
|
if (this.exclude) {
|
|
87
|
-
const matchedToExclude = matching.match(
|
|
96
|
+
const matchedToExclude = matching.match(normalizedOriginFiles, this.exclude);
|
|
88
97
|
if (originFiles.length === matchedToExclude.length) {
|
|
89
98
|
return false;
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
if (this.include) {
|
|
93
|
-
const matchedToInclude = matching.match(
|
|
102
|
+
const matchedToInclude = matching.match(normalizedOriginFiles, (_a = this.include) !== null && _a !== void 0 ? _a : '**');
|
|
94
103
|
return matchedToInclude.length > 0;
|
|
95
104
|
}
|
|
96
105
|
return true;
|
|
97
106
|
}
|
|
107
|
+
static normalizeGlobPattern(pattern) {
|
|
108
|
+
if (!pattern) {
|
|
109
|
+
return pattern;
|
|
110
|
+
}
|
|
111
|
+
return OriginSourcePattern.removeTrailingCurrentWorkingDir(pattern);
|
|
112
|
+
}
|
|
113
|
+
static normalizePath(toNormalize) {
|
|
114
|
+
return OriginSourcePattern.removeTrailingCurrentWorkingDir(toNormalize);
|
|
115
|
+
}
|
|
116
|
+
static removeTrailingCurrentWorkingDir(removeFrom) {
|
|
117
|
+
const prefixToRemove = '.' + path_1.default.sep;
|
|
118
|
+
if (removeFrom.startsWith(prefixToRemove)) {
|
|
119
|
+
return removeFrom.substring(2);
|
|
120
|
+
}
|
|
121
|
+
return removeFrom;
|
|
122
|
+
}
|
|
98
123
|
}
|
|
99
124
|
exports.OriginSourcePattern = OriginSourcePattern;
|
|
100
125
|
/**
|
|
@@ -120,14 +145,16 @@ exports.InstrumentationTask = InstrumentationTask;
|
|
|
120
145
|
* A summary of executing the instrumentation task.
|
|
121
146
|
*/
|
|
122
147
|
class TaskResult {
|
|
123
|
-
constructor(translated, translatedFromCache, alreadyInstrumented, unsupported, failed, warnings) {
|
|
148
|
+
constructor(translated, excluded, translatedFromCache, alreadyInstrumented, unsupported, failed, warnings) {
|
|
124
149
|
commons_1.Contract.require(translated > -1);
|
|
150
|
+
commons_1.Contract.require(excluded > -1);
|
|
125
151
|
commons_1.Contract.require(translatedFromCache > -1);
|
|
126
152
|
commons_1.Contract.require(alreadyInstrumented > -1);
|
|
127
153
|
commons_1.Contract.require(unsupported > -1);
|
|
128
154
|
commons_1.Contract.require(failed > -1);
|
|
129
155
|
commons_1.Contract.require(warnings > -1);
|
|
130
156
|
this.translated = translated;
|
|
157
|
+
this.excluded = excluded;
|
|
131
158
|
this.translatedFromCache = translatedFromCache;
|
|
132
159
|
this.alreadyInstrumented = alreadyInstrumented;
|
|
133
160
|
this.unsupported = unsupported;
|
|
@@ -140,13 +167,13 @@ class TaskResult {
|
|
|
140
167
|
* @param incBy - The task result to add (as delta).
|
|
141
168
|
*/
|
|
142
169
|
withIncrement(incBy) {
|
|
143
|
-
return new TaskResult(this.translated + incBy.translated, this.translatedFromCache + incBy.translatedFromCache, this.alreadyInstrumented + incBy.alreadyInstrumented, this.unsupported + incBy.unsupported, this.failed + incBy.failed, this.warnings + incBy.warnings);
|
|
170
|
+
return new TaskResult(this.translated + incBy.translated, this.excluded + incBy.excluded, this.translatedFromCache + incBy.translatedFromCache, this.alreadyInstrumented + incBy.alreadyInstrumented, this.unsupported + incBy.unsupported, this.failed + incBy.failed, this.warnings + incBy.warnings);
|
|
144
171
|
}
|
|
145
172
|
/**
|
|
146
173
|
* @returns the neutral task element (adding it with {@code withIncrement} does not change the result).
|
|
147
174
|
*/
|
|
148
175
|
static neutral() {
|
|
149
|
-
return new TaskResult(0, 0, 0, 0, 0, 0);
|
|
176
|
+
return new TaskResult(0, 0, 0, 0, 0, 0, 0);
|
|
150
177
|
}
|
|
151
178
|
/**
|
|
152
179
|
* @returns a task result signaling one error.
|
|
@@ -155,7 +182,7 @@ class TaskResult {
|
|
|
155
182
|
*/
|
|
156
183
|
static error(e) {
|
|
157
184
|
console.error(e);
|
|
158
|
-
return new TaskResult(0, 0, 0, 0, 1, 0);
|
|
185
|
+
return new TaskResult(0, 0, 0, 0, 0, 1, 0);
|
|
159
186
|
}
|
|
160
187
|
/**
|
|
161
188
|
* @returns a task result signaling one warning.
|
|
@@ -164,7 +191,7 @@ class TaskResult {
|
|
|
164
191
|
*/
|
|
165
192
|
static warning(msg) {
|
|
166
193
|
console.warn(msg);
|
|
167
|
-
return new TaskResult(0, 0, 0, 0, 0, 1);
|
|
194
|
+
return new TaskResult(0, 0, 0, 0, 0, 0, 1);
|
|
168
195
|
}
|
|
169
196
|
}
|
|
170
197
|
exports.TaskResult = TaskResult;
|
package/dist/src/main.js
CHANGED
|
@@ -7,6 +7,7 @@ App_1.App.run()
|
|
|
7
7
|
.then(result => {
|
|
8
8
|
console.log('Instrumentation finished.');
|
|
9
9
|
console.log(`\tInstrumented: ${result.translated}`);
|
|
10
|
+
console.log(`\tExcluded: ${result.excluded}`);
|
|
10
11
|
console.log(`\tInstrumented from cache: ${result.translatedFromCache}`);
|
|
11
12
|
console.log(`\tAlready instrumented: ${result.alreadyInstrumented}`);
|
|
12
13
|
console.log(`\tUnsupported: ${result.unsupported}`);
|
package/dist/vaccine.js
CHANGED
|
@@ -1,221 +1 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
9
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module, desc) => {
|
|
13
|
-
if (module && typeof module === "object" || typeof module === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// ../../node_modules/detect-node/browser.js
|
|
25
|
-
var require_browser = __commonJS({
|
|
26
|
-
"../../node_modules/detect-node/browser.js"(exports, module) {
|
|
27
|
-
module.exports = false;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// (disabled):../../node_modules/unload/dist/es/node.js
|
|
32
|
-
var require_node = __commonJS({
|
|
33
|
-
"(disabled):../../node_modules/unload/dist/es/node.js"() {
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// inline-worker:__inline-worker
|
|
38
|
-
function inlineWorker(scriptText) {
|
|
39
|
-
let blob = new Blob([scriptText], { type: "text/javascript" });
|
|
40
|
-
let url = URL.createObjectURL(blob);
|
|
41
|
-
let worker = new Worker(url);
|
|
42
|
-
URL.revokeObjectURL(url);
|
|
43
|
-
return worker;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/vaccine/worker/vaccine.worker.ts
|
|
47
|
-
function Worker2() {
|
|
48
|
-
return inlineWorker('var n=class{constructor(t){this.cachedMessages=[];this.url=t,this.socket=this.createSocket()}createSocket(){let t=new WebSocket(this.url);return t.onopen=()=>this.onopen(),t.onclose=()=>this.onclose(),t}onclose(){this.socket=this.createSocket()}onopen(){this.cachedMessages.forEach(t=>this.socket.send(t)),this.cachedMessages=[]}send(t){this.socket.readyState===WebSocket.OPEN?this.socket.send(t):this.cachedMessages.push(t)}};var o;(function(e){e.MESSAGE_TYPE_SOURCEMAP="s",e.MESSAGE_TYPE_COVERAGE="c"})(o||(o={}));var C=20,p=1e3,a=class{constructor(t,e){this.milliseconds=t;this.onCountedToZero=e;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)}},r=class{constructor(t){this.socket=t,this.cachedCoveredPositions=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new a(p,()=>this.flush())}add(t){let e=t.split(":");if(e.length!==3)return;let[c,u,l]=e,i=this.cachedCoveredPositions.get(c);i||(i=new Set,this.cachedCoveredPositions.set(c,i)),i.add(`${u}:${l}`),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=C&&this.flush()}flush(){this.numberOfCachedPositions!==0&&(this.flushCountdown.stopCountdown(),this.cachedCoveredPositions.forEach((t,e)=>{this.socket.send(`${o.MESSAGE_TYPE_COVERAGE} ${e} ${Array.from(t).join(" ")}`)}),this.cachedCoveredPositions=new Map,this.numberOfCachedPositions=0)}};console.log("Starting coverage forwarding worker.");var h=new n("ws://$REPORT_TO_HOST:$REPORT_TO_PORT/socket"),d=new r(h);onmessage=s=>{let t=s.data;t.startsWith(o.MESSAGE_TYPE_SOURCEMAP)?h.send(t):t==="unload"?d.flush():d.add(t)};\n');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/vaccine/utils.ts
|
|
52
|
-
function universe() {
|
|
53
|
-
return getWindow();
|
|
54
|
-
}
|
|
55
|
-
function hasWindow() {
|
|
56
|
-
return typeof window !== "undefined";
|
|
57
|
-
}
|
|
58
|
-
function getWindow() {
|
|
59
|
-
return window;
|
|
60
|
-
}
|
|
61
|
-
function universeAttribute(attributeName, defaultValue) {
|
|
62
|
-
let result = universe()[attributeName];
|
|
63
|
-
if (!result) {
|
|
64
|
-
result = defaultValue;
|
|
65
|
-
universe()[attributeName] = result;
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// src/vaccine/Interceptor.ts
|
|
71
|
-
var STATEMENT_COVERAGE_ID = "s";
|
|
72
|
-
var Interceptor = class {
|
|
73
|
-
constructor(coverageObj, path) {
|
|
74
|
-
this.coverageObj = coverageObj;
|
|
75
|
-
this.path = path;
|
|
76
|
-
}
|
|
77
|
-
get(target, prop, receiver) {
|
|
78
|
-
const value = target[prop];
|
|
79
|
-
if (value !== Object(value)) {
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
return makeProxy(this.coverageObj, value, [...this.path, prop]);
|
|
83
|
-
}
|
|
84
|
-
set(obj, prop, value) {
|
|
85
|
-
const fullPath = [...this.path, prop];
|
|
86
|
-
if (fullPath[0] === STATEMENT_COVERAGE_ID) {
|
|
87
|
-
const fileId = this.coverageObj.hash;
|
|
88
|
-
const start = this.coverageObj.statementMap[fullPath[1]].start;
|
|
89
|
-
universe()._$Bc(fileId, start.line, start.column);
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
function makeProxy(coverage, target, path) {
|
|
95
|
-
return new Proxy(target, new Interceptor(coverage, path));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// ../../node_modules/unload/dist/es/index.js
|
|
99
|
-
var import_detect_node = __toModule(require_browser());
|
|
100
|
-
|
|
101
|
-
// ../../node_modules/unload/dist/es/browser.js
|
|
102
|
-
function add(fn) {
|
|
103
|
-
if (typeof WorkerGlobalScope === "function" && self instanceof WorkerGlobalScope) {
|
|
104
|
-
} else {
|
|
105
|
-
if (typeof window.addEventListener !== "function")
|
|
106
|
-
return;
|
|
107
|
-
window.addEventListener("beforeunload", function() {
|
|
108
|
-
fn();
|
|
109
|
-
}, true);
|
|
110
|
-
window.addEventListener("unload", function() {
|
|
111
|
-
fn();
|
|
112
|
-
}, true);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
var browser_default = {
|
|
116
|
-
add
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// ../../node_modules/unload/dist/es/index.js
|
|
120
|
-
var import_node = __toModule(require_node());
|
|
121
|
-
var USE_METHOD = import_detect_node.default ? import_node.default : browser_default;
|
|
122
|
-
var LISTENERS = new Set();
|
|
123
|
-
var startedListening = false;
|
|
124
|
-
function startListening() {
|
|
125
|
-
if (startedListening)
|
|
126
|
-
return;
|
|
127
|
-
startedListening = true;
|
|
128
|
-
USE_METHOD.add(runAll);
|
|
129
|
-
}
|
|
130
|
-
function add2(fn) {
|
|
131
|
-
startListening();
|
|
132
|
-
if (typeof fn !== "function")
|
|
133
|
-
throw new Error("Listener is no function");
|
|
134
|
-
LISTENERS.add(fn);
|
|
135
|
-
var addReturn = {
|
|
136
|
-
remove: function remove() {
|
|
137
|
-
return LISTENERS["delete"](fn);
|
|
138
|
-
},
|
|
139
|
-
run: function run() {
|
|
140
|
-
LISTENERS["delete"](fn);
|
|
141
|
-
return fn();
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
return addReturn;
|
|
145
|
-
}
|
|
146
|
-
function runAll() {
|
|
147
|
-
var promises = [];
|
|
148
|
-
LISTENERS.forEach(function(fn) {
|
|
149
|
-
promises.push(fn());
|
|
150
|
-
LISTENERS["delete"](fn);
|
|
151
|
-
});
|
|
152
|
-
return Promise.all(promises);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// src/vaccine/protocol.ts
|
|
156
|
-
var ProtocolMessageTypes;
|
|
157
|
-
(function(ProtocolMessageTypes2) {
|
|
158
|
-
ProtocolMessageTypes2["MESSAGE_TYPE_SOURCEMAP"] = "s";
|
|
159
|
-
ProtocolMessageTypes2["MESSAGE_TYPE_COVERAGE"] = "c";
|
|
160
|
-
})(ProtocolMessageTypes || (ProtocolMessageTypes = {}));
|
|
161
|
-
|
|
162
|
-
// src/vaccine/main.ts
|
|
163
|
-
var globalAgentObject = universeAttribute("__TS_AGENT", {});
|
|
164
|
-
function getWorker() {
|
|
165
|
-
return globalAgentObject._$BcWorker;
|
|
166
|
-
}
|
|
167
|
-
function setWorker(worker) {
|
|
168
|
-
globalAgentObject._$BcWorker = worker;
|
|
169
|
-
return worker;
|
|
170
|
-
}
|
|
171
|
-
universe().makeCoverageInterceptor = function(coverage) {
|
|
172
|
-
const fileId = coverage.hash;
|
|
173
|
-
if (!getWorker()) {
|
|
174
|
-
const worker = setWorker(new Worker2());
|
|
175
|
-
(function handleUnloading() {
|
|
176
|
-
const protectWindowEvent = function(name) {
|
|
177
|
-
let wrappedHandler = getWindow()[name];
|
|
178
|
-
getWindow()[name] = function(...args) {
|
|
179
|
-
worker.postMessage("unload");
|
|
180
|
-
if (wrappedHandler) {
|
|
181
|
-
return wrappedHandler.apply(this, args);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
if (hasWindow()) {
|
|
185
|
-
Object.defineProperty(getWindow(), name, {
|
|
186
|
-
get: function() {
|
|
187
|
-
return wrappedHandler;
|
|
188
|
-
},
|
|
189
|
-
set: function(newHandler) {
|
|
190
|
-
wrappedHandler = newHandler;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
protectWindowEvent("onunload");
|
|
196
|
-
protectWindowEvent("onbeforeunload");
|
|
197
|
-
add2(() => worker.postMessage("unload"));
|
|
198
|
-
})();
|
|
199
|
-
}
|
|
200
|
-
(function sendSourceMaps() {
|
|
201
|
-
const sentMaps = universeAttribute("sentMaps", new Set());
|
|
202
|
-
if (coverage.inputSourceMap) {
|
|
203
|
-
if (!sentMaps.has(coverage.path)) {
|
|
204
|
-
getWorker().postMessage(`${ProtocolMessageTypes.MESSAGE_TYPE_SOURCEMAP} ${fileId}:${JSON.stringify(coverage.inputSourceMap)}`);
|
|
205
|
-
sentMaps.add(coverage.path);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
})();
|
|
209
|
-
(function registerCoverageReporter() {
|
|
210
|
-
const reported = new Set();
|
|
211
|
-
universe()._$Bc = (fileId2, coveredLine, coveredColumn) => {
|
|
212
|
-
const coverageMessage = `${fileId2}:${coveredLine}:${coveredColumn}`;
|
|
213
|
-
if (!reported.has(coverageMessage)) {
|
|
214
|
-
getWorker().postMessage(coverageMessage);
|
|
215
|
-
reported.add(coverageMessage);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
})();
|
|
219
|
-
return makeProxy(coverage, coverage, []);
|
|
220
|
-
};
|
|
221
|
-
})();
|
|
1
|
+
(()=>{var x=Object.create;var h=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var j=e=>h(e,"__esModule",{value:!0});var g=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var G=(e,n,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of y(n))!I.call(e,o)&&o!=="default"&&h(e,o,{get:()=>n[o],enumerable:!(t=A(n,o))||t.enumerable});return e},b=e=>G(j(h(e!=null?x($(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var k=g((K,C)=>{C.exports=!1});var O=g(()=>{});function f(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),o=new Worker(t);return URL.revokeObjectURL(t),o}function p(){return f('var n=class{constructor(t){this.cachedMessages=[];this.url=t,this.socket=this.createSocket()}createSocket(){let t=new WebSocket(this.url);return t.onopen=()=>this.onopen(),t.onclose=()=>this.onclose(),t}onclose(){this.socket=this.createSocket()}onopen(){this.cachedMessages.forEach(t=>this.socket.send(t)),this.cachedMessages=[]}send(t){this.socket.readyState===WebSocket.OPEN?this.socket.send(t):this.cachedMessages.push(t)}};var o;(function(e){e.MESSAGE_TYPE_SOURCEMAP="s",e.MESSAGE_TYPE_COVERAGE="c"})(o||(o={}));var C=20,p=1e3,a=class{constructor(t,e){this.milliseconds=t;this.onCountedToZero=e;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)}},r=class{constructor(t){this.socket=t,this.cachedCoveredPositions=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new a(p,()=>this.flush())}add(t){let e=t.split(":");if(e.length!==3)return;let[c,u,l]=e,i=this.cachedCoveredPositions.get(c);i||(i=new Set,this.cachedCoveredPositions.set(c,i)),i.add(`${u}:${l}`),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=C&&this.flush()}flush(){this.numberOfCachedPositions!==0&&(this.flushCountdown.stopCountdown(),this.cachedCoveredPositions.forEach((t,e)=>{this.socket.send(`${o.MESSAGE_TYPE_COVERAGE} ${e} ${Array.from(t).join(" ")}`)}),this.cachedCoveredPositions=new Map,this.numberOfCachedPositions=0)}};console.log("Starting coverage forwarding worker.");var h=new n("ws://$REPORT_TO_HOST:$REPORT_TO_PORT/socket"),d=new r(h);onmessage=s=>{let t=s.data;t.startsWith(o.MESSAGE_TYPE_SOURCEMAP)?h.send(t):t==="unload"?d.flush():d.add(t)};\n')}function u(){return c()}function E(){return typeof window!="undefined"}function c(){return window}function m(e,n){let t=u()[e];return t||(t=n,u()[e]=t),t}var L="s",S=class{constructor(n,t){this.coverageObj=n;this.path=t}get(n,t,o){let r=n[t];return r!==Object(r)?r:w(this.coverageObj,r,[...this.path,t])}set(n,t,o){let r=[...this.path,t];if(r[0]===L){let i=this.coverageObj.hash,s=this.coverageObj.statementMap[r[1]].start;u()._$Bc(i,s.line,s.column)}return!0}};function w(e,n,t){return new Proxy(n,new S(e,t))}var _=b(k());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 M={add:U};var P=b(O()),D=_.default?P.default:M,d=new Set,T=!1;function H(){T||(T=!0,D.add(B))}function W(e){if(H(),typeof e!="function")throw new Error("Listener is no function");d.add(e);var n={remove:function(){return d.delete(e)},run:function(){return d.delete(e),e()}};return n}function B(){var e=[];return d.forEach(function(n){e.push(n()),d.delete(n)}),Promise.all(e)}var l;(function(t){t.MESSAGE_TYPE_SOURCEMAP="s",t.MESSAGE_TYPE_COVERAGE="c"})(l||(l={}));var R=m("__TS_AGENT",{});function v(){return R._$BcWorker}function Y(e){return R._$BcWorker=e,e}u().makeCoverageInterceptor=function(e){let n=e.hash;if(!v()){let t=Y(new p);(function(){let r=function(i){let s=c()[i];c()[i]=function(...a){if(t.postMessage("unload"),s)return s.apply(this,a)},E()&&Object.defineProperty(c(),i,{get:function(){return s},set:function(a){s=a}})};r("onunload"),r("onbeforeunload"),W(()=>t.postMessage("unload"))})()}return function(){let o=m("sentMaps",new Set);e.inputSourceMap&&(o.has(e.path)||(v().postMessage(`${l.MESSAGE_TYPE_SOURCEMAP} ${n}:${JSON.stringify(e.inputSourceMap)}`),o.add(e.path)))}(),function(){let o=new Set;u()._$Bc=(r,i,s)=>{let a=`${r}:${i}:${s}`;o.has(a)||(v().postMessage(a),o.add(a))}}(),w(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.23",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
16
16
|
"build": "tsc --project tsconfig.json && node esbuild.mjs",
|
|
17
|
-
"
|
|
17
|
+
"instrumenter": "node dist/src/main.js",
|
|
18
18
|
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|