@teamscale/javascript-instrumenter 1.0.0-beta.6 → 1.0.4

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.
Files changed (38) hide show
  1. package/README.md +0 -25
  2. package/dist/main.mjs +216 -0
  3. package/dist/vaccine.js +1 -1
  4. package/package.json +28 -19
  5. package/dist/package.json +0 -69
  6. package/dist/src/App.d.ts +0 -52
  7. package/dist/src/App.d.ts.map +0 -1
  8. package/dist/src/App.js +0 -283
  9. package/dist/src/instrumenter/FileSystem.d.ts +0 -38
  10. package/dist/src/instrumenter/FileSystem.d.ts.map +0 -1
  11. package/dist/src/instrumenter/FileSystem.js +0 -134
  12. package/dist/src/instrumenter/Instrumenter.d.ts +0 -92
  13. package/dist/src/instrumenter/Instrumenter.d.ts.map +0 -1
  14. package/dist/src/instrumenter/Instrumenter.js +0 -376
  15. package/dist/src/instrumenter/InstrumenterConfig.d.ts +0 -37
  16. package/dist/src/instrumenter/InstrumenterConfig.d.ts.map +0 -1
  17. package/dist/src/instrumenter/InstrumenterConfig.js +0 -165
  18. package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts +0 -8
  19. package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts.map +0 -1
  20. package/dist/src/instrumenter/RelativeCollectorPatternParser.js +0 -53
  21. package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts +0 -2
  22. package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts.map +0 -1
  23. package/dist/src/instrumenter/RelativeCollectorPatternParser.test.js +0 -28
  24. package/dist/src/instrumenter/Task.d.ts +0 -224
  25. package/dist/src/instrumenter/Task.d.ts.map +0 -1
  26. package/dist/src/instrumenter/Task.js +0 -309
  27. package/dist/src/instrumenter/TaskBuilder.d.ts +0 -75
  28. package/dist/src/instrumenter/TaskBuilder.d.ts.map +0 -1
  29. package/dist/src/instrumenter/TaskBuilder.js +0 -228
  30. package/dist/src/instrumenter/WebToolkit.d.ts +0 -40
  31. package/dist/src/instrumenter/WebToolkit.d.ts.map +0 -1
  32. package/dist/src/instrumenter/WebToolkit.js +0 -146
  33. package/dist/src/main.d.ts +0 -3
  34. package/dist/src/main.d.ts.map +0 -1
  35. package/dist/src/main.js +0 -8
  36. package/dist/src/vaccine/types.d.ts +0 -65
  37. package/dist/src/vaccine/types.d.ts.map +0 -1
  38. package/dist/src/vaccine/types.js +0 -2
