slnodejs 6.1.257 → 6.1.259

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 (49) hide show
  1. package/browser-agent/dist/browser-agent-all.js +7 -2
  2. package/browser-agent/dist/browser-agent-all.min.js +23 -23
  3. package/browser-agent/package.json +1 -1
  4. package/package.json +3 -2
  5. package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js +6 -5
  6. package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js.map +1 -1
  7. package/tsOutputs/build-scanner/instrumentation/content-instrumenter.d.ts +9 -0
  8. package/tsOutputs/build-scanner/instrumentation/files-instrumenter.d.ts +40 -0
  9. package/tsOutputs/build-scanner/instrumentation/files-instrumenter.js +28 -24
  10. package/tsOutputs/build-scanner/instrumentation/files-instrumenter.js.map +1 -1
  11. package/tsOutputs/build-scanner/instrumentation/instrumentation-utils.js +0 -8
  12. package/tsOutputs/build-scanner/instrumentation/instrumentation-utils.js.map +1 -1
  13. package/tsOutputs/build-scanner/instrumentation/instrumented-file-size-reducer.js +2 -3
  14. package/tsOutputs/build-scanner/instrumentation/instrumented-file-size-reducer.js.map +1 -1
  15. package/tsOutputs/build-scanner/instrumentation/process-pool/contracts.d.ts +20 -0
  16. package/tsOutputs/build-scanner/instrumentation/process-pool/contracts.js +10 -0
  17. package/tsOutputs/build-scanner/instrumentation/process-pool/contracts.js.map +1 -0
  18. package/tsOutputs/build-scanner/instrumentation/process-pool/instrumenter-spawn.js +13 -2
  19. package/tsOutputs/build-scanner/instrumentation/process-pool/instrumenter-spawn.js.map +1 -1
  20. package/tsOutputs/build-scanner/instrumentation/process-pool/process-pool.js +150 -41
  21. package/tsOutputs/build-scanner/instrumentation/process-pool/process-pool.js.map +1 -1
  22. package/tsOutputs/build-scanner/instrumentation/process-pool/split-by-transform-stream.js +42 -0
  23. package/tsOutputs/build-scanner/instrumentation/process-pool/split-by-transform-stream.js.map +1 -0
  24. package/tsOutputs/build-scanner/instrumentation/strategies/copy-as-is-strategy.d.ts +7 -0
  25. package/tsOutputs/build-scanner/instrumentation/{stratagies/copy-as-is-stratagy.js → strategies/copy-as-is-strategy.js} +3 -3
  26. package/tsOutputs/build-scanner/instrumentation/strategies/copy-as-is-strategy.js.map +1 -0
  27. package/tsOutputs/build-scanner/instrumentation/strategies/instrumentation-strategy.interface.d.ts +3 -0
  28. package/tsOutputs/build-scanner/instrumentation/{stratagies/instrumentation-stratagy.interface.js → strategies/instrumentation-strategy.interface.js} +1 -1
  29. package/tsOutputs/build-scanner/instrumentation/strategies/instrumentation-strategy.interface.js.map +1 -0
  30. package/tsOutputs/build-scanner/instrumentation/strategies/js-instrumnetation-strategy.d.ts +22 -0
  31. package/tsOutputs/build-scanner/instrumentation/strategies/js-instrumnetation-strategy.js +88 -0
  32. package/tsOutputs/build-scanner/instrumentation/strategies/js-instrumnetation-strategy.js.map +1 -0
  33. package/tsOutputs/build-scanner/instrumentation/strategies/markup-instrumnetation-strategy.d.ts +8 -0
  34. package/tsOutputs/build-scanner/instrumentation/{stratagies/markup-instrumnetation-stratagy.js → strategies/markup-instrumnetation-strategy.js} +31 -51
  35. package/tsOutputs/build-scanner/instrumentation/strategies/markup-instrumnetation-strategy.js.map +1 -0
  36. package/tsOutputs/common/contracts.d.ts +2 -0
  37. package/tsOutputs/common/ignored-files-handler.d.ts +26 -0
  38. package/tsOutputs/common/logger.d.ts +9 -1
  39. package/tsOutputs/common/logger.js +41 -1
  40. package/tsOutputs/common/logger.js.map +1 -1
  41. package/tsOutputs/common/watchdog.d.ts +1 -0
  42. package/tsOutputs/common/watchdog.js.map +1 -1
  43. package/tsOutputs/test-listener/factory.js +2 -2
  44. package/tsOutputs/test-listener/factory.js.map +1 -1
  45. package/tsOutputs/build-scanner/instrumentation/stratagies/copy-as-is-stratagy.js.map +0 -1
  46. package/tsOutputs/build-scanner/instrumentation/stratagies/instrumentation-stratagy.interface.js.map +0 -1
  47. package/tsOutputs/build-scanner/instrumentation/stratagies/js-instrumnetation-stratagy.js +0 -44
  48. package/tsOutputs/build-scanner/instrumentation/stratagies/js-instrumnetation-stratagy.js.map +0 -1
  49. package/tsOutputs/build-scanner/instrumentation/stratagies/markup-instrumnetation-stratagy.js.map +0 -1
@@ -12,85 +12,194 @@ var __extends = (this && this.__extends) || (function () {
12
12
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
13
  };
14
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
+ };
15
51
  Object.defineProperty(exports, "__esModule", { value: true });
16
52
  exports.ProcessPool = void 0;
17
53
  var events_1 = require("events");
18
54
  var path = require("path");
19
55
  var child_process_1 = require("child_process");
20
- var kTaskInfo = Symbol('kTaskInfo');
56
+ var split_by_transform_stream_1 = require("./split-by-transform-stream");
57
+ var cockpit_notifier_1 = require("../../../common/agent-events/cockpit-notifier");
58
+ var contracts_1 = require("./contracts");
59
+ var kTaskInfo = Symbol('instrumentationTask');
21
60
  var kProcessFreedEvent = Symbol('kProcessFreedEvent');
61
+ var OUT_OF_MEMORY = 'Out of memory';
62
+ var OUT_OF_MEMORY_PATTERN = 'JavaScript heap out of memory';
63
+ var InstrumentationTask = /** @class */ (function () {
64
+ function InstrumentationTask(callback) {
65
+ this.callback = callback;
66
+ }
67
+ InstrumentationTask.prototype.done = function (result) {
68
+ this.callback(null, result);
69
+ };
70
+ InstrumentationTask.prototype.fail = function (error) {
71
+ this.callback(error, null);
72
+ };
73
+ return InstrumentationTask;
74
+ }());
22
75
  var ProcessPool = /** @class */ (function (_super) {
23
76
  __extends(ProcessPool, _super);
24
- function ProcessPool(numProcesses, processOptions) {
77
+ function ProcessPool(numProcesses, processOptions, logger) {
25
78
  var _this = _super.call(this) || this;
26
79
  _this.numProcesses = numProcesses;
80
+ _this.logger = logger;
27
81
  _this.processes = [];
28
82
  _this.freeProcesses = [];
29
83
  _this.processOptions = '';
30
84
  _this.processOptions = JSON.stringify(processOptions);
31
- for (var i = 0; i < _this.numProcesses; i++) {
32
- _this.addNewProcess();
33
- }
34
85
  return _this;
35
86
  }
87
+ ProcessPool.prototype.initSubprocesses = function () {
88
+ for (var i = 0; i < this.numProcesses; i++) {
89
+ this.addNewProcess();
90
+ }
91
+ };
36
92
  ProcessPool.prototype.addNewProcess = function () {
37
93
  var _this = this;
38
94
  var pathToInstrumenter = path.resolve(__dirname, 'instrumenter-spawn.js');
39
95
  var subprocess = child_process_1.fork(pathToInstrumenter, [this.processOptions], { silent: true });
40
- subprocess.on('message', function (result) {
96
+ this.logger.info("Subrocess with pid - " + subprocess.pid + " was started");
97
+ var subprocessPrefix = "Subprocess [" + subprocess.pid + "]: ";
98
+ subprocess.on('message', function (data) {
41
99
  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);
100
+ if (data.type === contracts_1.PROCESS_MESSAGE_TYPE.INSTRUMENTATION_RESULT) {
101
+ // In case of success: Call the callback that was passed to `runTask`,
102
+ // remove the `TaskInfo` associated with the Worker, and mark it as free
103
+ // again.
104
+ (_a = subprocess[kTaskInfo]) === null || _a === void 0 ? void 0 : _a.done(data.payload);
105
+ subprocess[kTaskInfo] = null;
106
+ _this.emitFreeProcess(subprocess);
107
+ return;
108
+ }
109
+ if (data.type === contracts_1.PROCESS_MESSAGE_TYPE.LOG) {
110
+ var logMessage = data.payload;
111
+ _this.logger.log(logMessage.level, logMessage.label + ' ' + logMessage.message);
112
+ return;
113
+ }
114
+ if (data.type === contracts_1.PROCESS_MESSAGE_TYPE.COCKPIT_NOTIFY) {
115
+ cockpit_notifier_1.CockpitNotifier.sendError(subprocessPrefix + data.payload.message);
116
+ return;
117
+ }
118
+ _this.logger.info(subprocessPrefix + " unprocessed message - " + JSON.stringify(data));
49
119
  });
50
- subprocess.stderr.on('data', function (data) {
120
+ subprocess.on('exit', function (_data) {
121
+ _this.logger.info("Subrocess with pid - " + subprocess.pid + " was closed");
122
+ _this.processes.splice(_this.processes.indexOf(subprocess), 1);
123
+ });
124
+ subprocess.on('error', function (err) {
51
125
  var _a;
52
- if (data.toString().indexOf('FATAL ERROR: Reached heap limit Allocation failed') > -1) {
126
+ if (err.message === OUT_OF_MEMORY) {
53
127
  if (subprocess[kTaskInfo]) {
54
- (_a = subprocess[kTaskInfo]) === null || _a === void 0 ? void 0 : _a.call(subprocess, new Error('out of memory'), null);
128
+ (_a = subprocess[kTaskInfo]) === null || _a === void 0 ? void 0 : _a.fail(err);
55
129
  subprocess[kTaskInfo] = null;
130
+ _this.processes.splice(_this.processes.indexOf(subprocess), 1);
131
+ _this.addNewProcess();
56
132
  }
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();
133
+ }
134
+ else {
135
+ _this.logger.error(subprocessPrefix + err.message);
136
+ }
137
+ });
138
+ var splitByLines = new split_by_transform_stream_1.SplitByTransformStream('\n');
139
+ subprocess.stderr.pipe(splitByLines).on('data', function (data) {
140
+ var errorText = data.toString();
141
+ if (errorText.indexOf(OUT_OF_MEMORY_PATTERN) > -1) {
142
+ _this.emit('error', new Error(OUT_OF_MEMORY));
143
+ }
144
+ else {
145
+ _this.logger.error(subprocessPrefix + errorText);
64
146
  }
65
147
  });
66
148
  this.processes.push(subprocess);
67
149
  this.freeProcesses.push(subprocess);
68
150
  this.emit(kProcessFreedEvent);
69
151
  };
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);
152
+ ProcessPool.prototype.runInstrumentationTask = function (task) {
153
+ return __awaiter(this, void 0, void 0, function () {
154
+ var _this = this;
155
+ return __generator(this, function (_a) {
156
+ switch (_a.label) {
157
+ case 0:
158
+ if (!(this.freeProcesses.length === 0)) return [3 /*break*/, 2];
159
+ // No free threads, wait until a worker thread becomes free.
160
+ return [4 /*yield*/, this.waitForFreeProcess()];
161
+ case 1:
162
+ // No free threads, wait until a worker thread becomes free.
163
+ _a.sent();
164
+ return [2 /*return*/, this.runInstrumentationTask(task)];
165
+ case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
166
+ var subprocess = _this.freeProcesses.pop();
167
+ subprocess[kTaskInfo] = new InstrumentationTask(function (error, result) {
168
+ if (error) {
169
+ return reject(error);
170
+ }
171
+ return resolve(result);
172
+ });
173
+ subprocess.send(task);
174
+ })];
84
175
  }
85
- return resolve(result);
86
- };
87
- subprocess.send(task);
176
+ });
177
+ });
178
+ };
179
+ ProcessPool.prototype.waitForFreeProcess = function () {
180
+ var _this = this;
181
+ return new Promise(function (resolve) {
182
+ _this.once(kProcessFreedEvent, function () { return resolve(); });
88
183
  });
89
184
  };
185
+ ProcessPool.prototype.emitFreeProcess = function (subprocess) {
186
+ this.freeProcesses.push(subprocess);
187
+ this.emit(kProcessFreedEvent);
188
+ };
90
189
  ProcessPool.prototype.close = function () {
91
190
  for (var _i = 0, _a = this.processes; _i < _a.length; _i++) {
92
191
  var subprocess = _a[_i];
93
- subprocess.kill();
192
+ try {
193
+ var killStatus = subprocess.kill();
194
+ if (!killStatus) {
195
+ this.logger.error("Subprocess " + subprocess.pid + " wasn't killed.");
196
+ subprocess.unref();
197
+ }
198
+ }
199
+ catch (error) {
200
+ this.logger.error("Subprocess " + subprocess.pid + " wasn't killed.", error);
201
+ subprocess.unref();
202
+ }
94
203
  }
95
204
  };
96
205
  return ProcessPool;
@@ -1 +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,kBAAY,GAAZ,YAAY,CAAQ;QAJhC,eAAS,GAAG,EAAE,CAAC;QACf,mBAAa,GAAG,EAAE,CAAC;QACnB,oBAAc,GAAG,EAAE,CAAC;QAKxB,KAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAI,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE;YACxC,KAAI,CAAC,aAAa,EAAE,CAAC;SACxB;;IACL,CAAC;IAEO,mCAAa,GAArB;QAAA,iBAiCC;QAhCG,IAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAA;QAC3E,IAAM,UAAU,GAAG,oBAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAErF,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,UAAC,MAAM;;YAC5B,sEAAsE;YACtE,wEAAwE;YACxE,SAAS;YACT,MAAA,UAAU,CAAC,SAAS,CAAC,+CAArB,UAAU,EAAc,IAAI,EAAE,MAAM,EA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AI,CAAC,IAAI,CAAC,kBAAkB,EAAE;oBAC1B,OAAO,CAAC,KAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;gBACH,OAAO;aACV;YAED,IAAM,UAAU,GAAG,KAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;YAC5C,UAAU,CAAC,SAAS,CAAC,GAAG,UAAC,KAAY,EAAE,MAAS;gBAC5C,IAAI,KAAK,EAAE;oBACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;iBACxB;gBACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC,CAAC;YACF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,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"}
1
+ {"version":3,"file":"process-pool.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/process-pool/process-pool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAsC;AACtC,2BAA6B;AAC7B,+CAAmD;AAInD,yEAAqE;AACrE,kFAAgF;AAChF,yCAA8G;AAE9G,IAAM,SAAS,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAChD,IAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACxD,IAAM,aAAa,GAAG,eAAe,CAAC;AACtC,IAAM,qBAAqB,GAAG,+BAA+B,CAAC;AAE9D;IACI,6BAAoB,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;I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IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAc,UAAU,CAAC,GAAG,oBAAiB,CAAC,CAAC;oBACjE,UAAU,CAAC,KAAK,EAAE,CAAC;iBACtB;aAEJ;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAc,UAAU,CAAC,GAAG,oBAAiB,EAAE,KAAK,CAAC,CAAC;gBACxE,UAAU,CAAC,KAAK,EAAE,CAAC;aACtB;SACJ;IACL,CAAC;IACL,kBAAC;AAAD,CAAC,AAtID,CAAiC,qBAAY,GAsI5C;AAtIY,kCAAW"}
@@ -0,0 +1,42 @@
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.SplitByTransformStream = void 0;
17
+ var stream_1 = require("stream");
18
+ var SplitByTransformStream = /** @class */ (function (_super) {
19
+ __extends(SplitByTransformStream, _super);
20
+ function SplitByTransformStream(splitter, streamOptions) {
21
+ var _this = _super.call(this, streamOptions) || this;
22
+ _this.buffer = '';
23
+ _this.splitter = '\n';
24
+ _this.splitter = splitter;
25
+ return _this;
26
+ }
27
+ SplitByTransformStream.prototype._transform = function (chunk, _encoding, callback) {
28
+ var _this = this;
29
+ this.buffer = this.buffer || '';
30
+ var text = this.buffer + chunk.toString();
31
+ var parts = text.split(this.splitter);
32
+ parts.slice(0, -1).forEach(function (x) { return _this.push(x); });
33
+ this.buffer = parts.slice(-1)[0];
34
+ callback(null);
35
+ };
36
+ SplitByTransformStream.prototype._flush = function (callback) {
37
+ callback(null, this.buffer);
38
+ };
39
+ return SplitByTransformStream;
40
+ }(stream_1.Transform));
41
+ exports.SplitByTransformStream = SplitByTransformStream;
42
+ //# sourceMappingURL=split-by-transform-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split-by-transform-stream.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/process-pool/split-by-transform-stream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAwE;AAExE;IAA4C,0CAAS;IAIjD,gCAAY,QAAyB,EAAE,aAAgC;QAAvE,YACI,kBAAM,aAAa,CAAC,SAEvB;QANO,YAAM,GAAG,EAAE,CAAC;QACZ,cAAQ,GAAoB,IAAI,CAAC;QAIrC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;;IAC7B,CAAC;IAED,2CAAU,GAAV,UAAW,KAAa,EAAE,SAAiB,EAAE,QAA2B;QAAxE,iBAQC;QAPG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC5C,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAExC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,KAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAZ,CAAY,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,uCAAM,GAAN,UAAO,QAA2B;QAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IACL,6BAAC;AAAD,CAAC,AAtBD,CAA4C,kBAAS,GAsBpD;AAtBY,wDAAsB"}
@@ -0,0 +1,7 @@
1
+ import { Logger } from '../../../common/contracts';
2
+ import { IInstrumentationStrategy } from './instrumentation-strategy.interface';
3
+ export declare class CopyAsIsStrategy implements IInstrumentationStrategy {
4
+ private logger;
5
+ constructor(logger: Logger);
6
+ process(inputFile: string, outputFile: string, fileKey: string): Promise<void>;
7
+ }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CopyAsIsStrategy = void 0;
4
- var fileAndFolderUtils = require("../../../build-scanner/file-and-folder-utils");
4
+ var fileAndFolderUtils = require("../../file-and-folder-utils");
5
5
  var CopyAsIsStrategy = /** @class */ (function () {
6
6
  function CopyAsIsStrategy(logger) {
7
7
  this.logger = logger;
8
8
  }
9
- CopyAsIsStrategy.prototype.instrumentFile = function (inputFile, outputFile, fileKey) {
9
+ CopyAsIsStrategy.prototype.process = function (inputFile, outputFile, fileKey) {
10
10
  var _this = this;
11
11
  return new Promise(function (resolve, reject) {
12
12
  fileAndFolderUtils.copyFileAsIs(inputFile, outputFile, fileKey, _this.logger, function (err) {
@@ -22,4 +22,4 @@ var CopyAsIsStrategy = /** @class */ (function () {
22
22
  return CopyAsIsStrategy;
23
23
  }());
24
24
  exports.CopyAsIsStrategy = CopyAsIsStrategy;
25
- //# sourceMappingURL=copy-as-is-stratagy.js.map
25
+ //# sourceMappingURL=copy-as-is-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-as-is-strategy.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/strategies/copy-as-is-strategy.ts"],"names":[],"mappings":";;;AAAA,gEAAkE;AAIlE;IAEI,0BAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAElC,CAAC;IAED,kCAAO,GAAP,UAAQ,SAAiB,EAAE,UAAkB,EAAE,OAAe;QAA9D,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"}
@@ -0,0 +1,3 @@
1
+ export interface IInstrumentationStrategy {
2
+ process(inputFile: string, outputFile: string, fileKey: string): Promise<void>;
3
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=instrumentation-stratagy.interface.js.map
3
+ //# sourceMappingURL=instrumentation-strategy.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation-strategy.interface.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/strategies/instrumentation-strategy.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { ICockpitNotifierPiggyback, Logger } from '../../../common/contracts';
2
+ import { IInstrumentationStrategy } from './instrumentation-strategy.interface';
3
+ import { ContentInstrumenter } from '../content-instrumenter';
4
+ export interface IInstrumentationStrategyParams {
5
+ shouldMinifyInstrumentedOutput: boolean;
6
+ shouldReduceInstrumentedFileSize: boolean;
7
+ useBranchCoverage: boolean;
8
+ babylonPlugins: boolean;
9
+ }
10
+ export declare class JsFileInstrumentationStrategy implements IInstrumentationStrategy {
11
+ protected config: IInstrumentationStrategyParams;
12
+ protected instrumenter: ContentInstrumenter;
13
+ protected preamble: string[];
14
+ protected logger: Logger;
15
+ protected cockpitNotifier: ICockpitNotifierPiggyback;
16
+ constructor(config: IInstrumentationStrategyParams, instrumenter: ContentInstrumenter, preamble: string[], logger: Logger, cockpitNotifier: ICockpitNotifierPiggyback);
17
+ process(inputFile: string, outputFile: string, fileKey: string): Promise<void>;
18
+ protected getContent(inputFile: string): string;
19
+ protected postInstrumentation(instrumentedContent: any, fileKey: any): string;
20
+ protected addPreamble(instrumentedContent: string): string;
21
+ private reduceFileSize;
22
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.JsFileInstrumentationStrategy = void 0;
40
+ var instrumented_file_size_reducer_1 = require("../instrumented-file-size-reducer");
41
+ var fs_1 = require("fs");
42
+ var validation_utils_1 = require("../../../common/utils/validation-utils");
43
+ var JsFileInstrumentationStrategy = /** @class */ (function () {
44
+ function JsFileInstrumentationStrategy(config, instrumenter, preamble, logger, cockpitNotifier) {
45
+ this.config = config;
46
+ this.instrumenter = instrumenter;
47
+ this.preamble = preamble;
48
+ this.logger = logger;
49
+ this.cockpitNotifier = cockpitNotifier;
50
+ validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(config, 'config');
51
+ validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(instrumenter, 'instrumenter');
52
+ validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(preamble, 'preamble');
53
+ validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(logger, 'logger');
54
+ validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(cockpitNotifier, 'cockpitNotifier');
55
+ }
56
+ JsFileInstrumentationStrategy.prototype.process = function (inputFile, outputFile, fileKey) {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ var content, instrumentedContent;
59
+ return __generator(this, function (_a) {
60
+ content = this.getContent(inputFile);
61
+ instrumentedContent = this.instrumenter.instrumentContent(content, fileKey);
62
+ instrumentedContent = this.postInstrumentation(instrumentedContent, fileKey);
63
+ fs_1.writeFileSync(outputFile, instrumentedContent, 'utf8');
64
+ return [2 /*return*/];
65
+ });
66
+ });
67
+ };
68
+ JsFileInstrumentationStrategy.prototype.getContent = function (inputFile) {
69
+ var contentBuffer = fs_1.readFileSync(inputFile);
70
+ return contentBuffer.toString();
71
+ };
72
+ JsFileInstrumentationStrategy.prototype.postInstrumentation = function (instrumentedContent, fileKey) {
73
+ if (this.config.shouldReduceInstrumentedFileSize) {
74
+ instrumentedContent = this.reduceFileSize(instrumentedContent, fileKey);
75
+ }
76
+ instrumentedContent = this.addPreamble(instrumentedContent);
77
+ return instrumentedContent;
78
+ };
79
+ JsFileInstrumentationStrategy.prototype.addPreamble = function (instrumentedContent) {
80
+ return this.preamble.concat([instrumentedContent]).join('\n');
81
+ };
82
+ JsFileInstrumentationStrategy.prototype.reduceFileSize = function (instrumentedCode, fileKey) {
83
+ return instrumented_file_size_reducer_1.reduceContentSize(fileKey, instrumentedCode, this.config.babylonPlugins, !this.config.useBranchCoverage, this.config.shouldMinifyInstrumentedOutput, this.logger, this.cockpitNotifier);
84
+ };
85
+ return JsFileInstrumentationStrategy;
86
+ }());
87
+ exports.JsFileInstrumentationStrategy = JsFileInstrumentationStrategy;
88
+ //# sourceMappingURL=js-instrumnetation-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js-instrumnetation-strategy.js","sourceRoot":"","sources":["../../../../build-scanner/instrumentation/strategies/js-instrumnetation-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,oFAAsE;AACtE,yBAAiD;AACjD,2EAAyE;AASzE;IAEI,uCACc,MAAsC,EACtC,YAAiC,EACjC,QAAkB,EAClB,MAAc,EACd,eAA0C;QAJ1C,WAAM,GAAN,MAAM,CAAgC;QACtC,iBAAY,GAAZ,YAAY,CAAqB;QACjC,aAAQ,GAAR,Q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W,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,EACX,IAAI,CAAC,eAAe,CACvB,CAAC;IACN,CAAC;IAEL,oCAAC;AAAD,CAAC,AAxDD,IAwDC;AAxDY,sEAA6B"}
@@ -0,0 +1,8 @@
1
+ import { JsFileInstrumentationStrategy } from './js-instrumnetation-strategy';
2
+ export declare class MarkupFileInstrumentationStrategy extends JsFileInstrumentationStrategy {
3
+ process(inputFile: string, outputFile: string, fileKey: string): Promise<void>;
4
+ private replaceOldJsByInstrumented;
5
+ private insertCoverageCodeTag;
6
+ protected addPreamble(instrumentedContent: string): string;
7
+ private insertTagAtBeginning;
8
+ }
@@ -49,44 +49,36 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  }
50
50
  };
51
51
  Object.defineProperty(exports, "__esModule", { value: true });
52
- exports.MarkupFileInstrumentationStratagy = void 0;
53
- var fs_1 = require("fs");
52
+ exports.MarkupFileInstrumentationStrategy = void 0;
53
+ var fs = require("fs");
54
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() {
55
+ var js_instrumnetation_strategy_1 = require("./js-instrumnetation-strategy");
56
+ var MarkupFileInstrumentationStrategy = /** @class */ (function (_super) {
57
+ __extends(MarkupFileInstrumentationStrategy, _super);
58
+ function MarkupFileInstrumentationStrategy() {
59
59
  return _super !== null && _super.apply(this, arguments) || this;
60
60
  }
61
- MarkupFileInstrumentationStratagy.prototype.instrumentFile = function (inputFile, outputFile, fileKey) {
61
+ MarkupFileInstrumentationStrategy.prototype.process = function (inputFile, outputFile, fileKey) {
62
62
  return __awaiter(this, void 0, void 0, function () {
63
63
  var singleMarkupFileInstrumenter, content, instrumentedJsContent, instrumentedContent;
64
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*/];
65
+ singleMarkupFileInstrumenter = new SingleMarkupFileInstrumenter(this.logger);
66
+ singleMarkupFileInstrumenter.extractScripts(inputFile);
67
+ if (!singleMarkupFileInstrumenter.hasJsInFile()) {
68
+ throw new Error('No script tags. Nothing to instrument');
85
69
  }
70
+ singleMarkupFileInstrumenter.markScripts();
71
+ content = singleMarkupFileInstrumenter.getAllJsInFile();
72
+ instrumentedJsContent = this.instrumenter.instrumentContent(content, fileKey);
73
+ instrumentedContent = this.replaceOldJsByInstrumented(singleMarkupFileInstrumenter.originalFileContent, singleMarkupFileInstrumenter.originalScriptTags, instrumentedJsContent);
74
+ instrumentedContent = this.insertCoverageCodeTag(instrumentedContent, instrumentedJsContent);
75
+ instrumentedContent = this.postInstrumentation(instrumentedContent, fileKey);
76
+ fs.writeFileSync(outputFile, instrumentedContent, 'utf8');
77
+ return [2 /*return*/];
86
78
  });
87
79
  });
88
80
  };
89
- MarkupFileInstrumentationStratagy.prototype.replaceOldJsByInstrumented = function (originalFileContent, originalScriptTags, instrumentedContent) {
81
+ MarkupFileInstrumentationStrategy.prototype.replaceOldJsByInstrumented = function (originalFileContent, originalScriptTags, instrumentedContent) {
90
82
  var instrumentedFileContent = originalFileContent;
91
83
  for (var i = 0; i < originalScriptTags.length; i++) {
92
84
  var currentTag = originalScriptTags[i];
@@ -99,47 +91,35 @@ var MarkupFileInstrumentationStratagy = /** @class */ (function (_super) {
99
91
  }
100
92
  return instrumentedFileContent;
101
93
  };
102
- MarkupFileInstrumentationStratagy.prototype.insertCoverageCodeTag = function (fileContent, instrumentedJsContent) {
94
+ MarkupFileInstrumentationStrategy.prototype.insertCoverageCodeTag = function (fileContent, instrumentedJsContent) {
103
95
  var firstTagMarker = createScriptMarker(0);
104
96
  var firstTagStart = instrumentedJsContent.indexOf(firstTagMarker);
105
97
  var istanbulCoverageCode = instrumentedJsContent.substring(0, firstTagStart);
106
98
  var coverageCodeTag = "<script>\n\t" + istanbulCoverageCode + "\n</script>\n";
107
99
  return this.insertTagAtBeginning(coverageCodeTag, fileContent);
108
100
  };
109
- MarkupFileInstrumentationStratagy.prototype.addPreamble = function (instrumentedContent) {
101
+ MarkupFileInstrumentationStrategy.prototype.addPreamble = function (instrumentedContent) {
110
102
  var preambleTag = "<script>\n\t" + this.preamble.join('\n') + "\n</script>\n";
111
103
  return this.insertTagAtBeginning(preambleTag, instrumentedContent);
112
104
  };
113
- MarkupFileInstrumentationStratagy.prototype.insertTagAtBeginning = function (newTag, instrumentedContent) {
105
+ MarkupFileInstrumentationStrategy.prototype.insertTagAtBeginning = function (newTag, instrumentedContent) {
114
106
  var firstScriptTagIndex = instrumentedContent.search(/<script[\s\S]*?>/);
115
107
  return instrumentedContent.slice(0, firstScriptTagIndex) + newTag +
116
108
  instrumentedContent.slice(firstScriptTagIndex);
117
109
  };
118
- return MarkupFileInstrumentationStratagy;
119
- }(js_instrumnetation_stratagy_1.JsFileInstrumentationStratagy));
120
- exports.MarkupFileInstrumentationStratagy = MarkupFileInstrumentationStratagy;
110
+ return MarkupFileInstrumentationStrategy;
111
+ }(js_instrumnetation_strategy_1.JsFileInstrumentationStrategy));
112
+ exports.MarkupFileInstrumentationStrategy = MarkupFileInstrumentationStrategy;
121
113
  var SingleMarkupFileInstrumenter = /** @class */ (function () {
122
114
  function SingleMarkupFileInstrumenter(logger) {
123
115
  this.logger = logger;
124
116
  this.originalScriptTags = [];
125
117
  }
126
118
  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
- });
119
+ this.originalFileContent = fs.readFileSync(inputFile, 'utf8');
120
+ this.fileParser = new MarkupFileParser(this.originalFileContent, inputFile, this.logger);
121
+ this.fileParser.extractScriptTags();
122
+ this.originalScriptTags = cloneTagsArray(this.fileParser.scriptTags);
143
123
  };
144
124
  SingleMarkupFileInstrumenter.prototype.hasJsInFile = function () {
145
125
  return this.fileParser.scriptTags.length !== 0 && isJSEmbeddedInFile(this.fileParser);
@@ -167,4 +147,4 @@ function createScriptMarker(index) {
167
147
  function cloneTagsArray(tagsArray) {
168
148
  return JSON.parse(JSON.stringify(tagsArray));
169
149
  }
170
- //# sourceMappingURL=markup-instrumnetation-stratagy.js.map
150
+ //# sourceMappingURL=markup-instrumnetation-strategy.js.map