slnodejs 6.1.256 → 6.1.257
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/browser-agent/dist/browser-agent-all.js +1 -1
- package/browser-agent/dist/browser-agent-all.min.js +1 -1
- package/browser-agent/package.json +1 -1
- package/package.json +1 -1
- package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js +94 -81
- package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js.map +1 -1
- package/tsOutputs/build-scanner/instrumentation/content-instrumenter.js +27 -0
- package/tsOutputs/build-scanner/instrumentation/content-instrumenter.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/files-instrumenter.js +161 -0
- package/tsOutputs/build-scanner/instrumentation/files-instrumenter.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/instrumentation-utils.js +12 -3
- package/tsOutputs/build-scanner/instrumentation/instrumentation-utils.js.map +1 -1
- package/tsOutputs/build-scanner/instrumentation/process-pool/instrumenter-spawn.js +56 -0
- package/tsOutputs/build-scanner/instrumentation/process-pool/instrumenter-spawn.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/process-pool/process-pool.js +99 -0
- package/tsOutputs/build-scanner/instrumentation/process-pool/process-pool.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/copy-as-is-stratagy.js +25 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/copy-as-is-stratagy.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/instrumentation-stratagy.interface.js +3 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/instrumentation-stratagy.interface.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/js-instrumnetation-stratagy.js +44 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/js-instrumnetation-stratagy.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/markup-instrumnetation-stratagy.js +170 -0
- package/tsOutputs/build-scanner/instrumentation/stratagies/markup-instrumnetation-stratagy.js.map +1 -0
- package/tsOutputs/build-scanner/instrumentation/file-instrumenter.js +0 -343
- package/tsOutputs/build-scanner/instrumentation/file-instrumenter.js.map +0 -1
- package/tsOutputs/build-scanner/instrumentation/markup-file-instrumenter.js +0 -186
- package/tsOutputs/build-scanner/instrumentation/markup-file-instrumenter.js.map +0 -1
- package/tsOutputs/build-scanner/instrumentation/sync-instrumenter.js +0 -47
- package/tsOutputs/build-scanner/instrumentation/sync-instrumenter.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ProcessPool = void 0;
|
|
17
|
+
var events_1 = require("events");
|
|
18
|
+
var path = require("path");
|
|
19
|
+
var child_process_1 = require("child_process");
|
|
20
|
+
var kTaskInfo = Symbol('kTaskInfo');
|
|
21
|
+
var kProcessFreedEvent = Symbol('kProcessFreedEvent');
|
|
22
|
+
var ProcessPool = /** @class */ (function (_super) {
|
|
23
|
+
__extends(ProcessPool, _super);
|
|
24
|
+
function ProcessPool(numProcesses, processOptions) {
|
|
25
|
+
var _this = _super.call(this) || this;
|
|
26
|
+
_this.numProcesses = numProcesses;
|
|
27
|
+
_this.processes = [];
|
|
28
|
+
_this.freeProcesses = [];
|
|
29
|
+
_this.processOptions = '';
|
|
30
|
+
_this.processOptions = JSON.stringify(processOptions);
|
|
31
|
+
for (var i = 0; i < _this.numProcesses; i++) {
|
|
32
|
+
_this.addNewProcess();
|
|
33
|
+
}
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
ProcessPool.prototype.addNewProcess = function () {
|
|
37
|
+
var _this = this;
|
|
38
|
+
var pathToInstrumenter = path.resolve(__dirname, 'instrumenter-spawn.js');
|
|
39
|
+
var subprocess = child_process_1.fork(pathToInstrumenter, [this.processOptions], { silent: true });
|
|
40
|
+
subprocess.on('message', function (result) {
|
|
41
|
+
var _a;
|
|
42
|
+
// In case of success: Call the callback that was passed to `runTask`,
|
|
43
|
+
// remove the `TaskInfo` associated with the Worker, and mark it as free
|
|
44
|
+
// again.
|
|
45
|
+
(_a = subprocess[kTaskInfo]) === null || _a === void 0 ? void 0 : _a.call(subprocess, null, result);
|
|
46
|
+
subprocess[kTaskInfo] = null;
|
|
47
|
+
_this.freeProcesses.push(subprocess);
|
|
48
|
+
_this.emit(kProcessFreedEvent);
|
|
49
|
+
});
|
|
50
|
+
subprocess.stderr.on('data', function (data) {
|
|
51
|
+
var _a;
|
|
52
|
+
if (data.toString().indexOf('FATAL ERROR: Reached heap limit Allocation failed') > -1) {
|
|
53
|
+
if (subprocess[kTaskInfo]) {
|
|
54
|
+
(_a = subprocess[kTaskInfo]) === null || _a === void 0 ? void 0 : _a.call(subprocess, new Error('out of memory'), null);
|
|
55
|
+
subprocess[kTaskInfo] = null;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
_this.emit('error', new Error('out of memory'));
|
|
59
|
+
}
|
|
60
|
+
// Remove the worker from the list and start a new Worker to replace the
|
|
61
|
+
// current one.
|
|
62
|
+
_this.processes.splice(_this.processes.indexOf(subprocess), 1);
|
|
63
|
+
_this.addNewProcess();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.processes.push(subprocess);
|
|
67
|
+
this.freeProcesses.push(subprocess);
|
|
68
|
+
this.emit(kProcessFreedEvent);
|
|
69
|
+
};
|
|
70
|
+
ProcessPool.prototype.runTask = function (task) {
|
|
71
|
+
var _this = this;
|
|
72
|
+
return new Promise(function (resolve, reject) {
|
|
73
|
+
if (_this.freeProcesses.length === 0) {
|
|
74
|
+
// No free threads, wait until a worker thread becomes free.
|
|
75
|
+
_this.once(kProcessFreedEvent, function () {
|
|
76
|
+
resolve(_this.runTask(task));
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var subprocess = _this.freeProcesses.pop();
|
|
81
|
+
subprocess[kTaskInfo] = function (error, result) {
|
|
82
|
+
if (error) {
|
|
83
|
+
return reject(error);
|
|
84
|
+
}
|
|
85
|
+
return resolve(result);
|
|
86
|
+
};
|
|
87
|
+
subprocess.send(task);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
ProcessPool.prototype.close = function () {
|
|
91
|
+
for (var _i = 0, _a = this.processes; _i < _a.length; _i++) {
|
|
92
|
+
var subprocess = _a[_i];
|
|
93
|
+
subprocess.kill();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return ProcessPool;
|
|
97
|
+
}(events_1.EventEmitter));
|
|
98
|
+
exports.ProcessPool = ProcessPool;
|
|
99
|
+
//# sourceMappingURL=process-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-pool.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/process-pool/process-pool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAsC;AACtC,2BAA6B;AAC7B,+CAAqC;AAErC,IAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AACtC,IAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAExD;IAAiC,+BAAY;IAMzC,qBAAoB,YAAoB,EAAE,cAAuC;QAAjF,YACI,iBAAO,SAOV;QARmB,kBAA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AAC,CAAA;IACN,CAAC;IAED,2BAAK,GAAL;QACI,KAAyB,UAAc,EAAd,KAAA,IAAI,CAAC,SAAS,EAAd,cAAc,EAAd,IAAc;YAAlC,IAAM,UAAU,SAAA;YAAoB,UAAU,CAAC,IAAI,EAAE,CAAC;SAAA;IAC/D,CAAC;IACL,kBAAC;AAAD,CAAC,AA5ED,CAAiC,qBAAY,GA4E5C;AA5EY,kCAAW"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CopyAsIsStrategy = void 0;
|
|
4
|
+
var fileAndFolderUtils = require("../../../build-scanner/file-and-folder-utils");
|
|
5
|
+
var CopyAsIsStrategy = /** @class */ (function () {
|
|
6
|
+
function CopyAsIsStrategy(logger) {
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
}
|
|
9
|
+
CopyAsIsStrategy.prototype.instrumentFile = function (inputFile, outputFile, fileKey) {
|
|
10
|
+
var _this = this;
|
|
11
|
+
return new Promise(function (resolve, reject) {
|
|
12
|
+
fileAndFolderUtils.copyFileAsIs(inputFile, outputFile, fileKey, _this.logger, function (err) {
|
|
13
|
+
if (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
resolve();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return CopyAsIsStrategy;
|
|
23
|
+
}());
|
|
24
|
+
exports.CopyAsIsStrategy = CopyAsIsStrategy;
|
|
25
|
+
//# sourceMappingURL=copy-as-is-stratagy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-as-is-stratagy.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/stratagies/copy-as-is-stratagy.ts"],"names":[],"mappings":";;;AAAA,iFAAmF;AAInF;IAEI,0BAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAElC,CAAC;IAED,yCAAc,GAAd,UAAe,SAAiB,EAAE,UAAkB,EAAE,OAAe;QAArE,iBAUC;QATG,OAAO,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;YACrC,kBAAkB,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,KAAI,CAAC,MAAM,EAAE,UAAC,GAAG;gBAC7E,IAAI,GAAG,EAAE;oBACL,MAAM,CAAC,GAAG,CAAC,CAAC;iBACf;qBAAM;oBACH,OAAO,EAAE,CAAC;iBACb;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAA;IACN,CAAC;IACL,uBAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,4CAAgB"}
|
package/tsOutputs/build-scanner/instrumentation/stratagies/instrumentation-stratagy.interface.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation-stratagy.interface.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/stratagies/instrumentation-stratagy.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsFileInstrumentationStratagy = void 0;
|
|
4
|
+
var instrumented_file_size_reducer_1 = require("../instrumented-file-size-reducer");
|
|
5
|
+
var fs_1 = require("fs");
|
|
6
|
+
var validation_utils_1 = require("../../../common/utils/validation-utils");
|
|
7
|
+
var JsFileInstrumentationStratagy = /** @class */ (function () {
|
|
8
|
+
function JsFileInstrumentationStratagy(config, instrumenter, preamble, logger) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.instrumenter = instrumenter;
|
|
11
|
+
this.preamble = preamble;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(config, 'config');
|
|
14
|
+
validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(instrumenter, 'instrumenter');
|
|
15
|
+
validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(preamble, 'preamble');
|
|
16
|
+
validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(logger, 'logger');
|
|
17
|
+
}
|
|
18
|
+
JsFileInstrumentationStratagy.prototype.instrumentFile = function (inputFile, outputFile, fileKey) {
|
|
19
|
+
var content = this.getContent(inputFile);
|
|
20
|
+
var instrumentedContent = this.instrumenter.instrumentContent(content, fileKey);
|
|
21
|
+
instrumentedContent = this.postInstrumentation(instrumentedContent, fileKey);
|
|
22
|
+
fs_1.writeFileSync(outputFile, instrumentedContent, 'utf8');
|
|
23
|
+
};
|
|
24
|
+
JsFileInstrumentationStratagy.prototype.getContent = function (inputFile) {
|
|
25
|
+
var contentBuffer = fs_1.readFileSync(inputFile);
|
|
26
|
+
return contentBuffer.toString();
|
|
27
|
+
};
|
|
28
|
+
JsFileInstrumentationStratagy.prototype.postInstrumentation = function (instrumentedContent, fileKey) {
|
|
29
|
+
if (this.config.shouldReduceInstrumentedFileSize) {
|
|
30
|
+
instrumentedContent = this.reduceFileSize(instrumentedContent, fileKey);
|
|
31
|
+
}
|
|
32
|
+
instrumentedContent = this.addPreamble(instrumentedContent);
|
|
33
|
+
return instrumentedContent;
|
|
34
|
+
};
|
|
35
|
+
JsFileInstrumentationStratagy.prototype.addPreamble = function (instrumentedContent) {
|
|
36
|
+
return this.preamble.concat([instrumentedContent]).join('\n');
|
|
37
|
+
};
|
|
38
|
+
JsFileInstrumentationStratagy.prototype.reduceFileSize = function (instrumentedCode, fileKey) {
|
|
39
|
+
return instrumented_file_size_reducer_1.reduceContentSize(fileKey, instrumentedCode, this.config.babylonPlugins, !this.config.useBranchCoverage, this.config.shouldMinifyInstrumentedOutput, this.logger);
|
|
40
|
+
};
|
|
41
|
+
return JsFileInstrumentationStratagy;
|
|
42
|
+
}());
|
|
43
|
+
exports.JsFileInstrumentationStratagy = JsFileInstrumentationStratagy;
|
|
44
|
+
//# sourceMappingURL=js-instrumnetation-stratagy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-instrumnetation-stratagy.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/stratagies/js-instrumnetation-stratagy.ts"],"names":[],"mappings":";;;AAGA,oFAAsE;AACtE,yBAAiD;AACjD,2EAAyE;AASzE;IAEI,uCACc,MAAsC,EACtC,YAAiC,EACjC,QAAkB,EAClB,MAAc;QAHd,WAAM,GAAN,MAAM,CAAgC;QACtC,iBAAY,GAAZ,YAAY,CAAqB;QACjC,aAAQ,GAAR,QAAQ,CAAU;QAClB,WAAM,GAAN,MAAM,CAAQ;QAExB,kCAAe,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvD,kCAAe,CAAC,oBAAoB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACnE,kCAAe,CAAC,oBAAoB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC3D,kCAAe,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED,sDAAc,GAAd,UAAe,SAAiB,EAAE,UAAkB,EAAE,OAAe;QACjE,IAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3C,IAAI,mBAAmB,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAEhF,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAE5E,kBAAa,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAES,kDAAU,GAApB,UAAqB,SAAiB;QAClC,IAAM,aAAa,GAAG,iBAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAES,2DAAmB,GAA7B,UAA8B,mBAAmB,EAAE,OAAO;QACtD,IAAI,IAAI,CAAC,MAAM,CAAC,gCAAgC,EAAE;YAC9C,mBAAmB,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;SAC3E;QAED,mBAAmB,GAAG,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QAC5D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAES,mDAAW,GAArB,UAAsB,mBAA2B;QAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAEO,sDAAc,GAAtB,UAAuB,gBAAwB,EAAE,OAAe;QAC5D,OAAO,kDAAiB,CACpB,OAAO,EACP,gBAAgB,EAChB,IAAI,CAAC,MAAM,CAAC,cAAc,EAC1B,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC9B,IAAI,CAAC,MAAM,CAAC,8BAA8B,EAC1C,IAAI,CAAC,MAAM,CACd,CAAC;IACN,CAAC;IAEL,oCAAC;AAAD,CAAC,AArDD,IAqDC;AArDY,sEAA6B"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
+
function step(op) {
|
|
29
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
+
while (_) try {
|
|
31
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
+
switch (op[0]) {
|
|
34
|
+
case 0: case 1: t = op; break;
|
|
35
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
+
default:
|
|
39
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
+
if (t[2]) _.ops.pop();
|
|
44
|
+
_.trys.pop(); continue;
|
|
45
|
+
}
|
|
46
|
+
op = body.call(thisArg, _);
|
|
47
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.MarkupFileInstrumentationStratagy = void 0;
|
|
53
|
+
var fs_1 = require("fs");
|
|
54
|
+
var MarkupFileParser = require("../../markup-files-parser");
|
|
55
|
+
var js_instrumnetation_stratagy_1 = require("./js-instrumnetation-stratagy");
|
|
56
|
+
var MarkupFileInstrumentationStratagy = /** @class */ (function (_super) {
|
|
57
|
+
__extends(MarkupFileInstrumentationStratagy, _super);
|
|
58
|
+
function MarkupFileInstrumentationStratagy() {
|
|
59
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
60
|
+
}
|
|
61
|
+
MarkupFileInstrumentationStratagy.prototype.instrumentFile = function (inputFile, outputFile, fileKey) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var singleMarkupFileInstrumenter, content, instrumentedJsContent, instrumentedContent;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
singleMarkupFileInstrumenter = new SingleMarkupFileInstrumenter(this.logger);
|
|
68
|
+
return [4 /*yield*/, singleMarkupFileInstrumenter.extractScripts(inputFile)];
|
|
69
|
+
case 1:
|
|
70
|
+
_a.sent();
|
|
71
|
+
if (!singleMarkupFileInstrumenter.hasJsInFile()) {
|
|
72
|
+
// TODO: return CustomError or object
|
|
73
|
+
throw new Error('No script tags. Nothing to instrument');
|
|
74
|
+
}
|
|
75
|
+
singleMarkupFileInstrumenter.markScripts();
|
|
76
|
+
content = singleMarkupFileInstrumenter.getAllJsInFile();
|
|
77
|
+
instrumentedJsContent = this.instrumenter.instrumentContent(content, fileKey);
|
|
78
|
+
instrumentedContent = this.replaceOldJsByInstrumented(singleMarkupFileInstrumenter.originalFileContent, singleMarkupFileInstrumenter.originalScriptTags, instrumentedJsContent);
|
|
79
|
+
instrumentedContent = this.insertCoverageCodeTag(instrumentedContent, instrumentedJsContent);
|
|
80
|
+
instrumentedContent = this.postInstrumentation(instrumentedContent, fileKey);
|
|
81
|
+
return [4 /*yield*/, fs_1.promises.writeFile(outputFile, instrumentedContent, 'utf8')];
|
|
82
|
+
case 2:
|
|
83
|
+
_a.sent();
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
MarkupFileInstrumentationStratagy.prototype.replaceOldJsByInstrumented = function (originalFileContent, originalScriptTags, instrumentedContent) {
|
|
90
|
+
var instrumentedFileContent = originalFileContent;
|
|
91
|
+
for (var i = 0; i < originalScriptTags.length; i++) {
|
|
92
|
+
var currentTag = originalScriptTags[i];
|
|
93
|
+
var scriptMarker = createScriptMarker(i);
|
|
94
|
+
var scriptStartIndex = instrumentedContent.indexOf(scriptMarker);
|
|
95
|
+
scriptStartIndex += scriptMarker.length;
|
|
96
|
+
var scriptEndIndex = instrumentedContent.lastIndexOf(scriptMarker);
|
|
97
|
+
var instrumentedScript = instrumentedContent.substring(scriptStartIndex, scriptEndIndex);
|
|
98
|
+
instrumentedFileContent = instrumentedFileContent.replace(currentTag.content, instrumentedScript);
|
|
99
|
+
}
|
|
100
|
+
return instrumentedFileContent;
|
|
101
|
+
};
|
|
102
|
+
MarkupFileInstrumentationStratagy.prototype.insertCoverageCodeTag = function (fileContent, instrumentedJsContent) {
|
|
103
|
+
var firstTagMarker = createScriptMarker(0);
|
|
104
|
+
var firstTagStart = instrumentedJsContent.indexOf(firstTagMarker);
|
|
105
|
+
var istanbulCoverageCode = instrumentedJsContent.substring(0, firstTagStart);
|
|
106
|
+
var coverageCodeTag = "<script>\n\t" + istanbulCoverageCode + "\n</script>\n";
|
|
107
|
+
return this.insertTagAtBeginning(coverageCodeTag, fileContent);
|
|
108
|
+
};
|
|
109
|
+
MarkupFileInstrumentationStratagy.prototype.addPreamble = function (instrumentedContent) {
|
|
110
|
+
var preambleTag = "<script>\n\t" + this.preamble.join('\n') + "\n</script>\n";
|
|
111
|
+
return this.insertTagAtBeginning(preambleTag, instrumentedContent);
|
|
112
|
+
};
|
|
113
|
+
MarkupFileInstrumentationStratagy.prototype.insertTagAtBeginning = function (newTag, instrumentedContent) {
|
|
114
|
+
var firstScriptTagIndex = instrumentedContent.search(/<script[\s\S]*?>/);
|
|
115
|
+
return instrumentedContent.slice(0, firstScriptTagIndex) + newTag +
|
|
116
|
+
instrumentedContent.slice(firstScriptTagIndex);
|
|
117
|
+
};
|
|
118
|
+
return MarkupFileInstrumentationStratagy;
|
|
119
|
+
}(js_instrumnetation_stratagy_1.JsFileInstrumentationStratagy));
|
|
120
|
+
exports.MarkupFileInstrumentationStratagy = MarkupFileInstrumentationStratagy;
|
|
121
|
+
var SingleMarkupFileInstrumenter = /** @class */ (function () {
|
|
122
|
+
function SingleMarkupFileInstrumenter(logger) {
|
|
123
|
+
this.logger = logger;
|
|
124
|
+
this.originalScriptTags = [];
|
|
125
|
+
}
|
|
126
|
+
SingleMarkupFileInstrumenter.prototype.extractScripts = function (inputFile) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var _a;
|
|
129
|
+
return __generator(this, function (_b) {
|
|
130
|
+
switch (_b.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
_a = this;
|
|
133
|
+
return [4 /*yield*/, fs_1.promises.readFile(inputFile, 'utf8')];
|
|
134
|
+
case 1:
|
|
135
|
+
_a.originalFileContent = _b.sent();
|
|
136
|
+
this.fileParser = new MarkupFileParser(this.originalFileContent, inputFile, this.logger);
|
|
137
|
+
this.fileParser.extractScriptTags();
|
|
138
|
+
this.originalScriptTags = cloneTagsArray(this.fileParser.scriptTags);
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
SingleMarkupFileInstrumenter.prototype.hasJsInFile = function () {
|
|
145
|
+
return this.fileParser.scriptTags.length !== 0 && isJSEmbeddedInFile(this.fileParser);
|
|
146
|
+
};
|
|
147
|
+
SingleMarkupFileInstrumenter.prototype.markScripts = function () {
|
|
148
|
+
this.fileParser.scriptTags = this.fileParser.scriptTags.map(function (scriptTag, index) {
|
|
149
|
+
var slComment = createScriptMarker(index);
|
|
150
|
+
scriptTag.content = slComment + scriptTag.content + slComment;
|
|
151
|
+
return scriptTag;
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
SingleMarkupFileInstrumenter.prototype.getAllJsInFile = function () {
|
|
155
|
+
return this.fileParser.getAllJsInFile();
|
|
156
|
+
};
|
|
157
|
+
return SingleMarkupFileInstrumenter;
|
|
158
|
+
}());
|
|
159
|
+
// Checks if the js code is inside file or loaded from external js file (ie <script src="..."></script>).
|
|
160
|
+
function isJSEmbeddedInFile(fileParser) {
|
|
161
|
+
return fileParser.getAllJsInFile() !== '';
|
|
162
|
+
}
|
|
163
|
+
function createScriptMarker(index) {
|
|
164
|
+
return "/********** SL tag no " + index + " **********/";
|
|
165
|
+
}
|
|
166
|
+
// Because we add mark comments to tag scripts we want to save the original without any changes so we implement deep copy.
|
|
167
|
+
function cloneTagsArray(tagsArray) {
|
|
168
|
+
return JSON.parse(JSON.stringify(tagsArray));
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=markup-instrumnetation-stratagy.js.map
|
package/tsOutputs/build-scanner/instrumentation/stratagies/markup-instrumnetation-stratagy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup-instrumnetation-stratagy.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/stratagies/markup-instrumnetation-stratagy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAoC;AAGpC,4DAA+D;AAC/D,6EAA8E;AAE9E;IAAuD,qDAA6B;IAApF;;IAsDA,CAAC;IApDS,0DAAc,GAApB,UAAqB,SAAiB,EAAE,UAAkB,EAAE,OAAe;;;;;;wBACjE,4BAA4B,GAAG,IAAI,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBAEnF,qBAAM,4BAA4B,CAAC,cAAc,CAAC,SAAS,CAAC,EAAA;;wBAA5D,SAA4D,CAAC;wBAC7D,IAAI,CAAC,4BAA4B,CAAC,WAAW,EAAE,EAAE;4BAC7C,qCAAqC;4BACrC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;yBAC5D;wBACD,4BAA4B,CAAC,WAAW,EAAE,CAAC;wBACrC,OAAO,GAAG,4BAA4B,CAAC,cAAc,EAAE,CAAC;wBAExD,qBAAqB,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAEhF,mBAAmB,GAAG,IAAI,CAAC,0BAA0B,CAAC,4BAA4B,CAAC,mBAAmB,EAAE,4BAA4B,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;wBACpL,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;wBAC7F,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;wBAE7E,qBAAM,aAAE,CAAC,SAAS,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;;;;;KAC/D;IAEO,sEAA0B,GAAlC,UA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