@teamscale/javascript-instrumenter 0.0.1-beta.2 → 0.0.1-beta.9
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/README.md +4 -11
- 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/main.js +0 -0
- package/dist/vaccine.js +1 -221
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ or
|
|
|
52
52
|
There are several options to run the Instrumenter. For example, via `yarn` by running
|
|
53
53
|
|
|
54
54
|
```
|
|
55
|
-
yarn
|
|
55
|
+
yarn instrumenter
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
or via `npx` by running
|
|
@@ -74,24 +74,17 @@ the file must contain source-map information, or the source-map file
|
|
|
74
74
|
must be placed along with the source file in the same directory.
|
|
75
75
|
|
|
76
76
|
```
|
|
77
|
-
yarn
|
|
77
|
+
yarn instrumenter --inplace ./the/path/to/the/file.js
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
```
|
|
81
|
-
yarn
|
|
81
|
+
yarn instrumenter --inplace ./the/path/to/the/file.js --source-map ./the/path/to/the/source.map
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
```
|
|
85
|
-
yarn
|
|
85
|
+
yarn instrumenter ./the/path/to/the/file.js --to ./the/file/path/to/write/to.js
|
|
86
86
|
```
|
|
87
87
|
|
|
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
88
|
### Integration with Testing Frameworks
|
|
96
89
|
|
|
97
90
|
This is planned work: Provide a Babel plugin that provides a code transformation
|
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.9",
|
|
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.'
|
package/dist/src/main.js
CHANGED
|
File without changes
|
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.9",
|
|
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": [
|