@teamscale/javascript-instrumenter 0.1.0-beta.4 → 0.1.0-beta.5

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 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
- in the [Teamscale Documentation](https://docs.teamscale.com/howto/recording-test-coverage-for-javascript/).
12
+ in the [Teamscale Documentation](https://docs.teamscale.com/howto/setting-up-profiler-tga/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.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
5
5
  "main": "dist/src/main.js",
6
6
  "bin": "dist/src/main.js",
@@ -23,9 +23,9 @@
23
23
  "dist/**/*"
24
24
  ],
25
25
  "devDependencies": {
26
- "@babel/core": "^7.23.7",
26
+ "@babel/core": "^7.23.9",
27
27
  "@babel/plugin-transform-modules-commonjs": "^7.23.3",
28
- "@babel/preset-env": "^7.23.8",
28
+ "@babel/preset-env": "^7.23.9",
29
29
  "@types/argparse": "^2.0.14",
30
30
  "@types/async": "^3.2.24",
31
31
  "@types/babel__generator": "^7.6.8",
@@ -34,26 +34,26 @@
34
34
  "@types/convert-source-map": "^2.0.3",
35
35
  "@types/glob": "^8.1.0",
36
36
  "@types/istanbul-lib-instrument": "^1.7.7",
37
- "@types/jest": "^29.5.11",
38
- "@types/node": "^20.11.0",
37
+ "@types/jest": "^29.5.12",
38
+ "@types/node": "^20.11.19",
39
39
  "@types/ws": "^8.5.10",
40
40
  "babel-jest": "^29.7.0",
41
- "esbuild": "^0.19.11",
41
+ "esbuild": "^0.20.0",
42
42
  "esbuild-plugin-inline-worker": "^0.1.1",
43
43
  "jest": "^29.7.0",
44
44
  "rimraf": "^5.0.5",
45
- "ts-jest": "^29.1.1",
45
+ "ts-jest": "^29.1.2",
46
46
  "ts-node": "^10.9.2",
47
47
  "tslib": "^2.6.2",
48
48
  "typescript": "^5.3.3"
49
49
  },
50
50
  "dependencies": {
51
- "@cqse/commons": "0.1.0-beta.2",
51
+ "@cqse/commons": "0.1.0-beta.4",
52
52
  "@teamscale/lib-instrument": "workspace:../lib-instrument",
53
53
  "@babel/generator": "^7.23.6",
54
- "@babel/parser": "^7.23.6",
55
- "@babel/traverse": "^7.23.7",
56
- "@babel/types": "^7.23.6",
54
+ "@babel/parser": "^7.23.9",
55
+ "@babel/traverse": "^7.23.9",
56
+ "@babel/types": "^7.23.9",
57
57
  "@types/micromatch": "^4.0.6",
58
58
  "argparse": "^2.0.1",
59
59
  "async": "^3.2.5",
package/dist/src/main.js CHANGED
@@ -18,7 +18,7 @@ App_1.App.run()
18
18
  const stats = (_b = result.task) === null || _b === void 0 ? void 0 : _b.originSourcePattern.retrieveMatchingFiles();
19
19
  console.log(`\tSource origin matches`);
20
20
  console.log(`\t\tInclude patterns: [${stats.includePatterns}]`);
21
- console.log(`\t\tExclude patterns: [${stats.excludeMatches}]`);
21
+ console.log(`\t\tExclude patterns: [${stats.excludePatterns}]`);
22
22
  console.log(`\t\tInclude matches: ${stats.includeMatches.length}`);
23
23
  console.log(`\t\tExclude matches: ${stats.excludeMatches.length}`);
24
24
  console.log(`\t\tNeither matches: ${stats.neitherExcludedNorIncluded.length}`);
package/dist/vaccine.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{function c(t){let n=new Blob([t],{type:"text/javascript"}),e=URL.createObjectURL(n),o=new Worker(e);return URL.revokeObjectURL(e),o}function l(){return c('var r=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(){console.log("Connection to Coverage Collector established."),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),this.cachedMessages.length%500===0&&console.log(`More than ${this.cachedMessages.length} messages are queued to be sent.`))}};var i=class{constructor(e,t){this.milliseconds=e;this.onCountedToZero=t;this.timerHandle=null}restartCountdown(){this.stopCountdown(),this.timerHandle=self.setTimeout(()=>{this.stopCountdown(),this.onCountedToZero()},this.milliseconds)}stopCountdown(){this.timerHandle!==null&&(self.clearTimeout(this.timerHandle),this.timerHandle=null)}};var d=20,l=1e3,u="c",a=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new i(l,()=>this.flush())}addRanges(e,t){let s=this.cachedCoveredRanges.get(e);s||(s={lines:[]},this.cachedCoveredRanges.set(e,s)),t.lines.forEach(n=>s.lines.push(n)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=d&&this.flush()}arrayToLineCov(e){if(e.length%2!==0)throw new Error("Unexpected length of input data.");let t=[];for(let s=0;s<e.length;s=s+2){let n=e[s],c=e[s+1];n===c?t.push(`${n}`):t.push(`${n}-${c}`)}return t.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((t,s)=>{e.push(`@${s}`),e.push(this.arrayToLineCov(t.lines))}),this.socket.send(`${u} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};console.log("Starting coverage forwarding worker.");var g=new r("$REPORT_TO_URL/socket"),h=new a(g);onmessage=o=>{if(Array.isArray(o.data)){let[e,t]=o.data;h.addRanges(e,t)}else o.data==="unload"?h.flush():console.error(`No handler for message: ${o.data}`)};\n')}function u(){return h()}function h(){return window}function d(t,n){let e=u()[t];return e||(e=n,u()[t]=e),e}function f(t,n){let e=new Map;function o(r){let s=e.get(r);return s||(s={lines:[]},e.set(r,s),s)}function i(r,s,C){o(r).lines.push(s,C)}function a(){n(e),e.clear()}return setInterval(()=>a(),t),{putLineCoverage:i,flush:a}}var g=d("__TS_AGENT",{});function p(){return g._$BcWorker}function w(t){return g._$BcWorker=t,t}var v=f(250,t=>{for(let n of t.entries())p().postMessage(n)});u()._$l=v.putLineCoverage;if(!p()){let t=w(new l);(function(){let e=()=>{v.flush(),t.postMessage("unload")},o=function(a,r){r&&r.addEventListener(a,e,{capture:!0})},i=h();o("blur",i),o("unload",i),o("visibilitychange",i),o("beforeunload",i)})()}})();
1
+ "use strict";(()=>{function l(t){let o=new Blob([t],{type:"text/javascript"}),e=URL.createObjectURL(o),n=new Worker(e);return URL.revokeObjectURL(e),n}function d(){return l('var n=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(){console.log("Connection to Coverage Collector established."),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),this.cachedMessages.length%500===0&&console.log(`More than ${this.cachedMessages.length} messages are queued to be sent.`))}};var i=class{constructor(e,t){this.milliseconds=e;this.onCountedToZero=t;this.timerHandle=null}restartCountdown(){this.stopCountdown(),this.timerHandle=self.setTimeout(()=>{this.stopCountdown(),this.onCountedToZero()},this.milliseconds)}stopCountdown(){this.timerHandle!==null&&(self.clearTimeout(this.timerHandle),this.timerHandle=null)}};var h=20,d=1e3,l="c",r=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new i(d,()=>this.flush())}addLines(e,t){let s=this.cachedCoveredRanges.get(e);s||(s=new Set,this.cachedCoveredRanges.set(e,s)),t.forEach(c=>s.add(c)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=h&&this.flush()}arrayToLineCov(e){let t=[];for(let s of e)t.push(`${s}`);return t.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((t,s)=>{e.push(`@${s}`),e.push(this.arrayToLineCov(t))}),this.socket.send(`${l} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};console.log("Starting coverage forwarding worker.");var u=new n("$REPORT_TO_URL/socket"),a=new r(u);onmessage=o=>{if(Array.isArray(o.data)){let[e,t]=o.data;a.addLines(e,t)}else o.data==="unload"?a.flush():console.error(`No handler for message: ${o.data}`)};\n')}function u(){return f()}function f(){return window}function g(t,o){let e=u()[t];return e||(e=o,u()[t]=e),e}function p(t,o){let e=new Map;function n(s){let r=e.get(s);return r||(r={lines:new Set},e.set(s,r),r)}function i(s,r,b=r){let h=n(s).lines;for(let c=r;c<=b;c++)h.add(c);h.size>255&&a()}function a(){o(e),e.clear()}return setInterval(()=>a(),t),{putLineCoverage:i,flush:a}}var v=g("__TS_AGENT",{});function C(){return v._$BcWorker}function k(t){return v._$BcWorker=t,t}var w=p(250,t=>{for(let o of t.entries())C().postMessage([o[0],Array.from(o[1].lines)])});u()._$l=w.putLineCoverage;if(!C()){let t=k(new d);(function(){let e=()=>{w.flush(),t.postMessage("unload")},n=function(a,s){s&&s.addEventListener(a,e,{capture:!0})},i=f();n("blur",i),n("unload",i),n("visibilitychange",i),n("beforeunload",i)})()}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
5
5
  "main": "dist/src/main.js",
6
6
  "bin": "dist/src/main.js",
@@ -15,9 +15,9 @@
15
15
  "dist/**/*"
16
16
  ],
17
17
  "devDependencies": {
18
- "@babel/core": "^7.23.7",
18
+ "@babel/core": "^7.23.9",
19
19
  "@babel/plugin-transform-modules-commonjs": "^7.23.3",
20
- "@babel/preset-env": "^7.23.8",
20
+ "@babel/preset-env": "^7.23.9",
21
21
  "@types/argparse": "^2.0.14",
22
22
  "@types/async": "^3.2.24",
23
23
  "@types/babel__generator": "^7.6.8",
@@ -26,25 +26,25 @@
26
26
  "@types/convert-source-map": "^2.0.3",
27
27
  "@types/glob": "^8.1.0",
28
28
  "@types/istanbul-lib-instrument": "^1.7.7",
29
- "@types/jest": "^29.5.11",
30
- "@types/node": "^20.11.0",
29
+ "@types/jest": "^29.5.12",
30
+ "@types/node": "^20.11.19",
31
31
  "@types/ws": "^8.5.10",
32
32
  "babel-jest": "^29.7.0",
33
- "esbuild": "^0.19.11",
33
+ "esbuild": "^0.20.0",
34
34
  "esbuild-plugin-inline-worker": "^0.1.1",
35
35
  "jest": "^29.7.0",
36
36
  "rimraf": "^5.0.5",
37
- "ts-jest": "^29.1.1",
37
+ "ts-jest": "^29.1.2",
38
38
  "ts-node": "^10.9.2",
39
39
  "tslib": "^2.6.2",
40
40
  "typescript": "^5.3.3"
41
41
  },
42
42
  "dependencies": {
43
- "@cqse/commons": "0.1.0-beta.2",
43
+ "@cqse/commons": "0.1.0-beta.4",
44
44
  "@babel/generator": "^7.23.6",
45
- "@babel/parser": "^7.23.6",
46
- "@babel/traverse": "^7.23.7",
47
- "@babel/types": "^7.23.6",
45
+ "@babel/parser": "^7.23.9",
46
+ "@babel/traverse": "^7.23.9",
47
+ "@babel/types": "^7.23.9",
48
48
  "@types/micromatch": "^4.0.6",
49
49
  "argparse": "^2.0.1",
50
50
  "async": "^3.2.5",
@@ -58,7 +58,7 @@
58
58
  "typescript-optional": "^2.0.1",
59
59
  "unload": "^2.4.1",
60
60
  "web-worker": "^1.3.0",
61
- "@teamscale/lib-instrument": "0.1.0-beta.4"
61
+ "@teamscale/lib-instrument": "0.1.0-beta.5"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"