@teamscale/javascript-instrumenter 0.1.0-beta.7 → 0.1.0-beta.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.1.0-beta.7",
3
+ "version": "0.1.0-beta.8",
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,10 +23,10 @@
23
23
  "dist/**/*"
24
24
  ],
25
25
  "devDependencies": {
26
- "@babel/core": "^7.24.0",
27
- "@babel/plugin-transform-modules-commonjs": "^7.23.3",
28
- "@babel/preset-env": "^7.24.0",
29
- "@types/argparse": "^2.0.15",
26
+ "@babel/core": "^7.24.4",
27
+ "@babel/plugin-transform-modules-commonjs": "^7.24.1",
28
+ "@babel/preset-env": "^7.24.4",
29
+ "@types/argparse": "^2.0.16",
30
30
  "@types/async": "^3.2.24",
31
31
  "@types/babel__generator": "^7.6.8",
32
32
  "@types/babel__traverse": "^7.20.5",
@@ -35,7 +35,7 @@
35
35
  "@types/glob": "^8.1.0",
36
36
  "@types/istanbul-lib-instrument": "^1.7.7",
37
37
  "@types/jest": "^29.5.12",
38
- "@types/node": "^20.11.28",
38
+ "@types/node": "^20.12.6",
39
39
  "@types/ws": "^8.5.10",
40
40
  "babel-jest": "^29.7.0",
41
41
  "esbuild": "^0.20.2",
@@ -45,14 +45,14 @@
45
45
  "ts-jest": "^29.1.2",
46
46
  "ts-node": "^10.9.2",
47
47
  "tslib": "^2.6.2",
48
- "typescript": "^5.4.2"
48
+ "typescript": "^5.4.4"
49
49
  },
50
50
  "dependencies": {
51
- "@cqse/commons": "0.1.0-beta.6",
51
+ "@cqse/commons": "0.1.0-beta.7",
52
52
  "@teamscale/lib-instrument": "workspace:../lib-instrument",
53
- "@babel/generator": "^7.23.6",
54
- "@babel/parser": "^7.24.0",
55
- "@babel/traverse": "^7.24.0",
53
+ "@babel/generator": "^7.24.4",
54
+ "@babel/parser": "^7.24.4",
55
+ "@babel/traverse": "^7.24.1",
56
56
  "@babel/types": "^7.24.0",
57
57
  "@types/micromatch": "^4.0.6",
58
58
  "argparse": "^2.0.1",
@@ -60,7 +60,7 @@
60
60
  "bunyan": "^1.8.15",
61
61
  "convert-source-map": "^2.0.0",
62
62
  "foreground-child": "^3.1.1",
63
- "glob": "^10.3.10",
63
+ "glob": "^10.3.12",
64
64
  "micromatch": "4.0.5",
65
65
  "mkdirp": "^3.0.1",
66
66
  "source-map": "0.7.4",
@@ -33,4 +33,17 @@ export interface CollectorSpecifierRelative {
33
33
  * Specifies how the vaccine can reach the collector.
34
34
  */
35
35
  export type CollectorSpecifier = CollectorSpecifierUrl | CollectorSpecifierRelative;
36
+ /**
37
+ * Message to the worker to report the location of the profiled document.
38
+ */
39
+ export interface LocationMessage {
40
+ /** Message type. */
41
+ type: 'location';
42
+ /** Hostname of the profiled document, e.g. "localhost". */
43
+ hostname: string;
44
+ /** Port of the profiled document, e.g. "1234" */
45
+ port: string;
46
+ }
47
+ /** Enumerates all types of messages to the worker. */
48
+ export type WorkerMessage = LocationMessage;
36
49
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,mCAAmC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC7B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,mCAAmC;IACnC,IAAI,EAAE,UAAU,CA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GAAG,eAAe,CAAA"}
package/dist/vaccine.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{function u(t){let o=new Blob([t],{type:"text/javascript"}),e=URL.createObjectURL(o),r=new Worker(e);return URL.revokeObjectURL(e),r}function d(){return u('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(){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 c=class{constructor(e,o){this.milliseconds=e;this.onCountedToZero=o;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 m=20,C=1e3,v="c",a=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new c(C,()=>this.flush())}addLines(e,o){let t=this.cachedCoveredRanges.get(e);t||(t=new Set,this.cachedCoveredRanges.set(e,t)),o.forEach(r=>t.add(r)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=m&&this.flush()}arrayToLineCov(e){let o=[];for(let t of e)o.push(`${t}`);return o.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((o,t)=>{e.push(`@${t}`),e.push(this.arrayToLineCov(o))}),this.socket.send(`${v} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};var l=class s{static resolve(e){switch(e.type){case"url":return e.url;case"relative":return s.resolveRelative(location.host,location.port,e)}}static resolveRelative(e,o,t){var u;let r=e;t.hostReplace&&(r=e.replace(t.hostReplace.search,t.hostReplace.replace));let g=(u=t.scheme)!=null?u:"ws",n;t.port===void 0?n="":t.port==="keep"?n=`:${o}`:n=`:${t.port}`;let h="";t.path&&(h=`/${t.path}`);let d=`${g}://${r}${n}${h}`;return console.debug(`Resolved collector URL ${d} from ${e}:${o}`),d}};console.log("Starting coverage forwarding worker.");var f=new i(`${l.resolve($COLLECTOR_SPECIFIER)}/socket`),p=new a(f);onmessage=s=>{if(Array.isArray(s.data)){let[e,o]=s.data;p.addLines(e,o)}else s.data==="unload"?p.flush():console.error(`No handler for message: ${s.data}`)};\n')}function l(){return f()}function f(){return window}function g(t,o){let e=l()[t];return e||(e=o,l()[t]=e),e}function p(t,o){let e=new Map;function r(s){let n=e.get(s);return n||(n={lines:new Set},e.set(s,n),n)}function i(s,n,b=n){let h=r(s).lines;for(let c=n;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 m(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)])});l()._$l=w.putLineCoverage;if(!C()){let t=m(new d);(function(){let e=()=>{w.flush(),t.postMessage("unload")},r=function(a,s){s&&s.addEventListener(a,e,{capture:!0})},i=f();r("blur",i),r("unload",i),r("visibilitychange",i),r("beforeunload",i)})()}})();
1
+ "use strict";(()=>{function u(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),a=new Worker(t);return URL.revokeObjectURL(t),a}function d(){return u('var i=class{constructor(){this.cachedMessages=[]}connect(e){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!==null&&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 a=class{constructor(e,o){this.milliseconds=e;this.onCountedToZero=o;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 C=20,f=1e3,v="c",c=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new a(f,()=>this.flush())}addLines(e,o){let t=this.cachedCoveredRanges.get(e);t||(t=new Set,this.cachedCoveredRanges.set(e,t)),o.forEach(n=>t.add(n)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=C&&this.flush()}arrayToLineCov(e){let o=[];for(let t of e)o.push(`${t}`);return o.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((o,t)=>{e.push(`@${t}`),e.push(this.arrayToLineCov(o))}),this.socket.send(`${v} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};var l=class s{static resolve(e,o,t){switch(e.type){case"url":return e.url;case"relative":return s.resolveRelative(o,t,e)}}static resolveRelative(e,o,t){var u;let n=e;t.hostReplace&&(n=e.replace(t.hostReplace.search,t.hostReplace.replace));let m=(u=t.scheme)!=null?u:"ws",r;t.port===void 0?r="":t.port==="keep"?r=`:${o}`:r=`:${t.port}`;let h="";t.path&&(h=`/${t.path}`);let d=`${m}://${n}${r}${h}`;return console.debug(`Resolved collector URL ${d} from ${e}:${o}`),d}};console.log("Starting coverage forwarding worker.");var g=new i,p=new c(g);onmessage=s=>{if(Array.isArray(s.data)){let[e,o]=s.data;p.addLines(e,o)}else if(s.data==="unload")p.flush();else if(s.data.type==="location"){let e=s.data,o=l.resolve($COLLECTOR_SPECIFIER,e.hostname,e.port);g.connect(`${o}/socket`)}else console.error(`No handler for message: ${s.data}`)};\n')}function c(){return f()}function f(){return window}function g(e,n){let t=c()[e];return t||(t=n,c()[e]=t),t}function p(e,n){let t=new Map;function a(i){let o=t.get(i);return o||(o={lines:new Set},t.set(i,o),o)}function s(i,o,w=o){let h=a(i).lines;for(let l=o;l<=w;l++)h.add(l);h.size>255&&r()}function r(){n(t),t.clear()}return setInterval(()=>r(),e),{putLineCoverage:s,flush:r}}var v=g("__TS_AGENT",{});function m(){return v._$BcWorker}function b(e){return v._$BcWorker=e,e}var C=p(250,e=>{for(let n of e.entries())m().postMessage([n[0],Array.from(n[1].lines)])});c()._$l=C.putLineCoverage;if(!m()){let e=b(new d),n={type:"location",hostname:document.location.hostname,port:document.location.port};e.postMessage(n),function(){let a=()=>{C.flush(),e.postMessage("unload")},s=function(i,o){o&&o.addEventListener(i,a,{capture:!0})},r=f();s("blur",r),s("unload",r),s("visibilitychange",r),s("beforeunload",r)}()}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.1.0-beta.7",
3
+ "version": "0.1.0-beta.8",
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,10 +15,10 @@
15
15
  "dist/**/*"
16
16
  ],
17
17
  "devDependencies": {
18
- "@babel/core": "^7.24.0",
19
- "@babel/plugin-transform-modules-commonjs": "^7.23.3",
20
- "@babel/preset-env": "^7.24.0",
21
- "@types/argparse": "^2.0.15",
18
+ "@babel/core": "^7.24.4",
19
+ "@babel/plugin-transform-modules-commonjs": "^7.24.1",
20
+ "@babel/preset-env": "^7.24.4",
21
+ "@types/argparse": "^2.0.16",
22
22
  "@types/async": "^3.2.24",
23
23
  "@types/babel__generator": "^7.6.8",
24
24
  "@types/babel__traverse": "^7.20.5",
@@ -27,7 +27,7 @@
27
27
  "@types/glob": "^8.1.0",
28
28
  "@types/istanbul-lib-instrument": "^1.7.7",
29
29
  "@types/jest": "^29.5.12",
30
- "@types/node": "^20.11.28",
30
+ "@types/node": "^20.12.6",
31
31
  "@types/ws": "^8.5.10",
32
32
  "babel-jest": "^29.7.0",
33
33
  "esbuild": "^0.20.2",
@@ -37,13 +37,13 @@
37
37
  "ts-jest": "^29.1.2",
38
38
  "ts-node": "^10.9.2",
39
39
  "tslib": "^2.6.2",
40
- "typescript": "^5.4.2"
40
+ "typescript": "^5.4.4"
41
41
  },
42
42
  "dependencies": {
43
- "@cqse/commons": "0.1.0-beta.6",
44
- "@babel/generator": "^7.23.6",
45
- "@babel/parser": "^7.24.0",
46
- "@babel/traverse": "^7.24.0",
43
+ "@cqse/commons": "0.1.0-beta.7",
44
+ "@babel/generator": "^7.24.4",
45
+ "@babel/parser": "^7.24.4",
46
+ "@babel/traverse": "^7.24.1",
47
47
  "@babel/types": "^7.24.0",
48
48
  "@types/micromatch": "^4.0.6",
49
49
  "argparse": "^2.0.1",
@@ -51,14 +51,14 @@
51
51
  "bunyan": "^1.8.15",
52
52
  "convert-source-map": "^2.0.0",
53
53
  "foreground-child": "^3.1.1",
54
- "glob": "^10.3.10",
54
+ "glob": "^10.3.12",
55
55
  "micromatch": "4.0.5",
56
56
  "mkdirp": "^3.0.1",
57
57
  "source-map": "0.7.4",
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.7"
61
+ "@teamscale/lib-instrument": "0.1.0-beta.8"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"