@@ -1,146 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.determineSymbolMapsDir = determineSymbolMapsDir;
7
- exports.extractGwtCallInfos = extractGwtCallInfos;
8
- exports.loadInputSourceMapsGwt = loadInputSourceMapsGwt;
9
- exports.determineGwtFileUid = determineGwtFileUid;
10
- exports.isGwtBundle = isGwtBundle;
11
- const path_1 = __importDefault(require("path"));
12
- const FileSystem_1 = require("./FileSystem");
13
- const types_1 = require("@babel/types");
14
- const parser_1 = require("@babel/parser");
15
- const commons_1 = require("@cqse/commons");
16
- /**
17
- * There are different places where a 'symbolMaps' folder can be:
18
- * (1) within the `WEB-INF` folder (`WEB-INF/deploy/<module-name>/symbolMaps`)
19
- * or (2) it can be a sibling of the parent `deferredjs` folder.
20
- *
21
- * @param taskFile - Path to the JS bundle file to start searching from.
22
- */
23
- function determineSymbolMapsDir(taskFile) {
24
- const symbolMapDirs = [];
25
- let webInfDir = null;
26
- const pathComponents = path_1.default.resolve(taskFile).split(path_1.default.sep);
27
- for (let i = pathComponents.length - 2; i >= 0; i--) {
28
- const fullDirPath = pathComponents.slice(0, i).join(path_1.default.sep);
29
- const webInfDirCandidate = path_1.default.join(fullDirPath, 'WEB-INF');
30
- if ((0, FileSystem_1.isExistingDirectory)(webInfDirCandidate)) {
31
- webInfDir = webInfDirCandidate;
32
- }
33
- const symbolMapDirCandidate = path_1.default.join(fullDirPath, 'symbolMaps');
34
- if ((0, FileSystem_1.isExistingDirectory)(symbolMapDirCandidate)) {
35
- symbolMapDirs.push(symbolMapDirCandidate);
36
- }
37
- }
38
- if (webInfDir != null) {
39
- (0, FileSystem_1.findSubFolders)(webInfDir, 'symbolMaps').forEach(dir => symbolMapDirs.push(dir));
40
- }
41
- return symbolMapDirs;
42
- }
43
- function expressionToString(expression) {
44
- if ((0, types_1.isMemberExpression)(expression) && (0, types_1.isExpression)(expression.property)) {
45
- return `${expressionToString(expression.object)}.${expressionToString(expression.property)}`;
46
- }
47
- else if ((0, types_1.isIdentifier)(expression)) {
48
- return expression.name;
49
- }
50
- throw new commons_1.IllegalArgumentException('Type of expression not yet supported.');
51
- }
52
- function extractQualifiedFunctionName(call) {
53
- if ((0, types_1.isMemberExpression)(call.callee) || (0, types_1.isIdentifier)(call.callee)) {
54
- return expressionToString(call.callee);
55
- }
56
- throw new commons_1.IllegalArgumentException('Type of callee not yet supported.');
57
- }
58
- /**
59
- * Extract the GWT function calls from the GWT bundle. These function calls
60
- * do have the actual application code as arguments.
61
- *
62
- * Examples of `bundleContent` (without the double quotes):
63
- * "showcase.onScriptDownloaded(["var $wnd = ..... __gwtModuleFunction.__moduleStartupDone($gwt.permProps);\n//# sourceURL=showcase-0.js\n"]);"
64
- * "$wnd.showcase.runAsyncCallback3("function bc(a){Wb((Ze(),Xe),a) ..... nZ5b(El)(3);\n//# sourceURL=showcase-3.js\n")
65
- */
66
- function extractGwtCallInfos(bundleContent) {
67
- const ast = (0, parser_1.parse)(bundleContent);
68
- if (ast.program.body.length === 0) {
69
- return null;
70
- }
71
- if (!(0, types_1.isExpressionStatement)(ast.program.body[0])) {
72
- return null;
73
- }
74
- const call = ast.program.body[0].expression;
75
- if (!(0, types_1.isCallExpression)(call)) {
76
- return null;
77
- }
78
- const qualifiedFunctionName = extractQualifiedFunctionName(call);
79
- const firstArgument = call.arguments[0];
80
- if ((0, types_1.isArrayExpression)(firstArgument)) {
81
- const codeArguments = [];
82
- for (const element of firstArgument.elements) {
83
- if ((0, types_1.isStringLiteral)(element)) {
84
- codeArguments.push(element.value);
85
- }
86
- else {
87
- throw new Error(`Did expect only string arguments in the call of "${qualifiedFunctionName}".`);
88
- }
89
- }
90
- return { codeArguments, functionName: qualifiedFunctionName, codeAsArrayArgument: true };
91
- }
92
- else if ((0, types_1.isStringLiteral)(firstArgument)) {
93
- const codeArgument = firstArgument.value;
94
- return { codeArguments: [codeArgument], functionName: qualifiedFunctionName, codeAsArrayArgument: false };
95
- }
96
- return null;
97
- }
98
- /**
99
- * Load the source map for the given GWT bundle.
100
- */
101
- function loadInputSourceMapsGwt(taskFile, bundleFile) {
102
- // taskFile:
103
- // war/stockwatcher/E2C1FB09E006E0A2420123D036967150.cache.js
104
- // war/showcase/deferredjs/28F63AD125178AAAB80993C11635D26F/5.cache.js
105
- const mapDirs = determineSymbolMapsDir(taskFile);
106
- const fileNumberMatcher = /sourceURL=(.*)-(\d+).js(\\n)*\s*$/;
107
- const mapModules = bundleFile.codeArguments.map(code => {
108
- const matches = fileNumberMatcher.exec(code);
109
- if (!matches) {
110
- return ['', -1];
111
- }
112
- return [matches[1], Number.parseInt(matches[2])];
113
- });
114
- const sourceMapFiles = mapModules.map(module => {
115
- for (const mapDir of mapDirs) {
116
- const mapFileCandidate = `${mapDir}/${bundleFile.fragmentId}_sourceMap${module[1]}.json`;
117
- if ((0, FileSystem_1.isExistingFile)(mapFileCandidate)) {
118
- return mapFileCandidate;
119
- }
120
- }
121
- return undefined;
122
- });
123
- return sourceMapFiles.map(file => {
124
- if (file) {
125
- return (0, FileSystem_1.sourceMapFromMapFile)(file);
126
- }
127
- return undefined;
128
- });
129
- }
130
- /**
131
- * Determine the ID of the given GWT bundle file.
132
- */
133
- function determineGwtFileUid(filename) {
134
- const fileUidMatcher = /.*([0-9A-Fa-f]{32}).*/;
135
- const uidMatches = fileUidMatcher.exec(filename);
136
- if (!uidMatches || uidMatches.length < 2) {
137
- return undefined;
138
- }
139
- return uidMatches[1];
140
- }
141
- /**
142
- * Is the given bundle a GWT bundle?
143
- */
144
- function isGwtBundle(bundle) {
145
- return bundle.type === 'gwt';
146
- }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":""}
package/dist/src/main.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const App_1 = require("./App");
5
- // Main function of the instrumenter
6
- App_1.App.run().catch(reason => {
7
- console.error(reason);
8
- });
@@ -1,65 +0,0 @@
1
- /**
2
- * The collector URL is known at build time.
3
- */
4
- export interface CollectorSpecifierUrl {
5
- /** Type of collector specifier. */
6
- type: 'url';
7
- /** The URL under which the collector can be reached at runtime. */
8
- url: string;
9
- }
10
- /** Describes a one-time search and replace operation on a string. */
11
- export interface SearchReplace {
12
- /** Literal string to search for. */
13
- search: string;
14
- /** Literal replacement string. */
15
- replace: string;
16
- }
17
- /**
18
- * The collector can be reached by replacing a term in location.host and optionally changing the port.
19
- */
20
- export interface CollectorSpecifierRelative {
21
- /** Type of collector specifier. */
22
- type: 'relative';
23
- /** Literal replacement string. */
24
- hostReplace?: SearchReplace;
25
- /** Optional port. If no port is given, uses the protocol's default port. */
26
- port?: number | 'keep';
27
- /** Optional URL scheme to use. If no scheme is given, uses ws. */
28
- scheme?: string;
29
- /** Optional path. If no path is given, uses only the hostname. */
30
- path?: string;
31
- }
32
- /**
33
- * Specifies how the vaccine can reach the collector.
34
- */
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
- /** Details about the bucket the coverage is added to. */
48
- export type CoverageBucketSpecifier = {
49
- /** A unique identifier of the instrumented application. */
50
- 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
- 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
- configOptions?: string;
62
- /** The project commit or revision to contribute coverage for. */
63
- commit: string;
64
- };
65
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
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,CAAC;IACjB,kCAAkC;IAClC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,oBAAoB;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,yDAAyD;AACzD,MAAM,MAAM,uBAAuB,GAAG;IACrC,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAEf,CAAA"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });