@teamscale/javascript-instrumenter 1.0.0-beta.6 → 1.0.0-beta.7
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 +0 -25
- package/dist/package.json +22 -28
- package/dist/src/App.d.ts +0 -36
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +4 -54
- package/dist/src/instrumenter/FileSystem.d.ts +0 -28
- package/dist/src/instrumenter/FileSystem.d.ts.map +1 -1
- package/dist/src/instrumenter/FileSystem.js +2 -32
- package/dist/src/instrumenter/Instrumenter.d.ts +2 -69
- package/dist/src/instrumenter/Instrumenter.d.ts.map +1 -1
- package/dist/src/instrumenter/Instrumenter.js +10 -94
- package/dist/src/instrumenter/InstrumenterConfig.d.ts +0 -9
- package/dist/src/instrumenter/InstrumenterConfig.d.ts.map +1 -1
- package/dist/src/instrumenter/InstrumenterConfig.js +0 -6
- package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts +1 -3
- package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts.map +1 -1
- package/dist/src/instrumenter/RelativeCollectorPatternParser.js +9 -9
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.js +12 -7
- package/dist/src/instrumenter/Task.d.ts +0 -144
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +29 -110
- package/dist/src/instrumenter/TaskBuilder.d.ts +0 -50
- package/dist/src/instrumenter/TaskBuilder.d.ts.map +1 -1
- package/dist/src/instrumenter/TaskBuilder.js +12 -59
- package/dist/src/instrumenter/WebToolkit.d.ts +0 -27
- package/dist/src/instrumenter/WebToolkit.d.ts.map +1 -1
- package/dist/src/instrumenter/WebToolkit.js +0 -27
- package/dist/src/main.js +3 -1
- package/dist/src/vaccine/types.d.ts +0 -37
- package/dist/src/vaccine/types.d.ts.map +1 -1
- package/dist/vaccine.js +1 -1
- package/package.json +13 -13
|
@@ -1,65 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The collector URL is known at build time.
|
|
3
|
-
*/
|
|
4
1
|
export interface CollectorSpecifierUrl {
|
|
5
|
-
/** Type of collector specifier. */
|
|
6
2
|
type: 'url';
|
|
7
|
-
/** The URL under which the collector can be reached at runtime. */
|
|
8
3
|
url: string;
|
|
9
4
|
}
|
|
10
|
-
/** Describes a one-time search and replace operation on a string. */
|
|
11
5
|
export interface SearchReplace {
|
|
12
|
-
/** Literal string to search for. */
|
|
13
6
|
search: string;
|
|
14
|
-
/** Literal replacement string. */
|
|
15
7
|
replace: string;
|
|
16
8
|
}
|
|
17
|
-
/**
|
|
18
|
-
* The collector can be reached by replacing a term in location.host and optionally changing the port.
|
|
19
|
-
*/
|
|
20
9
|
export interface CollectorSpecifierRelative {
|
|
21
|
-
/** Type of collector specifier. */
|
|
22
10
|
type: 'relative';
|
|
23
|
-
/** Literal replacement string. */
|
|
24
11
|
hostReplace?: SearchReplace;
|
|
25
|
-
/** Optional port. If no port is given, uses the protocol's default port. */
|
|
26
12
|
port?: number | 'keep';
|
|
27
|
-
/** Optional URL scheme to use. If no scheme is given, uses ws. */
|
|
28
13
|
scheme?: string;
|
|
29
|
-
/** Optional path. If no path is given, uses only the hostname. */
|
|
30
14
|
path?: string;
|
|
31
15
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Specifies how the vaccine can reach the collector.
|
|
34
|
-
*/
|
|
35
16
|
export type CollectorSpecifier = CollectorSpecifierUrl | CollectorSpecifierRelative;
|
|
36
|
-
/**
|
|
37
|
-
* Message to the worker to report the location of the profiled document.
|
|
38
|
-
*/
|
|
39
17
|
export interface LocationMessage {
|
|
40
|
-
/** Message type. */
|
|
41
18
|
type: 'location';
|
|
42
|
-
/** Hostname of the profiled document, e.g. "localhost". */
|
|
43
19
|
hostname: string;
|
|
44
|
-
/** Port of the profiled document, e.g. "1234" */
|
|
45
20
|
port: string;
|
|
46
21
|
}
|
|
47
|
-
/** Details about the bucket the coverage is added to. */
|
|
48
22
|
export type CoverageBucketSpecifier = {
|
|
49
|
-
/** A unique identifier of the instrumented application. */
|
|
50
23
|
appId: string;
|
|
51
|
-
/**
|
|
52
|
-
* The ID of the profiler configuration to use. No config ID might be given
|
|
53
|
-
* if the coverage shall be collected while Teamscale is not available.
|
|
54
|
-
*/
|
|
55
24
|
configId?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Concrete collector configuration options to pass. ATTENTION: These are generally
|
|
58
|
-
* unencrypted and shall not contain sensitive information or the execution
|
|
59
|
-
* environment must ensure that they cannot be leaked.
|
|
60
|
-
*/
|
|
61
25
|
configOptions?: string;
|
|
62
|
-
/** The project commit or revision to contribute coverage for. */
|
|
63
26
|
commit: string;
|
|
64
27
|
};
|
|
65
28
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,qBAAqB;IAErC,IAAI,EAAE,KAAK,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;CACZ;AAGD,MAAM,WAAW,aAAa;IAE7B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,MAAM,CAAC;CAChB;AAKD,MAAM,WAAW,0BAA0B;IAE1C,IAAI,EAAE,UAAU,CAAC;IAEjB,WAAW,CAAC,EAAE,aAAa,CAAC;IAE5B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAKD,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAKpF,MAAM,WAAW,eAAe;IAE/B,IAAI,EAAE,UAAU,CAAC;IAEjB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;CACb;AAGD,MAAM,MAAM,uBAAuB,GAAG;IAErC,KAAK,EAAE,MAAM,CAAC;IAMd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAOlB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,MAAM,EAAE,MAAM,CAAC;CAEf,CAAA"}
|
package/dist/vaccine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 h(){return u('var
|
|
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 h(){return u('var f=Object.defineProperty;var S=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>S(o,typeof e!="symbol"?e+"":e,t);var c=class{constructor(){n(this,"url");n(this,"socket");n(this,"cachedMessages");n(this,"messageOnConnect");n(this,"reconnectTimer");this.socket=null,this.url="",this.messageOnConnect="",this.cachedMessages=[],this.reconnectTimer=null}connect(e,t){this.url=e,this.messageOnConnect=t,this.socket=this.createSocket(),this.startReconnectTimer()}createSocket(){let e=new WebSocket(this.url);return e.onopen=()=>this.onopen(),e.onclose=()=>this.onclose(),e}startReconnectTimer(){this.reconnectTimer!==null&&clearInterval(this.reconnectTimer),this.reconnectTimer=setInterval(()=>{this.checkConnectionAndReconnect()},1e4)}checkConnectionAndReconnect(){var e;(this.socket===null||this.socket.readyState!==WebSocket.OPEN)&&((e=this.socket)==null||e.close(),console.log("Connection lost, attempting to reconnect..."),this.socket=this.createSocket())}onclose(){this.socket=this.createSocket()}onopen(){console.log("Connection to Coverage Collector established."),this.socket.send(this.messageOnConnect),this.cachedMessages.forEach(e=>this.socket.send(e)),this.cachedMessages=[]}send(e){if(this.socket!==null&&this.socket.readyState===WebSocket.OPEN)try{this.socket.send(e)}catch(t){console.error("Sending failed. Message will be re-sent when connection is available again.",t),this.addMessageToCache(e)}else this.addMessageToCache(e)}addMessageToCache(e){this.cachedMessages.push(e),this.cachedMessages.length%500===0&&console.log(`More than ${this.cachedMessages.length} messages are queued to be sent.`)}disconnect(){this.reconnectTimer!==null&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null),this.socket!==null&&(this.socket.close(),this.socket=null)}};var a=class{constructor(e,t){this.milliseconds=e;this.onCountedToZero=t;n(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 k=20,E=1e3,b="c",m="b",l=class{constructor(e){n(this,"socket");n(this,"flushCountdown");n(this,"cachedCoveredRanges");n(this,"numberOfCachedPositions");this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new a(E,()=>this.flush())}addLines(e,t){let s=this.cachedCoveredRanges.get(e);s||(s=new Set,this.cachedCoveredRanges.set(e,s)),t.forEach(i=>s.add(i)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=k&&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(`${b} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};var h=class o{static resolve(e,t,s){switch(e.type){case"url":return e.url;case"relative":return o.resolveRelative(t,s,e)}}static resolveRelative(e,t,s){var g;let i=e;s.hostReplace&&(i=e.replace(s.hostReplace.search,s.hostReplace.replace));let v=(g=s.scheme)!=null?g:"ws",r;s.port===void 0?r="":s.port==="keep"?r=`:${t}`:r=`:${s.port}`;let d="";s.path&&(d=`/${s.path}`);let u=`${v}://${i}${r}${d}`;return console.debug(`Resolved collector URL ${u} from ${e}:${t}`),u}};console.log("Starting coverage forwarding worker.");var C=new c,p=new l(C);onmessage=o=>{if(Array.isArray(o.data)){let[e,t]=o.data;p.addLines(e,t)}else if(o.data==="unload")p.flush();else if(o.data.type==="location"){let e=o.data,t=h.resolve($COLLECTOR_SPECIFIER,e.hostname,e.port),s=`${m} $BUCKET_SPECIFIER`;C.connect(`${t}/socket`,s)}else console.error(`No handler for message: ${o.data}`)};\n')}function c(){return d()}function d(){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 r(i,o,k=o){let f=a(i).lines;for(let l=o;l<=k;l++)f.add(l);f.size>255&&s()}function s(){n(t),t.clear()}return setInterval(()=>s(),e),{putLineCoverage:r,flush:s}}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 h),n={type:"location",hostname:document.location.hostname,port:document.location.port};e.postMessage(n),(function(){let a=()=>{C.flush(),e.postMessage("unload")},r=function(i,o){o&&o.addEventListener(i,a,{capture:!0})},s=d();r("blur",s),r("unload",s),r("visibilitychange",s),r("beforeunload",s)})()}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
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",
|
|
@@ -12,24 +12,24 @@
|
|
|
12
12
|
"dist/**/*"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@babel/generator": "^7.
|
|
16
|
-
"@babel/parser": "^7.
|
|
17
|
-
"@babel/traverse": "^7.
|
|
18
|
-
"@babel/types": "^7.
|
|
19
|
-
"@types/micromatch": "^4.0.
|
|
15
|
+
"@babel/generator": "^7.28.5",
|
|
16
|
+
"@babel/parser": "^7.28.5",
|
|
17
|
+
"@babel/traverse": "^7.28.5",
|
|
18
|
+
"@babel/types": "^7.28.5",
|
|
19
|
+
"@types/micromatch": "^4.0.10",
|
|
20
20
|
"async": "^3.2.6",
|
|
21
21
|
"bunyan": "^1.8.15",
|
|
22
22
|
"convert-source-map": "^2.0.0",
|
|
23
|
-
"foreground-child": "^3.3.
|
|
24
|
-
"glob": "^11.0.1",
|
|
23
|
+
"foreground-child": "^3.3.1",
|
|
25
24
|
"micromatch": "4.0.8",
|
|
26
25
|
"mkdirp": "^3.0.1",
|
|
27
|
-
"source-map": "0.7.
|
|
26
|
+
"source-map": "0.7.6",
|
|
27
|
+
"tinyglobby": "^0.2.15",
|
|
28
28
|
"unload": "^2.4.1",
|
|
29
|
-
"uuid": "^
|
|
29
|
+
"uuid": "^13.0.0",
|
|
30
30
|
"web-worker": "^1.5.0",
|
|
31
|
-
"@cqse/commons": "1.0.0-beta.
|
|
32
|
-
"@teamscale/lib-instrument": "1.0.0-beta.
|
|
31
|
+
"@cqse/commons": "1.0.0-beta.7",
|
|
32
|
+
"@teamscale/lib-instrument": "1.0.0-beta.7"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"build": "tsc --project tsconfig.json && pnpm buildVaccine",
|
|
40
40
|
"buildVaccine": "node esbuild.mjs",
|
|
41
41
|
"instrumenter": "node dist/src/main.js",
|
|
42
|
-
"test": "
|
|
42
|
+
"test": "node --import tsx --test test/**/*.test.ts"
|
|
43
43
|
}
|
|
44
44
|
}
|