@teamscale/javascript-instrumenter 0.0.1-beta.7 → 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/dist/package.json +1 -1
- package/dist/src/App.js +1 -1
- package/dist/src/main.js +0 -0
- package/dist/vaccine.js +1 -221
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/src/App.js
CHANGED
|
@@ -59,7 +59,7 @@ class App {
|
|
|
59
59
|
parser.add_argument('-v', '--version', { action: 'version', version: package_json_1.version });
|
|
60
60
|
parser.add_argument('-i', '--in-place', {
|
|
61
61
|
action: 'store_true',
|
|
62
|
-
help: 'If set, the original files to instrument are replaced
|
|
62
|
+
help: 'If set, the original files to instrument are replaced by their instrumented counterparts.'
|
|
63
63
|
});
|
|
64
64
|
parser.add_argument('-d', '--debug', { action: 'store_true' });
|
|
65
65
|
parser.add_argument('-o', '--to', {
|
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