@nsshunt/stsrunnerframework 0.0.7 → 0.0.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.
@@ -1,3 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
+ var __privateWrapper = (obj, member, setter, getter) => ({
13
+ set _(value) {
14
+ __privateSet(obj, member, value, setter);
15
+ },
16
+ get _() {
17
+ return __privateGet(obj, member, getter);
18
+ }
19
+ });
20
+ var _collectorCollectorPort, _runners, _options, _debug, _SetMessagePort, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _StartRunner, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _runner, _workerId, _options2, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _WorkerCommand, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
21
+ import { Sleep, ModelDelimeter } from "@nsshunt/stsutils";
22
+ import { Gauge } from "@nsshunt/stsobservability";
1
23
  const URI_BASE_VUEUTILS = "/";
2
24
  var eIWMessageCommands = /* @__PURE__ */ ((eIWMessageCommands2) => {
3
25
  eIWMessageCommands2["InstrumentTelemetry"] = "__STS__InstrumentTelemetry";
@@ -38,11 +60,2233 @@ const PublishMessageCommandsTestRunner = {
38
60
  ExecuteRefreshToken: "__ExecuteRefreshToken",
39
61
  ExecuteRefreshTokenResponse: "__ExecuteRefreshTokenResponse"
40
62
  };
63
+ const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
64
+ function getDefaultExportFromCjs(x) {
65
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
66
+ }
67
+ var ansiStyles$1 = { exports: {} };
68
+ var colorName;
69
+ var hasRequiredColorName;
70
+ function requireColorName() {
71
+ if (hasRequiredColorName) return colorName;
72
+ hasRequiredColorName = 1;
73
+ colorName = {
74
+ "aliceblue": [240, 248, 255],
75
+ "antiquewhite": [250, 235, 215],
76
+ "aqua": [0, 255, 255],
77
+ "aquamarine": [127, 255, 212],
78
+ "azure": [240, 255, 255],
79
+ "beige": [245, 245, 220],
80
+ "bisque": [255, 228, 196],
81
+ "black": [0, 0, 0],
82
+ "blanchedalmond": [255, 235, 205],
83
+ "blue": [0, 0, 255],
84
+ "blueviolet": [138, 43, 226],
85
+ "brown": [165, 42, 42],
86
+ "burlywood": [222, 184, 135],
87
+ "cadetblue": [95, 158, 160],
88
+ "chartreuse": [127, 255, 0],
89
+ "chocolate": [210, 105, 30],
90
+ "coral": [255, 127, 80],
91
+ "cornflowerblue": [100, 149, 237],
92
+ "cornsilk": [255, 248, 220],
93
+ "crimson": [220, 20, 60],
94
+ "cyan": [0, 255, 255],
95
+ "darkblue": [0, 0, 139],
96
+ "darkcyan": [0, 139, 139],
97
+ "darkgoldenrod": [184, 134, 11],
98
+ "darkgray": [169, 169, 169],
99
+ "darkgreen": [0, 100, 0],
100
+ "darkgrey": [169, 169, 169],
101
+ "darkkhaki": [189, 183, 107],
102
+ "darkmagenta": [139, 0, 139],
103
+ "darkolivegreen": [85, 107, 47],
104
+ "darkorange": [255, 140, 0],
105
+ "darkorchid": [153, 50, 204],
106
+ "darkred": [139, 0, 0],
107
+ "darksalmon": [233, 150, 122],
108
+ "darkseagreen": [143, 188, 143],
109
+ "darkslateblue": [72, 61, 139],
110
+ "darkslategray": [47, 79, 79],
111
+ "darkslategrey": [47, 79, 79],
112
+ "darkturquoise": [0, 206, 209],
113
+ "darkviolet": [148, 0, 211],
114
+ "deeppink": [255, 20, 147],
115
+ "deepskyblue": [0, 191, 255],
116
+ "dimgray": [105, 105, 105],
117
+ "dimgrey": [105, 105, 105],
118
+ "dodgerblue": [30, 144, 255],
119
+ "firebrick": [178, 34, 34],
120
+ "floralwhite": [255, 250, 240],
121
+ "forestgreen": [34, 139, 34],
122
+ "fuchsia": [255, 0, 255],
123
+ "gainsboro": [220, 220, 220],
124
+ "ghostwhite": [248, 248, 255],
125
+ "gold": [255, 215, 0],
126
+ "goldenrod": [218, 165, 32],
127
+ "gray": [128, 128, 128],
128
+ "green": [0, 128, 0],
129
+ "greenyellow": [173, 255, 47],
130
+ "grey": [128, 128, 128],
131
+ "honeydew": [240, 255, 240],
132
+ "hotpink": [255, 105, 180],
133
+ "indianred": [205, 92, 92],
134
+ "indigo": [75, 0, 130],
135
+ "ivory": [255, 255, 240],
136
+ "khaki": [240, 230, 140],
137
+ "lavender": [230, 230, 250],
138
+ "lavenderblush": [255, 240, 245],
139
+ "lawngreen": [124, 252, 0],
140
+ "lemonchiffon": [255, 250, 205],
141
+ "lightblue": [173, 216, 230],
142
+ "lightcoral": [240, 128, 128],
143
+ "lightcyan": [224, 255, 255],
144
+ "lightgoldenrodyellow": [250, 250, 210],
145
+ "lightgray": [211, 211, 211],
146
+ "lightgreen": [144, 238, 144],
147
+ "lightgrey": [211, 211, 211],
148
+ "lightpink": [255, 182, 193],
149
+ "lightsalmon": [255, 160, 122],
150
+ "lightseagreen": [32, 178, 170],
151
+ "lightskyblue": [135, 206, 250],
152
+ "lightslategray": [119, 136, 153],
153
+ "lightslategrey": [119, 136, 153],
154
+ "lightsteelblue": [176, 196, 222],
155
+ "lightyellow": [255, 255, 224],
156
+ "lime": [0, 255, 0],
157
+ "limegreen": [50, 205, 50],
158
+ "linen": [250, 240, 230],
159
+ "magenta": [255, 0, 255],
160
+ "maroon": [128, 0, 0],
161
+ "mediumaquamarine": [102, 205, 170],
162
+ "mediumblue": [0, 0, 205],
163
+ "mediumorchid": [186, 85, 211],
164
+ "mediumpurple": [147, 112, 219],
165
+ "mediumseagreen": [60, 179, 113],
166
+ "mediumslateblue": [123, 104, 238],
167
+ "mediumspringgreen": [0, 250, 154],
168
+ "mediumturquoise": [72, 209, 204],
169
+ "mediumvioletred": [199, 21, 133],
170
+ "midnightblue": [25, 25, 112],
171
+ "mintcream": [245, 255, 250],
172
+ "mistyrose": [255, 228, 225],
173
+ "moccasin": [255, 228, 181],
174
+ "navajowhite": [255, 222, 173],
175
+ "navy": [0, 0, 128],
176
+ "oldlace": [253, 245, 230],
177
+ "olive": [128, 128, 0],
178
+ "olivedrab": [107, 142, 35],
179
+ "orange": [255, 165, 0],
180
+ "orangered": [255, 69, 0],
181
+ "orchid": [218, 112, 214],
182
+ "palegoldenrod": [238, 232, 170],
183
+ "palegreen": [152, 251, 152],
184
+ "paleturquoise": [175, 238, 238],
185
+ "palevioletred": [219, 112, 147],
186
+ "papayawhip": [255, 239, 213],
187
+ "peachpuff": [255, 218, 185],
188
+ "peru": [205, 133, 63],
189
+ "pink": [255, 192, 203],
190
+ "plum": [221, 160, 221],
191
+ "powderblue": [176, 224, 230],
192
+ "purple": [128, 0, 128],
193
+ "rebeccapurple": [102, 51, 153],
194
+ "red": [255, 0, 0],
195
+ "rosybrown": [188, 143, 143],
196
+ "royalblue": [65, 105, 225],
197
+ "saddlebrown": [139, 69, 19],
198
+ "salmon": [250, 128, 114],
199
+ "sandybrown": [244, 164, 96],
200
+ "seagreen": [46, 139, 87],
201
+ "seashell": [255, 245, 238],
202
+ "sienna": [160, 82, 45],
203
+ "silver": [192, 192, 192],
204
+ "skyblue": [135, 206, 235],
205
+ "slateblue": [106, 90, 205],
206
+ "slategray": [112, 128, 144],
207
+ "slategrey": [112, 128, 144],
208
+ "snow": [255, 250, 250],
209
+ "springgreen": [0, 255, 127],
210
+ "steelblue": [70, 130, 180],
211
+ "tan": [210, 180, 140],
212
+ "teal": [0, 128, 128],
213
+ "thistle": [216, 191, 216],
214
+ "tomato": [255, 99, 71],
215
+ "turquoise": [64, 224, 208],
216
+ "violet": [238, 130, 238],
217
+ "wheat": [245, 222, 179],
218
+ "white": [255, 255, 255],
219
+ "whitesmoke": [245, 245, 245],
220
+ "yellow": [255, 255, 0],
221
+ "yellowgreen": [154, 205, 50]
222
+ };
223
+ return colorName;
224
+ }
225
+ var conversions;
226
+ var hasRequiredConversions;
227
+ function requireConversions() {
228
+ if (hasRequiredConversions) return conversions;
229
+ hasRequiredConversions = 1;
230
+ const cssKeywords = requireColorName();
231
+ const reverseKeywords = {};
232
+ for (const key of Object.keys(cssKeywords)) {
233
+ reverseKeywords[cssKeywords[key]] = key;
234
+ }
235
+ const convert = {
236
+ rgb: { channels: 3, labels: "rgb" },
237
+ hsl: { channels: 3, labels: "hsl" },
238
+ hsv: { channels: 3, labels: "hsv" },
239
+ hwb: { channels: 3, labels: "hwb" },
240
+ cmyk: { channels: 4, labels: "cmyk" },
241
+ xyz: { channels: 3, labels: "xyz" },
242
+ lab: { channels: 3, labels: "lab" },
243
+ lch: { channels: 3, labels: "lch" },
244
+ hex: { channels: 1, labels: ["hex"] },
245
+ keyword: { channels: 1, labels: ["keyword"] },
246
+ ansi16: { channels: 1, labels: ["ansi16"] },
247
+ ansi256: { channels: 1, labels: ["ansi256"] },
248
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
249
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
250
+ gray: { channels: 1, labels: ["gray"] }
251
+ };
252
+ conversions = convert;
253
+ for (const model of Object.keys(convert)) {
254
+ if (!("channels" in convert[model])) {
255
+ throw new Error("missing channels property: " + model);
256
+ }
257
+ if (!("labels" in convert[model])) {
258
+ throw new Error("missing channel labels property: " + model);
259
+ }
260
+ if (convert[model].labels.length !== convert[model].channels) {
261
+ throw new Error("channel and label counts mismatch: " + model);
262
+ }
263
+ const { channels, labels } = convert[model];
264
+ delete convert[model].channels;
265
+ delete convert[model].labels;
266
+ Object.defineProperty(convert[model], "channels", { value: channels });
267
+ Object.defineProperty(convert[model], "labels", { value: labels });
268
+ }
269
+ convert.rgb.hsl = function(rgb) {
270
+ const r = rgb[0] / 255;
271
+ const g = rgb[1] / 255;
272
+ const b = rgb[2] / 255;
273
+ const min = Math.min(r, g, b);
274
+ const max = Math.max(r, g, b);
275
+ const delta = max - min;
276
+ let h;
277
+ let s;
278
+ if (max === min) {
279
+ h = 0;
280
+ } else if (r === max) {
281
+ h = (g - b) / delta;
282
+ } else if (g === max) {
283
+ h = 2 + (b - r) / delta;
284
+ } else if (b === max) {
285
+ h = 4 + (r - g) / delta;
286
+ }
287
+ h = Math.min(h * 60, 360);
288
+ if (h < 0) {
289
+ h += 360;
290
+ }
291
+ const l = (min + max) / 2;
292
+ if (max === min) {
293
+ s = 0;
294
+ } else if (l <= 0.5) {
295
+ s = delta / (max + min);
296
+ } else {
297
+ s = delta / (2 - max - min);
298
+ }
299
+ return [h, s * 100, l * 100];
300
+ };
301
+ convert.rgb.hsv = function(rgb) {
302
+ let rdif;
303
+ let gdif;
304
+ let bdif;
305
+ let h;
306
+ let s;
307
+ const r = rgb[0] / 255;
308
+ const g = rgb[1] / 255;
309
+ const b = rgb[2] / 255;
310
+ const v = Math.max(r, g, b);
311
+ const diff = v - Math.min(r, g, b);
312
+ const diffc = function(c) {
313
+ return (v - c) / 6 / diff + 1 / 2;
314
+ };
315
+ if (diff === 0) {
316
+ h = 0;
317
+ s = 0;
318
+ } else {
319
+ s = diff / v;
320
+ rdif = diffc(r);
321
+ gdif = diffc(g);
322
+ bdif = diffc(b);
323
+ if (r === v) {
324
+ h = bdif - gdif;
325
+ } else if (g === v) {
326
+ h = 1 / 3 + rdif - bdif;
327
+ } else if (b === v) {
328
+ h = 2 / 3 + gdif - rdif;
329
+ }
330
+ if (h < 0) {
331
+ h += 1;
332
+ } else if (h > 1) {
333
+ h -= 1;
334
+ }
335
+ }
336
+ return [
337
+ h * 360,
338
+ s * 100,
339
+ v * 100
340
+ ];
341
+ };
342
+ convert.rgb.hwb = function(rgb) {
343
+ const r = rgb[0];
344
+ const g = rgb[1];
345
+ let b = rgb[2];
346
+ const h = convert.rgb.hsl(rgb)[0];
347
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
348
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
349
+ return [h, w * 100, b * 100];
350
+ };
351
+ convert.rgb.cmyk = function(rgb) {
352
+ const r = rgb[0] / 255;
353
+ const g = rgb[1] / 255;
354
+ const b = rgb[2] / 255;
355
+ const k = Math.min(1 - r, 1 - g, 1 - b);
356
+ const c = (1 - r - k) / (1 - k) || 0;
357
+ const m = (1 - g - k) / (1 - k) || 0;
358
+ const y = (1 - b - k) / (1 - k) || 0;
359
+ return [c * 100, m * 100, y * 100, k * 100];
360
+ };
361
+ function comparativeDistance(x, y) {
362
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
363
+ }
364
+ convert.rgb.keyword = function(rgb) {
365
+ const reversed = reverseKeywords[rgb];
366
+ if (reversed) {
367
+ return reversed;
368
+ }
369
+ let currentClosestDistance = Infinity;
370
+ let currentClosestKeyword;
371
+ for (const keyword of Object.keys(cssKeywords)) {
372
+ const value = cssKeywords[keyword];
373
+ const distance = comparativeDistance(rgb, value);
374
+ if (distance < currentClosestDistance) {
375
+ currentClosestDistance = distance;
376
+ currentClosestKeyword = keyword;
377
+ }
378
+ }
379
+ return currentClosestKeyword;
380
+ };
381
+ convert.keyword.rgb = function(keyword) {
382
+ return cssKeywords[keyword];
383
+ };
384
+ convert.rgb.xyz = function(rgb) {
385
+ let r = rgb[0] / 255;
386
+ let g = rgb[1] / 255;
387
+ let b = rgb[2] / 255;
388
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
389
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
390
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
391
+ const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
392
+ const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
393
+ const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
394
+ return [x * 100, y * 100, z * 100];
395
+ };
396
+ convert.rgb.lab = function(rgb) {
397
+ const xyz = convert.rgb.xyz(rgb);
398
+ let x = xyz[0];
399
+ let y = xyz[1];
400
+ let z = xyz[2];
401
+ x /= 95.047;
402
+ y /= 100;
403
+ z /= 108.883;
404
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
405
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
406
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
407
+ const l = 116 * y - 16;
408
+ const a = 500 * (x - y);
409
+ const b = 200 * (y - z);
410
+ return [l, a, b];
411
+ };
412
+ convert.hsl.rgb = function(hsl) {
413
+ const h = hsl[0] / 360;
414
+ const s = hsl[1] / 100;
415
+ const l = hsl[2] / 100;
416
+ let t2;
417
+ let t3;
418
+ let val;
419
+ if (s === 0) {
420
+ val = l * 255;
421
+ return [val, val, val];
422
+ }
423
+ if (l < 0.5) {
424
+ t2 = l * (1 + s);
425
+ } else {
426
+ t2 = l + s - l * s;
427
+ }
428
+ const t1 = 2 * l - t2;
429
+ const rgb = [0, 0, 0];
430
+ for (let i = 0; i < 3; i++) {
431
+ t3 = h + 1 / 3 * -(i - 1);
432
+ if (t3 < 0) {
433
+ t3++;
434
+ }
435
+ if (t3 > 1) {
436
+ t3--;
437
+ }
438
+ if (6 * t3 < 1) {
439
+ val = t1 + (t2 - t1) * 6 * t3;
440
+ } else if (2 * t3 < 1) {
441
+ val = t2;
442
+ } else if (3 * t3 < 2) {
443
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
444
+ } else {
445
+ val = t1;
446
+ }
447
+ rgb[i] = val * 255;
448
+ }
449
+ return rgb;
450
+ };
451
+ convert.hsl.hsv = function(hsl) {
452
+ const h = hsl[0];
453
+ let s = hsl[1] / 100;
454
+ let l = hsl[2] / 100;
455
+ let smin = s;
456
+ const lmin = Math.max(l, 0.01);
457
+ l *= 2;
458
+ s *= l <= 1 ? l : 2 - l;
459
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
460
+ const v = (l + s) / 2;
461
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
462
+ return [h, sv * 100, v * 100];
463
+ };
464
+ convert.hsv.rgb = function(hsv) {
465
+ const h = hsv[0] / 60;
466
+ const s = hsv[1] / 100;
467
+ let v = hsv[2] / 100;
468
+ const hi = Math.floor(h) % 6;
469
+ const f = h - Math.floor(h);
470
+ const p = 255 * v * (1 - s);
471
+ const q = 255 * v * (1 - s * f);
472
+ const t = 255 * v * (1 - s * (1 - f));
473
+ v *= 255;
474
+ switch (hi) {
475
+ case 0:
476
+ return [v, t, p];
477
+ case 1:
478
+ return [q, v, p];
479
+ case 2:
480
+ return [p, v, t];
481
+ case 3:
482
+ return [p, q, v];
483
+ case 4:
484
+ return [t, p, v];
485
+ case 5:
486
+ return [v, p, q];
487
+ }
488
+ };
489
+ convert.hsv.hsl = function(hsv) {
490
+ const h = hsv[0];
491
+ const s = hsv[1] / 100;
492
+ const v = hsv[2] / 100;
493
+ const vmin = Math.max(v, 0.01);
494
+ let sl;
495
+ let l;
496
+ l = (2 - s) * v;
497
+ const lmin = (2 - s) * vmin;
498
+ sl = s * vmin;
499
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
500
+ sl = sl || 0;
501
+ l /= 2;
502
+ return [h, sl * 100, l * 100];
503
+ };
504
+ convert.hwb.rgb = function(hwb) {
505
+ const h = hwb[0] / 360;
506
+ let wh = hwb[1] / 100;
507
+ let bl = hwb[2] / 100;
508
+ const ratio = wh + bl;
509
+ let f;
510
+ if (ratio > 1) {
511
+ wh /= ratio;
512
+ bl /= ratio;
513
+ }
514
+ const i = Math.floor(6 * h);
515
+ const v = 1 - bl;
516
+ f = 6 * h - i;
517
+ if ((i & 1) !== 0) {
518
+ f = 1 - f;
519
+ }
520
+ const n = wh + f * (v - wh);
521
+ let r;
522
+ let g;
523
+ let b;
524
+ switch (i) {
525
+ default:
526
+ case 6:
527
+ case 0:
528
+ r = v;
529
+ g = n;
530
+ b = wh;
531
+ break;
532
+ case 1:
533
+ r = n;
534
+ g = v;
535
+ b = wh;
536
+ break;
537
+ case 2:
538
+ r = wh;
539
+ g = v;
540
+ b = n;
541
+ break;
542
+ case 3:
543
+ r = wh;
544
+ g = n;
545
+ b = v;
546
+ break;
547
+ case 4:
548
+ r = n;
549
+ g = wh;
550
+ b = v;
551
+ break;
552
+ case 5:
553
+ r = v;
554
+ g = wh;
555
+ b = n;
556
+ break;
557
+ }
558
+ return [r * 255, g * 255, b * 255];
559
+ };
560
+ convert.cmyk.rgb = function(cmyk) {
561
+ const c = cmyk[0] / 100;
562
+ const m = cmyk[1] / 100;
563
+ const y = cmyk[2] / 100;
564
+ const k = cmyk[3] / 100;
565
+ const r = 1 - Math.min(1, c * (1 - k) + k);
566
+ const g = 1 - Math.min(1, m * (1 - k) + k);
567
+ const b = 1 - Math.min(1, y * (1 - k) + k);
568
+ return [r * 255, g * 255, b * 255];
569
+ };
570
+ convert.xyz.rgb = function(xyz) {
571
+ const x = xyz[0] / 100;
572
+ const y = xyz[1] / 100;
573
+ const z = xyz[2] / 100;
574
+ let r;
575
+ let g;
576
+ let b;
577
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
578
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
579
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
580
+ r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
581
+ g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
582
+ b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
583
+ r = Math.min(Math.max(0, r), 1);
584
+ g = Math.min(Math.max(0, g), 1);
585
+ b = Math.min(Math.max(0, b), 1);
586
+ return [r * 255, g * 255, b * 255];
587
+ };
588
+ convert.xyz.lab = function(xyz) {
589
+ let x = xyz[0];
590
+ let y = xyz[1];
591
+ let z = xyz[2];
592
+ x /= 95.047;
593
+ y /= 100;
594
+ z /= 108.883;
595
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
596
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
597
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
598
+ const l = 116 * y - 16;
599
+ const a = 500 * (x - y);
600
+ const b = 200 * (y - z);
601
+ return [l, a, b];
602
+ };
603
+ convert.lab.xyz = function(lab) {
604
+ const l = lab[0];
605
+ const a = lab[1];
606
+ const b = lab[2];
607
+ let x;
608
+ let y;
609
+ let z;
610
+ y = (l + 16) / 116;
611
+ x = a / 500 + y;
612
+ z = y - b / 200;
613
+ const y2 = y ** 3;
614
+ const x2 = x ** 3;
615
+ const z2 = z ** 3;
616
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
617
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
618
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
619
+ x *= 95.047;
620
+ y *= 100;
621
+ z *= 108.883;
622
+ return [x, y, z];
623
+ };
624
+ convert.lab.lch = function(lab) {
625
+ const l = lab[0];
626
+ const a = lab[1];
627
+ const b = lab[2];
628
+ let h;
629
+ const hr = Math.atan2(b, a);
630
+ h = hr * 360 / 2 / Math.PI;
631
+ if (h < 0) {
632
+ h += 360;
633
+ }
634
+ const c = Math.sqrt(a * a + b * b);
635
+ return [l, c, h];
636
+ };
637
+ convert.lch.lab = function(lch) {
638
+ const l = lch[0];
639
+ const c = lch[1];
640
+ const h = lch[2];
641
+ const hr = h / 360 * 2 * Math.PI;
642
+ const a = c * Math.cos(hr);
643
+ const b = c * Math.sin(hr);
644
+ return [l, a, b];
645
+ };
646
+ convert.rgb.ansi16 = function(args, saturation = null) {
647
+ const [r, g, b] = args;
648
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
649
+ value = Math.round(value / 50);
650
+ if (value === 0) {
651
+ return 30;
652
+ }
653
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
654
+ if (value === 2) {
655
+ ansi += 60;
656
+ }
657
+ return ansi;
658
+ };
659
+ convert.hsv.ansi16 = function(args) {
660
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
661
+ };
662
+ convert.rgb.ansi256 = function(args) {
663
+ const r = args[0];
664
+ const g = args[1];
665
+ const b = args[2];
666
+ if (r === g && g === b) {
667
+ if (r < 8) {
668
+ return 16;
669
+ }
670
+ if (r > 248) {
671
+ return 231;
672
+ }
673
+ return Math.round((r - 8) / 247 * 24) + 232;
674
+ }
675
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
676
+ return ansi;
677
+ };
678
+ convert.ansi16.rgb = function(args) {
679
+ let color = args % 10;
680
+ if (color === 0 || color === 7) {
681
+ if (args > 50) {
682
+ color += 3.5;
683
+ }
684
+ color = color / 10.5 * 255;
685
+ return [color, color, color];
686
+ }
687
+ const mult = (~~(args > 50) + 1) * 0.5;
688
+ const r = (color & 1) * mult * 255;
689
+ const g = (color >> 1 & 1) * mult * 255;
690
+ const b = (color >> 2 & 1) * mult * 255;
691
+ return [r, g, b];
692
+ };
693
+ convert.ansi256.rgb = function(args) {
694
+ if (args >= 232) {
695
+ const c = (args - 232) * 10 + 8;
696
+ return [c, c, c];
697
+ }
698
+ args -= 16;
699
+ let rem;
700
+ const r = Math.floor(args / 36) / 5 * 255;
701
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
702
+ const b = rem % 6 / 5 * 255;
703
+ return [r, g, b];
704
+ };
705
+ convert.rgb.hex = function(args) {
706
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
707
+ const string = integer.toString(16).toUpperCase();
708
+ return "000000".substring(string.length) + string;
709
+ };
710
+ convert.hex.rgb = function(args) {
711
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
712
+ if (!match) {
713
+ return [0, 0, 0];
714
+ }
715
+ let colorString = match[0];
716
+ if (match[0].length === 3) {
717
+ colorString = colorString.split("").map((char) => {
718
+ return char + char;
719
+ }).join("");
720
+ }
721
+ const integer = parseInt(colorString, 16);
722
+ const r = integer >> 16 & 255;
723
+ const g = integer >> 8 & 255;
724
+ const b = integer & 255;
725
+ return [r, g, b];
726
+ };
727
+ convert.rgb.hcg = function(rgb) {
728
+ const r = rgb[0] / 255;
729
+ const g = rgb[1] / 255;
730
+ const b = rgb[2] / 255;
731
+ const max = Math.max(Math.max(r, g), b);
732
+ const min = Math.min(Math.min(r, g), b);
733
+ const chroma = max - min;
734
+ let grayscale;
735
+ let hue;
736
+ if (chroma < 1) {
737
+ grayscale = min / (1 - chroma);
738
+ } else {
739
+ grayscale = 0;
740
+ }
741
+ if (chroma <= 0) {
742
+ hue = 0;
743
+ } else if (max === r) {
744
+ hue = (g - b) / chroma % 6;
745
+ } else if (max === g) {
746
+ hue = 2 + (b - r) / chroma;
747
+ } else {
748
+ hue = 4 + (r - g) / chroma;
749
+ }
750
+ hue /= 6;
751
+ hue %= 1;
752
+ return [hue * 360, chroma * 100, grayscale * 100];
753
+ };
754
+ convert.hsl.hcg = function(hsl) {
755
+ const s = hsl[1] / 100;
756
+ const l = hsl[2] / 100;
757
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
758
+ let f = 0;
759
+ if (c < 1) {
760
+ f = (l - 0.5 * c) / (1 - c);
761
+ }
762
+ return [hsl[0], c * 100, f * 100];
763
+ };
764
+ convert.hsv.hcg = function(hsv) {
765
+ const s = hsv[1] / 100;
766
+ const v = hsv[2] / 100;
767
+ const c = s * v;
768
+ let f = 0;
769
+ if (c < 1) {
770
+ f = (v - c) / (1 - c);
771
+ }
772
+ return [hsv[0], c * 100, f * 100];
773
+ };
774
+ convert.hcg.rgb = function(hcg) {
775
+ const h = hcg[0] / 360;
776
+ const c = hcg[1] / 100;
777
+ const g = hcg[2] / 100;
778
+ if (c === 0) {
779
+ return [g * 255, g * 255, g * 255];
780
+ }
781
+ const pure = [0, 0, 0];
782
+ const hi = h % 1 * 6;
783
+ const v = hi % 1;
784
+ const w = 1 - v;
785
+ let mg = 0;
786
+ switch (Math.floor(hi)) {
787
+ case 0:
788
+ pure[0] = 1;
789
+ pure[1] = v;
790
+ pure[2] = 0;
791
+ break;
792
+ case 1:
793
+ pure[0] = w;
794
+ pure[1] = 1;
795
+ pure[2] = 0;
796
+ break;
797
+ case 2:
798
+ pure[0] = 0;
799
+ pure[1] = 1;
800
+ pure[2] = v;
801
+ break;
802
+ case 3:
803
+ pure[0] = 0;
804
+ pure[1] = w;
805
+ pure[2] = 1;
806
+ break;
807
+ case 4:
808
+ pure[0] = v;
809
+ pure[1] = 0;
810
+ pure[2] = 1;
811
+ break;
812
+ default:
813
+ pure[0] = 1;
814
+ pure[1] = 0;
815
+ pure[2] = w;
816
+ }
817
+ mg = (1 - c) * g;
818
+ return [
819
+ (c * pure[0] + mg) * 255,
820
+ (c * pure[1] + mg) * 255,
821
+ (c * pure[2] + mg) * 255
822
+ ];
823
+ };
824
+ convert.hcg.hsv = function(hcg) {
825
+ const c = hcg[1] / 100;
826
+ const g = hcg[2] / 100;
827
+ const v = c + g * (1 - c);
828
+ let f = 0;
829
+ if (v > 0) {
830
+ f = c / v;
831
+ }
832
+ return [hcg[0], f * 100, v * 100];
833
+ };
834
+ convert.hcg.hsl = function(hcg) {
835
+ const c = hcg[1] / 100;
836
+ const g = hcg[2] / 100;
837
+ const l = g * (1 - c) + 0.5 * c;
838
+ let s = 0;
839
+ if (l > 0 && l < 0.5) {
840
+ s = c / (2 * l);
841
+ } else if (l >= 0.5 && l < 1) {
842
+ s = c / (2 * (1 - l));
843
+ }
844
+ return [hcg[0], s * 100, l * 100];
845
+ };
846
+ convert.hcg.hwb = function(hcg) {
847
+ const c = hcg[1] / 100;
848
+ const g = hcg[2] / 100;
849
+ const v = c + g * (1 - c);
850
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
851
+ };
852
+ convert.hwb.hcg = function(hwb) {
853
+ const w = hwb[1] / 100;
854
+ const b = hwb[2] / 100;
855
+ const v = 1 - b;
856
+ const c = v - w;
857
+ let g = 0;
858
+ if (c < 1) {
859
+ g = (v - c) / (1 - c);
860
+ }
861
+ return [hwb[0], c * 100, g * 100];
862
+ };
863
+ convert.apple.rgb = function(apple) {
864
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
865
+ };
866
+ convert.rgb.apple = function(rgb) {
867
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
868
+ };
869
+ convert.gray.rgb = function(args) {
870
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
871
+ };
872
+ convert.gray.hsl = function(args) {
873
+ return [0, 0, args[0]];
874
+ };
875
+ convert.gray.hsv = convert.gray.hsl;
876
+ convert.gray.hwb = function(gray) {
877
+ return [0, 100, gray[0]];
878
+ };
879
+ convert.gray.cmyk = function(gray) {
880
+ return [0, 0, 0, gray[0]];
881
+ };
882
+ convert.gray.lab = function(gray) {
883
+ return [gray[0], 0, 0];
884
+ };
885
+ convert.gray.hex = function(gray) {
886
+ const val = Math.round(gray[0] / 100 * 255) & 255;
887
+ const integer = (val << 16) + (val << 8) + val;
888
+ const string = integer.toString(16).toUpperCase();
889
+ return "000000".substring(string.length) + string;
890
+ };
891
+ convert.rgb.gray = function(rgb) {
892
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
893
+ return [val / 255 * 100];
894
+ };
895
+ return conversions;
896
+ }
897
+ var route;
898
+ var hasRequiredRoute;
899
+ function requireRoute() {
900
+ if (hasRequiredRoute) return route;
901
+ hasRequiredRoute = 1;
902
+ const conversions2 = requireConversions();
903
+ function buildGraph() {
904
+ const graph = {};
905
+ const models = Object.keys(conversions2);
906
+ for (let len = models.length, i = 0; i < len; i++) {
907
+ graph[models[i]] = {
908
+ // http://jsperf.com/1-vs-infinity
909
+ // micro-opt, but this is simple.
910
+ distance: -1,
911
+ parent: null
912
+ };
913
+ }
914
+ return graph;
915
+ }
916
+ function deriveBFS(fromModel) {
917
+ const graph = buildGraph();
918
+ const queue = [fromModel];
919
+ graph[fromModel].distance = 0;
920
+ while (queue.length) {
921
+ const current = queue.pop();
922
+ const adjacents = Object.keys(conversions2[current]);
923
+ for (let len = adjacents.length, i = 0; i < len; i++) {
924
+ const adjacent = adjacents[i];
925
+ const node = graph[adjacent];
926
+ if (node.distance === -1) {
927
+ node.distance = graph[current].distance + 1;
928
+ node.parent = current;
929
+ queue.unshift(adjacent);
930
+ }
931
+ }
932
+ }
933
+ return graph;
934
+ }
935
+ function link(from, to) {
936
+ return function(args) {
937
+ return to(from(args));
938
+ };
939
+ }
940
+ function wrapConversion(toModel, graph) {
941
+ const path = [graph[toModel].parent, toModel];
942
+ let fn = conversions2[graph[toModel].parent][toModel];
943
+ let cur = graph[toModel].parent;
944
+ while (graph[cur].parent) {
945
+ path.unshift(graph[cur].parent);
946
+ fn = link(conversions2[graph[cur].parent][cur], fn);
947
+ cur = graph[cur].parent;
948
+ }
949
+ fn.conversion = path;
950
+ return fn;
951
+ }
952
+ route = function(fromModel) {
953
+ const graph = deriveBFS(fromModel);
954
+ const conversion = {};
955
+ const models = Object.keys(graph);
956
+ for (let len = models.length, i = 0; i < len; i++) {
957
+ const toModel = models[i];
958
+ const node = graph[toModel];
959
+ if (node.parent === null) {
960
+ continue;
961
+ }
962
+ conversion[toModel] = wrapConversion(toModel, graph);
963
+ }
964
+ return conversion;
965
+ };
966
+ return route;
967
+ }
968
+ var colorConvert;
969
+ var hasRequiredColorConvert;
970
+ function requireColorConvert() {
971
+ if (hasRequiredColorConvert) return colorConvert;
972
+ hasRequiredColorConvert = 1;
973
+ const conversions2 = requireConversions();
974
+ const route2 = requireRoute();
975
+ const convert = {};
976
+ const models = Object.keys(conversions2);
977
+ function wrapRaw(fn) {
978
+ const wrappedFn = function(...args) {
979
+ const arg0 = args[0];
980
+ if (arg0 === void 0 || arg0 === null) {
981
+ return arg0;
982
+ }
983
+ if (arg0.length > 1) {
984
+ args = arg0;
985
+ }
986
+ return fn(args);
987
+ };
988
+ if ("conversion" in fn) {
989
+ wrappedFn.conversion = fn.conversion;
990
+ }
991
+ return wrappedFn;
992
+ }
993
+ function wrapRounded(fn) {
994
+ const wrappedFn = function(...args) {
995
+ const arg0 = args[0];
996
+ if (arg0 === void 0 || arg0 === null) {
997
+ return arg0;
998
+ }
999
+ if (arg0.length > 1) {
1000
+ args = arg0;
1001
+ }
1002
+ const result = fn(args);
1003
+ if (typeof result === "object") {
1004
+ for (let len = result.length, i = 0; i < len; i++) {
1005
+ result[i] = Math.round(result[i]);
1006
+ }
1007
+ }
1008
+ return result;
1009
+ };
1010
+ if ("conversion" in fn) {
1011
+ wrappedFn.conversion = fn.conversion;
1012
+ }
1013
+ return wrappedFn;
1014
+ }
1015
+ models.forEach((fromModel) => {
1016
+ convert[fromModel] = {};
1017
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
1018
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
1019
+ const routes = route2(fromModel);
1020
+ const routeModels = Object.keys(routes);
1021
+ routeModels.forEach((toModel) => {
1022
+ const fn = routes[toModel];
1023
+ convert[fromModel][toModel] = wrapRounded(fn);
1024
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1025
+ });
1026
+ });
1027
+ colorConvert = convert;
1028
+ return colorConvert;
1029
+ }
1030
+ ansiStyles$1.exports;
1031
+ (function(module) {
1032
+ const wrapAnsi16 = (fn, offset) => (...args) => {
1033
+ const code = fn(...args);
1034
+ return `\x1B[${code + offset}m`;
1035
+ };
1036
+ const wrapAnsi256 = (fn, offset) => (...args) => {
1037
+ const code = fn(...args);
1038
+ return `\x1B[${38 + offset};5;${code}m`;
1039
+ };
1040
+ const wrapAnsi16m = (fn, offset) => (...args) => {
1041
+ const rgb = fn(...args);
1042
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1043
+ };
1044
+ const ansi2ansi = (n) => n;
1045
+ const rgb2rgb = (r, g, b) => [r, g, b];
1046
+ const setLazyProperty = (object, property, get) => {
1047
+ Object.defineProperty(object, property, {
1048
+ get: () => {
1049
+ const value = get();
1050
+ Object.defineProperty(object, property, {
1051
+ value,
1052
+ enumerable: true,
1053
+ configurable: true
1054
+ });
1055
+ return value;
1056
+ },
1057
+ enumerable: true,
1058
+ configurable: true
1059
+ });
1060
+ };
1061
+ let colorConvert2;
1062
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1063
+ if (colorConvert2 === void 0) {
1064
+ colorConvert2 = requireColorConvert();
1065
+ }
1066
+ const offset = isBackground ? 10 : 0;
1067
+ const styles2 = {};
1068
+ for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
1069
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1070
+ if (sourceSpace === targetSpace) {
1071
+ styles2[name] = wrap(identity, offset);
1072
+ } else if (typeof suite === "object") {
1073
+ styles2[name] = wrap(suite[targetSpace], offset);
1074
+ }
1075
+ }
1076
+ return styles2;
1077
+ };
1078
+ function assembleStyles() {
1079
+ const codes = /* @__PURE__ */ new Map();
1080
+ const styles2 = {
1081
+ modifier: {
1082
+ reset: [0, 0],
1083
+ // 21 isn't widely supported and 22 does the same thing
1084
+ bold: [1, 22],
1085
+ dim: [2, 22],
1086
+ italic: [3, 23],
1087
+ underline: [4, 24],
1088
+ inverse: [7, 27],
1089
+ hidden: [8, 28],
1090
+ strikethrough: [9, 29]
1091
+ },
1092
+ color: {
1093
+ black: [30, 39],
1094
+ red: [31, 39],
1095
+ green: [32, 39],
1096
+ yellow: [33, 39],
1097
+ blue: [34, 39],
1098
+ magenta: [35, 39],
1099
+ cyan: [36, 39],
1100
+ white: [37, 39],
1101
+ // Bright color
1102
+ blackBright: [90, 39],
1103
+ redBright: [91, 39],
1104
+ greenBright: [92, 39],
1105
+ yellowBright: [93, 39],
1106
+ blueBright: [94, 39],
1107
+ magentaBright: [95, 39],
1108
+ cyanBright: [96, 39],
1109
+ whiteBright: [97, 39]
1110
+ },
1111
+ bgColor: {
1112
+ bgBlack: [40, 49],
1113
+ bgRed: [41, 49],
1114
+ bgGreen: [42, 49],
1115
+ bgYellow: [43, 49],
1116
+ bgBlue: [44, 49],
1117
+ bgMagenta: [45, 49],
1118
+ bgCyan: [46, 49],
1119
+ bgWhite: [47, 49],
1120
+ // Bright color
1121
+ bgBlackBright: [100, 49],
1122
+ bgRedBright: [101, 49],
1123
+ bgGreenBright: [102, 49],
1124
+ bgYellowBright: [103, 49],
1125
+ bgBlueBright: [104, 49],
1126
+ bgMagentaBright: [105, 49],
1127
+ bgCyanBright: [106, 49],
1128
+ bgWhiteBright: [107, 49]
1129
+ }
1130
+ };
1131
+ styles2.color.gray = styles2.color.blackBright;
1132
+ styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
1133
+ styles2.color.grey = styles2.color.blackBright;
1134
+ styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
1135
+ for (const [groupName, group] of Object.entries(styles2)) {
1136
+ for (const [styleName, style] of Object.entries(group)) {
1137
+ styles2[styleName] = {
1138
+ open: `\x1B[${style[0]}m`,
1139
+ close: `\x1B[${style[1]}m`
1140
+ };
1141
+ group[styleName] = styles2[styleName];
1142
+ codes.set(style[0], style[1]);
1143
+ }
1144
+ Object.defineProperty(styles2, groupName, {
1145
+ value: group,
1146
+ enumerable: false
1147
+ });
1148
+ }
1149
+ Object.defineProperty(styles2, "codes", {
1150
+ value: codes,
1151
+ enumerable: false
1152
+ });
1153
+ styles2.color.close = "\x1B[39m";
1154
+ styles2.bgColor.close = "\x1B[49m";
1155
+ setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1156
+ setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1157
+ setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1158
+ setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1159
+ setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1160
+ setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1161
+ return styles2;
1162
+ }
1163
+ Object.defineProperty(module, "exports", {
1164
+ enumerable: true,
1165
+ get: assembleStyles
1166
+ });
1167
+ })(ansiStyles$1);
1168
+ var ansiStylesExports = ansiStyles$1.exports;
1169
+ var browser = {
1170
+ stdout: false,
1171
+ stderr: false
1172
+ };
1173
+ const stringReplaceAll$1 = (string, substring, replacer) => {
1174
+ let index = string.indexOf(substring);
1175
+ if (index === -1) {
1176
+ return string;
1177
+ }
1178
+ const substringLength = substring.length;
1179
+ let endIndex = 0;
1180
+ let returnValue = "";
1181
+ do {
1182
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1183
+ endIndex = index + substringLength;
1184
+ index = string.indexOf(substring, endIndex);
1185
+ } while (index !== -1);
1186
+ returnValue += string.substr(endIndex);
1187
+ return returnValue;
1188
+ };
1189
+ const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
1190
+ let endIndex = 0;
1191
+ let returnValue = "";
1192
+ do {
1193
+ const gotCR = string[index - 1] === "\r";
1194
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1195
+ endIndex = index + 1;
1196
+ index = string.indexOf("\n", endIndex);
1197
+ } while (index !== -1);
1198
+ returnValue += string.substr(endIndex);
1199
+ return returnValue;
1200
+ };
1201
+ var util = {
1202
+ stringReplaceAll: stringReplaceAll$1,
1203
+ stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
1204
+ };
1205
+ var templates;
1206
+ var hasRequiredTemplates;
1207
+ function requireTemplates() {
1208
+ if (hasRequiredTemplates) return templates;
1209
+ hasRequiredTemplates = 1;
1210
+ const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1211
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1212
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1213
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1214
+ const ESCAPES = /* @__PURE__ */ new Map([
1215
+ ["n", "\n"],
1216
+ ["r", "\r"],
1217
+ ["t", " "],
1218
+ ["b", "\b"],
1219
+ ["f", "\f"],
1220
+ ["v", "\v"],
1221
+ ["0", "\0"],
1222
+ ["\\", "\\"],
1223
+ ["e", "\x1B"],
1224
+ ["a", "\x07"]
1225
+ ]);
1226
+ function unescape(c) {
1227
+ const u = c[0] === "u";
1228
+ const bracket = c[1] === "{";
1229
+ if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1230
+ return String.fromCharCode(parseInt(c.slice(1), 16));
1231
+ }
1232
+ if (u && bracket) {
1233
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1234
+ }
1235
+ return ESCAPES.get(c) || c;
1236
+ }
1237
+ function parseArguments(name, arguments_) {
1238
+ const results = [];
1239
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
1240
+ let matches;
1241
+ for (const chunk of chunks) {
1242
+ const number = Number(chunk);
1243
+ if (!Number.isNaN(number)) {
1244
+ results.push(number);
1245
+ } else if (matches = chunk.match(STRING_REGEX)) {
1246
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1247
+ } else {
1248
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1249
+ }
1250
+ }
1251
+ return results;
1252
+ }
1253
+ function parseStyle(style) {
1254
+ STYLE_REGEX.lastIndex = 0;
1255
+ const results = [];
1256
+ let matches;
1257
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
1258
+ const name = matches[1];
1259
+ if (matches[2]) {
1260
+ const args = parseArguments(name, matches[2]);
1261
+ results.push([name].concat(args));
1262
+ } else {
1263
+ results.push([name]);
1264
+ }
1265
+ }
1266
+ return results;
1267
+ }
1268
+ function buildStyle(chalk2, styles2) {
1269
+ const enabled = {};
1270
+ for (const layer of styles2) {
1271
+ for (const style of layer.styles) {
1272
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
1273
+ }
1274
+ }
1275
+ let current = chalk2;
1276
+ for (const [styleName, styles3] of Object.entries(enabled)) {
1277
+ if (!Array.isArray(styles3)) {
1278
+ continue;
1279
+ }
1280
+ if (!(styleName in current)) {
1281
+ throw new Error(`Unknown Chalk style: ${styleName}`);
1282
+ }
1283
+ current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
1284
+ }
1285
+ return current;
1286
+ }
1287
+ templates = (chalk2, temporary) => {
1288
+ const styles2 = [];
1289
+ const chunks = [];
1290
+ let chunk = [];
1291
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1292
+ if (escapeCharacter) {
1293
+ chunk.push(unescape(escapeCharacter));
1294
+ } else if (style) {
1295
+ const string = chunk.join("");
1296
+ chunk = [];
1297
+ chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
1298
+ styles2.push({ inverse, styles: parseStyle(style) });
1299
+ } else if (close) {
1300
+ if (styles2.length === 0) {
1301
+ throw new Error("Found extraneous } in Chalk template literal");
1302
+ }
1303
+ chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
1304
+ chunk = [];
1305
+ styles2.pop();
1306
+ } else {
1307
+ chunk.push(character);
1308
+ }
1309
+ });
1310
+ chunks.push(chunk.join(""));
1311
+ if (styles2.length > 0) {
1312
+ const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
1313
+ throw new Error(errMessage);
1314
+ }
1315
+ return chunks.join("");
1316
+ };
1317
+ return templates;
1318
+ }
1319
+ const ansiStyles = ansiStylesExports;
1320
+ const { stdout: stdoutColor, stderr: stderrColor } = browser;
1321
+ const {
1322
+ stringReplaceAll,
1323
+ stringEncaseCRLFWithFirstIndex
1324
+ } = util;
1325
+ const { isArray } = Array;
1326
+ const levelMapping = [
1327
+ "ansi",
1328
+ "ansi",
1329
+ "ansi256",
1330
+ "ansi16m"
1331
+ ];
1332
+ const styles = /* @__PURE__ */ Object.create(null);
1333
+ const applyOptions = (object, options = {}) => {
1334
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1335
+ throw new Error("The `level` option should be an integer from 0 to 3");
1336
+ }
1337
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
1338
+ object.level = options.level === void 0 ? colorLevel : options.level;
1339
+ };
1340
+ class ChalkClass {
1341
+ constructor(options) {
1342
+ return chalkFactory(options);
1343
+ }
1344
+ }
1345
+ const chalkFactory = (options) => {
1346
+ const chalk2 = {};
1347
+ applyOptions(chalk2, options);
1348
+ chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
1349
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
1350
+ Object.setPrototypeOf(chalk2.template, chalk2);
1351
+ chalk2.template.constructor = () => {
1352
+ throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1353
+ };
1354
+ chalk2.template.Instance = ChalkClass;
1355
+ return chalk2.template;
1356
+ };
1357
+ function Chalk(options) {
1358
+ return chalkFactory(options);
1359
+ }
1360
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
1361
+ styles[styleName] = {
1362
+ get() {
1363
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1364
+ Object.defineProperty(this, styleName, { value: builder });
1365
+ return builder;
1366
+ }
1367
+ };
1368
+ }
1369
+ styles.visible = {
1370
+ get() {
1371
+ const builder = createBuilder(this, this._styler, true);
1372
+ Object.defineProperty(this, "visible", { value: builder });
1373
+ return builder;
1374
+ }
1375
+ };
1376
+ const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1377
+ for (const model of usedModels) {
1378
+ styles[model] = {
1379
+ get() {
1380
+ const { level } = this;
1381
+ return function(...arguments_) {
1382
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
1383
+ return createBuilder(this, styler, this._isEmpty);
1384
+ };
1385
+ }
1386
+ };
1387
+ }
1388
+ for (const model of usedModels) {
1389
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1390
+ styles[bgModel] = {
1391
+ get() {
1392
+ const { level } = this;
1393
+ return function(...arguments_) {
1394
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
1395
+ return createBuilder(this, styler, this._isEmpty);
1396
+ };
1397
+ }
1398
+ };
1399
+ }
1400
+ const proto = Object.defineProperties(() => {
1401
+ }, {
1402
+ ...styles,
1403
+ level: {
1404
+ enumerable: true,
1405
+ get() {
1406
+ return this._generator.level;
1407
+ },
1408
+ set(level) {
1409
+ this._generator.level = level;
1410
+ }
1411
+ }
1412
+ });
1413
+ const createStyler = (open, close, parent) => {
1414
+ let openAll;
1415
+ let closeAll;
1416
+ if (parent === void 0) {
1417
+ openAll = open;
1418
+ closeAll = close;
1419
+ } else {
1420
+ openAll = parent.openAll + open;
1421
+ closeAll = close + parent.closeAll;
1422
+ }
1423
+ return {
1424
+ open,
1425
+ close,
1426
+ openAll,
1427
+ closeAll,
1428
+ parent
1429
+ };
1430
+ };
1431
+ const createBuilder = (self, _styler, _isEmpty) => {
1432
+ const builder = (...arguments_) => {
1433
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1434
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
1435
+ }
1436
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1437
+ };
1438
+ Object.setPrototypeOf(builder, proto);
1439
+ builder._generator = self;
1440
+ builder._styler = _styler;
1441
+ builder._isEmpty = _isEmpty;
1442
+ return builder;
1443
+ };
1444
+ const applyStyle = (self, string) => {
1445
+ if (self.level <= 0 || !string) {
1446
+ return self._isEmpty ? "" : string;
1447
+ }
1448
+ let styler = self._styler;
1449
+ if (styler === void 0) {
1450
+ return string;
1451
+ }
1452
+ const { openAll, closeAll } = styler;
1453
+ if (string.indexOf("\x1B") !== -1) {
1454
+ while (styler !== void 0) {
1455
+ string = stringReplaceAll(string, styler.close, styler.open);
1456
+ styler = styler.parent;
1457
+ }
1458
+ }
1459
+ const lfIndex = string.indexOf("\n");
1460
+ if (lfIndex !== -1) {
1461
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1462
+ }
1463
+ return openAll + string + closeAll;
1464
+ };
1465
+ let template;
1466
+ const chalkTag = (chalk2, ...strings) => {
1467
+ const [firstString] = strings;
1468
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
1469
+ return strings.join(" ");
1470
+ }
1471
+ const arguments_ = strings.slice(1);
1472
+ const parts = [firstString.raw[0]];
1473
+ for (let i = 1; i < firstString.length; i++) {
1474
+ parts.push(
1475
+ String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
1476
+ String(firstString.raw[i])
1477
+ );
1478
+ }
1479
+ if (template === void 0) {
1480
+ template = requireTemplates();
1481
+ }
1482
+ return template(chalk2, parts.join(""));
1483
+ };
1484
+ Object.defineProperties(Chalk.prototype, styles);
1485
+ const chalk = Chalk();
1486
+ chalk.supportsColor = stdoutColor;
1487
+ chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1488
+ chalk.stderr.supportsColor = stderrColor;
1489
+ var source = chalk;
1490
+ const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
1491
+ chalk$1.level = 3;
1492
+ class WorkerInstance {
1493
+ constructor() {
1494
+ __privateAdd(this, _WorkerInstance_instances);
1495
+ __privateAdd(this, _collectorCollectorPort, null);
1496
+ __privateAdd(this, _runners, {});
1497
+ __privateAdd(this, _options, null);
1498
+ __privateAdd(this, _debug, (message) => {
1499
+ if (__privateGet(this, _options)) {
1500
+ console.log(chalk$1.green(`pid: [${process.pid}] ${__privateGet(this, _options).id} WorkerInstance::${message}`));
1501
+ } else {
1502
+ console.log(chalk$1.green(`pid: [${process.pid}] WorkerInstance::${message}`));
1503
+ }
1504
+ });
1505
+ __publicField(this, "GetRandomInt", (max) => {
1506
+ __privateGet(this, _debug).call(this, `GetRandomInt`);
1507
+ return Math.floor(Math.random() * Math.floor(max));
1508
+ });
1509
+ __publicField(this, "StartWork", async (runner) => {
1510
+ __privateGet(this, _debug).call(this, `StartWork`);
1511
+ return;
1512
+ });
1513
+ __publicField(this, "PostTelemetry", (runner) => {
1514
+ if (__privateGet(this, _collectorCollectorPort)) {
1515
+ const message = {
1516
+ command: eIWMessageCommands.InstrumentTelemetry,
1517
+ payload: {
1518
+ runner
1519
+ }
1520
+ };
1521
+ __privateGet(this, _collectorCollectorPort).postMessage(message);
1522
+ }
1523
+ });
1524
+ __privateAdd(this, _SetMessagePort, (workerMessagePort) => {
1525
+ __privateGet(this, _debug).call(this, `SetMessagePort`);
1526
+ __privateSet(this, _collectorCollectorPort, workerMessagePort.port);
1527
+ if (isNode) {
1528
+ __privateGet(this, _collectorCollectorPort).on("message", (data) => {
1529
+ __privateGet(this, _debug).call(this, `collectorCollectorPort onmessage: ${data.data}`);
1530
+ });
1531
+ } else {
1532
+ __privateGet(this, _collectorCollectorPort).onmessage = function(data) {
1533
+ console.log(`collectorCollectorPort onmessage: ${data.data}`);
1534
+ };
1535
+ }
1536
+ const response = {
1537
+ command: eIWMessageCommands.MessagePortResponse,
1538
+ payload: {}
1539
+ };
1540
+ __privateGet(this, _collectorCollectorPort).postMessage(response);
1541
+ });
1542
+ __publicField(this, "CreateAsyncRunner", (testRunnerTelemetryPayload) => {
1543
+ return null;
1544
+ });
1545
+ __privateAdd(this, _AddRunner, (testRunnerTelemetryPayload) => {
1546
+ __privateGet(this, _debug).call(this, `AddRunner`);
1547
+ const { runner } = testRunnerTelemetryPayload;
1548
+ const asyncRunnerInstance = this.CreateAsyncRunner(testRunnerTelemetryPayload);
1549
+ if (asyncRunnerInstance) {
1550
+ __privateGet(this, _runners)[runner.id] = {
1551
+ runnerInstance: asyncRunnerInstance,
1552
+ runner: testRunnerTelemetryPayload.runner,
1553
+ iteration: 0,
1554
+ terminate: false,
1555
+ paused: false
1556
+ };
1557
+ }
1558
+ return runner;
1559
+ });
1560
+ __privateAdd(this, _StartRunner, async (testRunnerTelemetryPayload) => {
1561
+ const { runner } = testRunnerTelemetryPayload;
1562
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} StartRunner`);
1563
+ __privateGet(this, _runners)[runner.id].terminate = false;
1564
+ __privateGet(this, _runners)[runner.id].paused = false;
1565
+ await __privateGet(this, _runners)[runner.id].runnerInstance.StartRunner();
1566
+ const ExecuteLoop = async () => {
1567
+ if (__privateGet(this, _runners)[runner.id].iteration < __privateGet(this, _runners)[runner.id].runner.options.executionProfile.iterations) {
1568
+ if (!__privateGet(this, _runners)[runner.id].paused) {
1569
+ await __privateGet(this, _runners)[runner.id].runnerInstance.Execute(__privateGet(this, _runners)[runner.id].iteration);
1570
+ __privateGet(this, _runners)[runner.id].iteration++;
1571
+ }
1572
+ if (!__privateGet(this, _runners)[runner.id].terminate) {
1573
+ if (!__privateGet(this, _runners)[runner.id].paused) {
1574
+ if (__privateGet(this, _runners)[runner.id].runner.options.executionProfile.delayBetweenIterations > 0) {
1575
+ await Sleep(__privateGet(this, _runners)[runner.id].runner.options.executionProfile.delayBetweenIterations);
1576
+ } else {
1577
+ await __privateMethod(this, _WorkerInstance_instances, SleepImmediate_fn).call(this);
1578
+ }
1579
+ ExecuteLoop();
1580
+ } else {
1581
+ await Sleep(50);
1582
+ ExecuteLoop();
1583
+ }
1584
+ }
1585
+ } else {
1586
+ if (__privateGet(this, _collectorCollectorPort)) {
1587
+ const message = {
1588
+ command: eIWMessageCommands.Completed,
1589
+ payload: {
1590
+ runner
1591
+ }
1592
+ };
1593
+ __privateGet(this, _collectorCollectorPort).postMessage(message);
1594
+ }
1595
+ await __privateGet(this, _runners)[runner.id].runnerInstance.Completed();
1596
+ }
1597
+ };
1598
+ ExecuteLoop();
1599
+ });
1600
+ __privateAdd(this, _StopAllRunners, async (testRunnerTelemetryPayload) => {
1601
+ __privateGet(this, _debug).call(this, `StopAllRunners`);
1602
+ for (const [, runner] of Object.entries(__privateGet(this, _runners))) {
1603
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.runner.id}]`)} StopAllRunners`);
1604
+ runner.terminate = true;
1605
+ await runner.runnerInstance.StopRunner();
1606
+ }
1607
+ await Sleep(0);
1608
+ });
1609
+ __privateAdd(this, _StopRunner, async (testRunnerTelemetryPayload) => {
1610
+ const { runner } = testRunnerTelemetryPayload;
1611
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} StopRunner`);
1612
+ __privateGet(this, _runners)[runner.id].terminate = true;
1613
+ await __privateGet(this, _runners)[runner.id].runnerInstance.StopRunner();
1614
+ await Sleep(0);
1615
+ });
1616
+ __privateAdd(this, _TerminateRunner, async (testRunnerTelemetryPayload) => {
1617
+ const { runner } = testRunnerTelemetryPayload;
1618
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} TerminateRunner`);
1619
+ __privateGet(this, _runners)[runner.id].terminate = true;
1620
+ await __privateGet(this, _runners)[runner.id].runnerInstance.TerminateRunner();
1621
+ await Sleep(0);
1622
+ });
1623
+ __privateAdd(this, _PauseRunner, async (testRunnerTelemetryPayload) => {
1624
+ const { runner } = testRunnerTelemetryPayload;
1625
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} PauseRunner`);
1626
+ __privateGet(this, _runners)[runner.id].paused = true;
1627
+ await __privateGet(this, _runners)[runner.id].runnerInstance.PauseRunner();
1628
+ await Sleep(0);
1629
+ });
1630
+ __privateAdd(this, _ResumeRunner, async (testRunnerTelemetryPayload) => {
1631
+ const { runner } = testRunnerTelemetryPayload;
1632
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} ResumeRunner`);
1633
+ __privateGet(this, _runners)[runner.id].paused = false;
1634
+ await __privateGet(this, _runners)[runner.id].runnerInstance.ResumeRunner();
1635
+ await Sleep(0);
1636
+ });
1637
+ __privateAdd(this, _ResetRunner, async (testRunnerTelemetryPayload) => {
1638
+ const { runner } = testRunnerTelemetryPayload;
1639
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} ResetRunner`);
1640
+ __privateGet(this, _runners)[runner.id].terminate = true;
1641
+ __privateGet(this, _runners)[runner.id].iteration = 0;
1642
+ await __privateGet(this, _runners)[runner.id].runnerInstance.ResetRunner();
1643
+ await Sleep(0);
1644
+ });
1645
+ // Execute a single iteration of this runners work item
1646
+ __privateAdd(this, _ExecuteRunner, async (testRunnerTelemetryPayload) => {
1647
+ const { runner } = testRunnerTelemetryPayload;
1648
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} ExecuteRunner`);
1649
+ await __privateGet(this, _runners)[runner.id].runnerInstance.Execute(__privateGet(this, _runners)[runner.id].iteration);
1650
+ __privateGet(this, _runners)[runner.id].iteration++;
1651
+ await Sleep(0);
1652
+ });
1653
+ __privateAdd(this, _UpdateOptions, async (testRunnerTelemetryPayload) => {
1654
+ const { runner } = testRunnerTelemetryPayload;
1655
+ __privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} UpdateOptions`);
1656
+ console.log(chalk$1.cyan(`before: [${JSON.stringify(__privateGet(this, _runners)[runner.id].runner.options)}]`));
1657
+ __privateGet(this, _runners)[runner.id].runner.options = { ...runner.options };
1658
+ console.log(chalk$1.cyan(`after: [${JSON.stringify(__privateGet(this, _runners)[runner.id].runner.options)}]`));
1659
+ await __privateGet(this, _runners)[runner.id].runnerInstance.UpdateOptions();
1660
+ await Sleep(0);
1661
+ });
1662
+ // ProcessMessage = async(data: MessageEvent) => { // Browser version
1663
+ __publicField(this, "ProcessMessage", async (data) => {
1664
+ __privateGet(this, _debug).call(this, `ProcessMessage: data: [${JSON.stringify(data)}]`);
1665
+ try {
1666
+ const payloadMessage = data;
1667
+ switch (payloadMessage.command) {
1668
+ case eIWMessageCommands.MessagePort:
1669
+ __privateGet(this, _debug).call(this, `ProcessMessage::MessagePort`);
1670
+ __privateGet(this, _SetMessagePort).call(this, payloadMessage.payload);
1671
+ __privateSet(this, _options, payloadMessage.payload.options);
1672
+ __privateGet(this, _debug).call(this, `ProcessMessage::#options: [${JSON.stringify(__privateGet(this, _options))}]`);
1673
+ break;
1674
+ case eIWMessageCommands.AddRunner:
1675
+ __privateGet(this, _debug).call(this, `ProcessMessage::AddRunner`);
1676
+ __privateGet(this, _AddRunner).call(this, payloadMessage.payload);
1677
+ break;
1678
+ case eIWMessageCommands.StopAllRunners:
1679
+ __privateGet(this, _debug).call(this, `ProcessMessage::StopAllRunners`);
1680
+ __privateGet(this, _StopAllRunners).call(this, payloadMessage.payload);
1681
+ break;
1682
+ case eIWMessageCommands.StartRunner:
1683
+ __privateGet(this, _debug).call(this, `ProcessMessage::StartRunner`);
1684
+ __privateGet(this, _StartRunner).call(this, payloadMessage.payload);
1685
+ break;
1686
+ case eIWMessageCommands.StopRunner:
1687
+ __privateGet(this, _debug).call(this, `ProcessMessage::StopRunner`);
1688
+ __privateGet(this, _StopRunner).call(this, payloadMessage.payload);
1689
+ break;
1690
+ case eIWMessageCommands.TerminateRunner:
1691
+ __privateGet(this, _debug).call(this, `ProcessMessage::TerminateRunner`);
1692
+ __privateGet(this, _TerminateRunner).call(this, payloadMessage.payload);
1693
+ break;
1694
+ case eIWMessageCommands.PauseRunner:
1695
+ __privateGet(this, _debug).call(this, `ProcessMessage::PauseRunner`);
1696
+ __privateGet(this, _PauseRunner).call(this, payloadMessage.payload);
1697
+ break;
1698
+ case eIWMessageCommands.ResumeRunner:
1699
+ __privateGet(this, _debug).call(this, `ProcessMessage::ResumeRunner`);
1700
+ __privateGet(this, _ResumeRunner).call(this, payloadMessage.payload);
1701
+ break;
1702
+ case eIWMessageCommands.ResetRunner:
1703
+ __privateGet(this, _debug).call(this, `ProcessMessage::ResetRunner`);
1704
+ __privateGet(this, _ResetRunner).call(this, payloadMessage.payload);
1705
+ break;
1706
+ case eIWMessageCommands.ExecuteRunner:
1707
+ __privateGet(this, _debug).call(this, `ProcessMessage::ExecuteRunner`);
1708
+ __privateGet(this, _ExecuteRunner).call(this, payloadMessage.payload);
1709
+ break;
1710
+ case eIWMessageCommands.UpdateOptions:
1711
+ __privateGet(this, _debug).call(this, `ProcessMessage::UpdateOptions`);
1712
+ __privateGet(this, _UpdateOptions).call(this, payloadMessage.payload);
1713
+ break;
1714
+ default:
1715
+ __privateGet(this, _debug).call(this, `ProcessMessage::default`);
1716
+ __privateGet(this, _debug).call(this, `Invalid payloadMessage.command: [${payloadMessage.command}] - Ignoring`);
1717
+ }
1718
+ } catch (error) {
1719
+ console.log(error);
1720
+ }
1721
+ });
1722
+ __privateGet(this, _debug).call(this, `constructor`);
1723
+ }
1724
+ get CollectorCollectorPort() {
1725
+ return __privateGet(this, _collectorCollectorPort);
1726
+ }
1727
+ get Options() {
1728
+ return __privateGet(this, _options);
1729
+ }
1730
+ }
1731
+ _collectorCollectorPort = new WeakMap();
1732
+ _runners = new WeakMap();
1733
+ _options = new WeakMap();
1734
+ _debug = new WeakMap();
1735
+ _SetMessagePort = new WeakMap();
1736
+ _AddRunner = new WeakMap();
1737
+ _WorkerInstance_instances = new WeakSet();
1738
+ SleepImmediate_fn = function() {
1739
+ return new Promise((resolve, reject) => {
1740
+ resolve();
1741
+ });
1742
+ };
1743
+ _StartRunner = new WeakMap();
1744
+ _StopAllRunners = new WeakMap();
1745
+ _StopRunner = new WeakMap();
1746
+ _TerminateRunner = new WeakMap();
1747
+ _PauseRunner = new WeakMap();
1748
+ _ResumeRunner = new WeakMap();
1749
+ _ResetRunner = new WeakMap();
1750
+ _ExecuteRunner = new WeakMap();
1751
+ _UpdateOptions = new WeakMap();
1752
+ class TelemetryProcessor {
1753
+ constructor() {
1754
+ __publicField(this, "ProcessTelemetry", (publishInstrumentController, telemetry) => {
1755
+ let update = false;
1756
+ if (telemetry.message) {
1757
+ telemetry.message.forEach((message) => {
1758
+ publishInstrumentController.LogEx(message);
1759
+ });
1760
+ update = true;
1761
+ }
1762
+ if (telemetry.requestCount) {
1763
+ publishInstrumentController.UpdateInstrument(Gauge.REQUEST_COUNT_GAUGE, {
1764
+ val: telemetry.requestCount
1765
+ });
1766
+ update = true;
1767
+ }
1768
+ if (telemetry.errorCount) {
1769
+ publishInstrumentController.UpdateInstrument(Gauge.ERROR_COUNT_GAUGE, {
1770
+ val: telemetry.errorCount
1771
+ });
1772
+ update = true;
1773
+ }
1774
+ if (telemetry.retryCount) {
1775
+ publishInstrumentController.UpdateInstrument(Gauge.RETRY_COUNT_GAUGE, {
1776
+ val: telemetry.retryCount
1777
+ });
1778
+ update = true;
1779
+ }
1780
+ if (telemetry.authenticationCount) {
1781
+ publishInstrumentController.UpdateInstrument(Gauge.AUTHENTICATION_COUNT_GAUGE, {
1782
+ val: telemetry.authenticationCount
1783
+ });
1784
+ update = true;
1785
+ }
1786
+ if (telemetry.authenticationErrorCount) {
1787
+ publishInstrumentController.UpdateInstrument(Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, {
1788
+ val: telemetry.authenticationCount
1789
+ });
1790
+ update = true;
1791
+ }
1792
+ if (telemetry.authenticationRetryCount) {
1793
+ publishInstrumentController.UpdateInstrument(Gauge.AUTHENTICATION_RETRY_COUNT_GAUGE, {
1794
+ val: telemetry.authenticationCount
1795
+ });
1796
+ update = true;
1797
+ }
1798
+ if (telemetry.coreCount) {
1799
+ publishInstrumentController.UpdateInstrument(Gauge.CORE_COUNT_GAUGE, {
1800
+ val: telemetry.coreCount
1801
+ });
1802
+ update = true;
1803
+ }
1804
+ if (telemetry.timer) {
1805
+ publishInstrumentController.UpdateInstrument(Gauge.TIMER_GAUGE, {
1806
+ val: telemetry.timer
1807
+ });
1808
+ update = true;
1809
+ }
1810
+ publishInstrumentController.UpdateInstrument(Gauge.ACTIVE_REQUEST_GAUGE, {
1811
+ val: telemetry.activeRequestCount
1812
+ });
1813
+ if (telemetry.velocity) {
1814
+ publishInstrumentController.UpdateInstrument(Gauge.VELOCITY_GAUGE, {
1815
+ Inc: telemetry.velocity
1816
+ });
1817
+ update = true;
1818
+ }
1819
+ if (telemetry.duration) {
1820
+ publishInstrumentController.UpdateInstrument(Gauge.DURATION_GAUGE, {
1821
+ val: telemetry.duration
1822
+ });
1823
+ publishInstrumentController.UpdateInstrument(Gauge.DURATION_HISTOGRAM_GAUGE, {
1824
+ val: telemetry.duration
1825
+ });
1826
+ update = true;
1827
+ }
1828
+ if (telemetry.latency) {
1829
+ publishInstrumentController.UpdateInstrument(Gauge.LATENCY_GAUGE, {
1830
+ val: telemetry.latency
1831
+ });
1832
+ publishInstrumentController.UpdateInstrument(Gauge.LATENCY_HISTOGRAM_GAUGE, {
1833
+ val: telemetry.latency
1834
+ });
1835
+ update = true;
1836
+ }
1837
+ if (telemetry.childCount) {
1838
+ publishInstrumentController.UpdateInstrument(Gauge.CHILD_COUNT, {
1839
+ val: telemetry.childCount
1840
+ });
1841
+ update = true;
1842
+ }
1843
+ if (telemetry.rx) {
1844
+ publishInstrumentController.UpdateInstrument(Gauge.NETWORK_RX_GAUGE, {
1845
+ Inc: telemetry.rx
1846
+ });
1847
+ update = true;
1848
+ }
1849
+ if (telemetry.tx) {
1850
+ publishInstrumentController.UpdateInstrument(Gauge.NETWORK_TX_GAUGE, {
1851
+ Inc: telemetry.tx
1852
+ });
1853
+ update = true;
1854
+ }
1855
+ return update;
1856
+ });
1857
+ }
1858
+ }
1859
+ chalk$1.level = 3;
1860
+ class STSWorkerManager {
1861
+ constructor(options) {
1862
+ __privateAdd(this, _STSWorkerManager_instances);
1863
+ //#agentSession: string = null;
1864
+ __privateAdd(this, _workersEx, {});
1865
+ __privateAdd(this, _runner, 0);
1866
+ __privateAdd(this, _workerId, 0);
1867
+ __privateAdd(this, _options2);
1868
+ __privateAdd(this, _STSInstrumentController);
1869
+ __privateAdd(this, _telemetryProcessor);
1870
+ __privateAdd(this, _debug2, (message) => {
1871
+ console.log(chalk$1.cyan(`pid: [${process.pid}] STSWorkerManager::${message}`));
1872
+ });
1873
+ __publicField(this, "AddWorker", async (useWorkerFactory) => {
1874
+ let workerFactory;
1875
+ if (useWorkerFactory) {
1876
+ workerFactory = useWorkerFactory;
1877
+ } else {
1878
+ workerFactory = __privateGet(this, _options2).workerFactory;
1879
+ }
1880
+ const workerId = __privateWrapper(this, _workerId)._++;
1881
+ const stsWorkerEx = {
1882
+ id: workerId,
1883
+ worker: workerFactory.createWorkerThreadWorker(),
1884
+ state: IWorkerState.starting,
1885
+ workerThreadWorkerOptions: workerFactory.workerThreadWorkerOptions,
1886
+ runnersEx: {},
1887
+ runnersEvents: {},
1888
+ GetRunner: (id) => __privateGet(this, _workersEx)[workerId].GetRunner(id),
1889
+ // Commands to execute on individual runners
1890
+ AddRunner: (runnerOptions) => this.AddRunnerToWorker(stsWorkerEx, runnerOptions),
1891
+ StartRunner: (runner) => __privateGet(this, _StartRunner2).call(this, stsWorkerEx, runner),
1892
+ StopRunner: (runner) => __privateGet(this, _StopRunner2).call(this, stsWorkerEx, runner),
1893
+ PauseRunner: (runner) => __privateGet(this, _PauseRunner2).call(this, stsWorkerEx, runner),
1894
+ ResumeRunner: (runner) => __privateGet(this, _ResumeRunner2).call(this, stsWorkerEx, runner),
1895
+ TerminateRunner: (runner) => __privateGet(this, _TerminateRunner2).call(this, stsWorkerEx, runner),
1896
+ ResetRunner: (runner) => __privateGet(this, _ResetRunner2).call(this, stsWorkerEx, runner),
1897
+ ExecuteRunner: (runner) => __privateGet(this, _ExecuteRunner2).call(this, stsWorkerEx, runner),
1898
+ UpdateOptionsRunner: (runner, options) => __privateGet(this, _UpdateOptions2).call(this, stsWorkerEx, runner, options),
1899
+ // Commands to execute on all runners
1900
+ Start: async () => __privateGet(this, _StartWorker).call(this, stsWorkerEx),
1901
+ Stop: async () => __privateGet(this, _StopWorker).call(this, stsWorkerEx),
1902
+ Pause: async () => __privateGet(this, _PauseWorker).call(this, stsWorkerEx),
1903
+ Resume: async () => __privateGet(this, _ResumeWorker).call(this, stsWorkerEx),
1904
+ Terminate: async () => __privateGet(this, _TerminateWorker).call(this, stsWorkerEx),
1905
+ Reset: async () => __privateGet(this, _ResetWorker).call(this, stsWorkerEx),
1906
+ Execute: async () => __privateGet(this, _ExecuteWorker).call(this, stsWorkerEx),
1907
+ UpdateOptions: async (options) => __privateGet(this, _UpdateOptionsWorker).call(this, stsWorkerEx, options)
1908
+ };
1909
+ __privateGet(this, _STSInstrumentController).LogEx(chalk$1.yellow(`pid: [${process.pid}] Creating new worker: [${stsWorkerEx.id}]`));
1910
+ __privateGet(this, _debug2).call(this, `Adding worker: [${stsWorkerEx.id}]`);
1911
+ const {
1912
+ port1,
1913
+ // process message port
1914
+ port2
1915
+ // collector message port
1916
+ } = new MessageChannel();
1917
+ const workerPort = port1;
1918
+ __privateGet(this, _debug2).call(this, `AddWorker::workerThreadWorkerOptions: [${stsWorkerEx.workerThreadWorkerOptions.id}]`);
1919
+ __privateGet(this, _PostMessageToWorker).call(this, stsWorkerEx, eIWMessageCommands.MessagePort, {
1920
+ port: port2,
1921
+ //applicationStoreState: stateCopy,
1922
+ options: {
1923
+ ...stsWorkerEx.workerThreadWorkerOptions
1924
+ }
1925
+ }, port2);
1926
+ const processMessage = (data) => {
1927
+ const publishMessagePayload2 = data;
1928
+ switch (publishMessagePayload2.command) {
1929
+ case eIWMessageCommands.MessagePortResponse:
1930
+ stsWorkerEx.state = IWorkerState.started;
1931
+ break;
1932
+ case eIWMessageCommands.InstrumentTelemetry:
1933
+ __privateGet(this, _ProcessTelemetry).call(this, stsWorkerEx, publishMessagePayload2.payload);
1934
+ break;
1935
+ case eIWMessageCommands.Completed:
1936
+ __privateGet(this, _ProcessCompleted).call(this, stsWorkerEx, publishMessagePayload2.payload);
1937
+ break;
1938
+ default:
1939
+ __privateGet(this, _debug2).call(this, `AddWorker::default`);
1940
+ }
1941
+ };
1942
+ let publishMessagePayload;
1943
+ if (isNode) {
1944
+ workerPort.on("message", (data) => {
1945
+ publishMessagePayload = data;
1946
+ processMessage(publishMessagePayload);
1947
+ });
1948
+ } else {
1949
+ workerPort.onmessage = async (data) => {
1950
+ publishMessagePayload = data.data;
1951
+ processMessage(publishMessagePayload);
1952
+ };
1953
+ }
1954
+ __privateGet(this, _workersEx)[stsWorkerEx.id] = stsWorkerEx;
1955
+ __privateGet(this, _debug2).call(this, `Added worker: [${stsWorkerEx.id}]`);
1956
+ return stsWorkerEx;
1957
+ });
1958
+ __publicField(this, "AddRunnerToWorker", (stsWorkerEx, runnerOptions) => {
1959
+ const runnerEx = __privateGet(this, _CreateAsyncRunner).call(this, stsWorkerEx, runnerOptions);
1960
+ stsWorkerEx.runnersEx[runnerEx.id] = runnerEx;
1961
+ __privateGet(this, _SetRunnerIntoWorker).call(this, stsWorkerEx, runnerEx);
1962
+ runnerEx.publishInstrumentController.LogEx(chalk$1.green(`Added runner: [${runnerEx.id}] into worker: [${stsWorkerEx.id}]`));
1963
+ return runnerEx;
1964
+ });
1965
+ __privateAdd(this, _SetRunnerIntoWorker, (workerEx, runnerEx) => {
1966
+ const payload = {
1967
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
1968
+ };
1969
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.AddRunner, payload);
1970
+ });
1971
+ __privateAdd(this, _ProcessTelemetry, (workerEx, payloadContents) => {
1972
+ const { runner } = payloadContents;
1973
+ if (workerEx.runnersEx[runner.id]) {
1974
+ const runnerEx = workerEx.runnersEx[runner.id];
1975
+ runnerEx.instrumentData = { ...runner.instrumentData };
1976
+ if (runner.instrumentData.message) {
1977
+ runnerEx.instrumentData.message = [...runner.instrumentData.message];
1978
+ } else {
1979
+ runnerEx.instrumentData.message = [];
1980
+ }
1981
+ __privateGet(this, _telemetryProcessor).ProcessTelemetry(runnerEx.publishInstrumentController, runnerEx.instrumentData);
1982
+ }
1983
+ });
1984
+ __privateAdd(this, _ProcessCompleted, (workerEx, payloadContents) => {
1985
+ const { runner } = payloadContents;
1986
+ if (workerEx.runnersEvents[runner.id]) {
1987
+ const runnersEvents = workerEx.runnersEvents[runner.id];
1988
+ runnersEvents.forEach((ev) => {
1989
+ if (ev.eventName.localeCompare("Completed") === 0) {
1990
+ ev.cb();
1991
+ }
1992
+ });
1993
+ }
1994
+ console.log(chalk$1.green(`ProcessCompleted: [${JSON.stringify(runner)}]`));
1995
+ });
1996
+ __privateAdd(this, _CreateAsyncRunner, (workerEx, runnerOptions) => {
1997
+ __privateWrapper(this, _runner)._++;
1998
+ __privateGet(this, _STSInstrumentController).LogEx(chalk$1.yellow(`Creating new async runner: [${__privateGet(this, _runner)}]`));
1999
+ const asyncRunnerContext = {
2000
+ nid: `${workerEx.workerThreadWorkerOptions.hostName}${ModelDelimeter.COMPONENT_SEPERATOR}${workerEx.workerThreadWorkerOptions.agentId}-${workerEx.workerThreadWorkerOptions.userAgent}${ModelDelimeter.NID_SEPERATOR}worker${workerEx.id}${ModelDelimeter.SEPERATOR}${__privateGet(this, _runner)}`,
2001
+ id: __privateGet(this, _runner).toString(),
2002
+ hostName: workerEx.workerThreadWorkerOptions.hostName ? workerEx.workerThreadWorkerOptions.hostName : "host",
2003
+ agentName: `${workerEx.workerThreadWorkerOptions.agentId}-${workerEx.workerThreadWorkerOptions.userAgent}`,
2004
+ threadId: `worker${workerEx.id}`,
2005
+ asyncRunnerId: __privateGet(this, _runner)
2006
+ };
2007
+ const runnerEx = {
2008
+ id: __privateGet(this, _runner),
2009
+ publishInstrumentController: __privateGet(this, _STSInstrumentController).AddPublishInstrumentController(asyncRunnerContext),
2010
+ asyncRunnerContext,
2011
+ options: runnerOptions,
2012
+ instrumentData: {
2013
+ requestCount: 0,
2014
+ errorCount: 0,
2015
+ retryCount: 0,
2016
+ authenticationCount: 0,
2017
+ authenticationErrorCount: 0,
2018
+ authenticationRetryCount: 0,
2019
+ velocity: 0,
2020
+ coreCount: 0,
2021
+ timer: 0,
2022
+ duration: 0,
2023
+ latency: 0,
2024
+ activeRequestCount: 0,
2025
+ message: [],
2026
+ childCount: 0,
2027
+ rx: 0,
2028
+ tx: 0
2029
+ },
2030
+ Start: async () => __privateGet(this, _StartRunner2).call(this, workerEx, runnerEx),
2031
+ Stop: async () => __privateGet(this, _StopRunner2).call(this, workerEx, runnerEx),
2032
+ Pause: async () => __privateGet(this, _PauseRunner2).call(this, workerEx, runnerEx),
2033
+ Resume: async () => __privateGet(this, _ResumeRunner2).call(this, workerEx, runnerEx),
2034
+ Reset: async () => __privateGet(this, _ResetRunner2).call(this, workerEx, runnerEx),
2035
+ Execute: async () => __privateGet(this, _ExecuteRunner2).call(this, workerEx, runnerEx),
2036
+ Terminate: async () => __privateGet(this, _TerminateRunner2).call(this, workerEx, runnerEx),
2037
+ UpdateOptions: async (options) => __privateGet(this, _UpdateOptions2).call(this, workerEx, runnerEx, options),
2038
+ on: (eventName, cb) => {
2039
+ if (!workerEx.runnersEvents[runnerEx.id]) {
2040
+ workerEx.runnersEvents[runnerEx.id] = [];
2041
+ }
2042
+ workerEx.runnersEvents[runnerEx.id].push({
2043
+ eventName,
2044
+ cb
2045
+ });
2046
+ return runnerEx;
2047
+ }
2048
+ };
2049
+ return runnerEx;
2050
+ });
2051
+ __privateAdd(this, _PostMessageToWorker, (workerEx, command, payload, transferObject) => {
2052
+ if (transferObject) {
2053
+ __privateGet(this, _debug2).call(this, `#PostMessageToWorker with transfer object`);
2054
+ workerEx.worker.postMessage({ command, payload }, [transferObject]);
2055
+ __privateGet(this, _debug2).call(this, `#PostMessageToWorker with transfer object - done...`);
2056
+ } else {
2057
+ __privateGet(this, _debug2).call(this, `#PostMessageToWorker`);
2058
+ workerEx.worker.postMessage({ command, payload });
2059
+ }
2060
+ });
2061
+ __privateAdd(this, _StartRunner2, async (workerEx, runnerEx) => {
2062
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StartRunner, {
2063
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2064
+ });
2065
+ return true;
2066
+ });
2067
+ __privateAdd(this, _ResetRunner2, async (workerEx, runnerEx) => {
2068
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResetRunner, {
2069
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2070
+ });
2071
+ return true;
2072
+ });
2073
+ __privateAdd(this, _ExecuteRunner2, async (workerEx, runnerEx) => {
2074
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ExecuteRunner, {
2075
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2076
+ });
2077
+ return true;
2078
+ });
2079
+ __privateAdd(this, _StopRunner2, async (workerEx, runnerEx) => {
2080
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StopRunner, {
2081
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2082
+ });
2083
+ return true;
2084
+ });
2085
+ __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx = null) => {
2086
+ if (runnerEx === null) {
2087
+ const ids = Object.keys(workerEx.runnersEx);
2088
+ if (ids.length > 0) {
2089
+ const id = ids[0];
2090
+ runnerEx = workerEx.runnersEx[id];
2091
+ }
2092
+ }
2093
+ if (runnerEx !== null) {
2094
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2095
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2096
+ });
2097
+ runnerEx.publishInstrumentController.LogEx(`Terminating runner: [${runnerEx.id}]`);
2098
+ const promArray = [];
2099
+ promArray.push((async () => {
2100
+ await Sleep(100);
2101
+ return runnerEx.publishInstrumentController.EndPublish();
2102
+ })());
2103
+ delete workerEx.runnersEx[runnerEx.id];
2104
+ const retVal = await Promise.all(promArray);
2105
+ console.log(`Removed instrument workers: [${retVal}]`);
2106
+ }
2107
+ return true;
2108
+ });
2109
+ __privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
2110
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
2111
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2112
+ });
2113
+ return true;
2114
+ });
2115
+ __privateAdd(this, _ResumeRunner2, async (workerEx, runnerEx) => {
2116
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResumeRunner, {
2117
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2118
+ });
2119
+ return true;
2120
+ });
2121
+ __privateAdd(this, _WorkerCommand, async (workerEx, command, options) => {
2122
+ try {
2123
+ if (workerEx.state !== IWorkerState.stopped) {
2124
+ console.log(`Stop Worker: [${workerEx.id}]`);
2125
+ const promArray = [];
2126
+ const ids = Object.keys(workerEx.runnersEx);
2127
+ ids.forEach((id) => {
2128
+ const runnerEx = workerEx.runnersEx[id];
2129
+ if (options) {
2130
+ promArray.push(command(workerEx, runnerEx, options));
2131
+ } else {
2132
+ promArray.push(command(workerEx, runnerEx));
2133
+ }
2134
+ });
2135
+ await Promise.all(promArray);
2136
+ }
2137
+ return true;
2138
+ } catch (error) {
2139
+ console.log(`Error in STSTestWorker:WorkerCommand: [${error}]`);
2140
+ return false;
2141
+ }
2142
+ });
2143
+ __privateAdd(this, _PauseWorker, async (workerEx) => {
2144
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _PauseRunner2));
2145
+ });
2146
+ __privateAdd(this, _ResumeWorker, async (workerEx) => {
2147
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _ResumeRunner2));
2148
+ });
2149
+ __privateAdd(this, _StopWorker, async (workerEx) => {
2150
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _StopRunner2));
2151
+ });
2152
+ __privateAdd(this, _StartWorker, async (workerEx) => {
2153
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _StartRunner2));
2154
+ });
2155
+ __privateAdd(this, _ResetWorker, async (workerEx) => {
2156
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _ResetRunner2));
2157
+ });
2158
+ __privateAdd(this, _ExecuteWorker, async (workerEx) => {
2159
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _ExecuteRunner2));
2160
+ });
2161
+ __privateAdd(this, _UpdateOptionsWorker, async (workerEx, options) => {
2162
+ return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _UpdateOptions2), options);
2163
+ });
2164
+ __privateAdd(this, _TerminateWorker, async (workerEx) => {
2165
+ try {
2166
+ if (workerEx.state !== IWorkerState.stopped) {
2167
+ await __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _TerminateRunner2));
2168
+ if (workerEx.worker) {
2169
+ workerEx.worker.terminate();
2170
+ __privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
2171
+ delete __privateGet(this, _workersEx)[workerEx.id];
2172
+ } else {
2173
+ }
2174
+ }
2175
+ return true;
2176
+ } catch (error) {
2177
+ console.log(`Error in STSTestWorker:TerminateWorker: [${error}]`);
2178
+ return false;
2179
+ }
2180
+ });
2181
+ __privateAdd(this, _UpdateOptions2, async (workerEx, runnerEx, options) => {
2182
+ runnerEx.options = { ...options };
2183
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.UpdateOptions, {
2184
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2185
+ });
2186
+ return true;
2187
+ });
2188
+ __publicField(this, "GetNextAvailableWorker", () => {
2189
+ let leastRunnerWorker = null;
2190
+ for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
2191
+ if (leastRunnerWorker) {
2192
+ if (Object.keys(stsWorker.runnersEx).length < Object.keys(leastRunnerWorker.runnersEx).length) {
2193
+ leastRunnerWorker = stsWorker;
2194
+ }
2195
+ } else {
2196
+ leastRunnerWorker = stsWorker;
2197
+ }
2198
+ }
2199
+ return leastRunnerWorker;
2200
+ });
2201
+ __publicField(this, "GetBusyWorker", () => {
2202
+ let busyWorker = null;
2203
+ for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
2204
+ if (busyWorker) {
2205
+ if (Object.keys(stsWorker.runnersEx).length > Object.keys(busyWorker.runnersEx).length) {
2206
+ busyWorker = stsWorker;
2207
+ }
2208
+ } else {
2209
+ busyWorker = stsWorker;
2210
+ }
2211
+ }
2212
+ return busyWorker;
2213
+ });
2214
+ __publicField(this, "StopAllWorkers", async () => {
2215
+ const promArray = [];
2216
+ for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
2217
+ promArray.push(stsWorker.Stop());
2218
+ }
2219
+ await Promise.all(promArray);
2220
+ });
2221
+ if (options) {
2222
+ __privateSet(this, _options2, options);
2223
+ } else {
2224
+ __privateSet(this, _options2, {});
2225
+ }
2226
+ __privateSet(this, _STSInstrumentController, __privateGet(this, _options2).publishInstrumentController);
2227
+ __privateSet(this, _telemetryProcessor, new TelemetryProcessor());
2228
+ }
2229
+ get WorkersEx() {
2230
+ return __privateGet(this, _workersEx);
2231
+ }
2232
+ get runnerId() {
2233
+ return __privateGet(this, _runner);
2234
+ }
2235
+ set runnerId(id) {
2236
+ __privateSet(this, _runner, id);
2237
+ }
2238
+ get Options() {
2239
+ return __privateGet(this, _options2);
2240
+ }
2241
+ set Options(options) {
2242
+ __privateSet(this, _options2, options);
2243
+ }
2244
+ }
2245
+ _workersEx = new WeakMap();
2246
+ _runner = new WeakMap();
2247
+ _workerId = new WeakMap();
2248
+ _options2 = new WeakMap();
2249
+ _STSInstrumentController = new WeakMap();
2250
+ _telemetryProcessor = new WeakMap();
2251
+ _debug2 = new WeakMap();
2252
+ _STSWorkerManager_instances = new WeakSet();
2253
+ CreateRunnerCopy_fn = function(runnerEx) {
2254
+ return {
2255
+ id: runnerEx.id,
2256
+ asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2257
+ options: { ...runnerEx.options },
2258
+ instrumentData: { ...runnerEx.instrumentData }
2259
+ };
2260
+ };
2261
+ _SetRunnerIntoWorker = new WeakMap();
2262
+ _ProcessTelemetry = new WeakMap();
2263
+ _ProcessCompleted = new WeakMap();
2264
+ _CreateAsyncRunner = new WeakMap();
2265
+ _PostMessageToWorker = new WeakMap();
2266
+ _StartRunner2 = new WeakMap();
2267
+ _ResetRunner2 = new WeakMap();
2268
+ _ExecuteRunner2 = new WeakMap();
2269
+ _StopRunner2 = new WeakMap();
2270
+ _TerminateRunner2 = new WeakMap();
2271
+ _PauseRunner2 = new WeakMap();
2272
+ _ResumeRunner2 = new WeakMap();
2273
+ _WorkerCommand = new WeakMap();
2274
+ _PauseWorker = new WeakMap();
2275
+ _ResumeWorker = new WeakMap();
2276
+ _StopWorker = new WeakMap();
2277
+ _StartWorker = new WeakMap();
2278
+ _ResetWorker = new WeakMap();
2279
+ _ExecuteWorker = new WeakMap();
2280
+ _UpdateOptionsWorker = new WeakMap();
2281
+ _TerminateWorker = new WeakMap();
2282
+ _UpdateOptions2 = new WeakMap();
41
2283
  export {
42
2284
  IRunnerState,
43
2285
  IWorkerState,
44
2286
  PublishMessageCommandsTestRunner,
2287
+ STSWorkerManager,
45
2288
  URI_BASE_VUEUTILS,
2289
+ WorkerInstance,
46
2290
  eIWMessageCommands
47
2291
  };
48
2292
  //# sourceMappingURL=stsrunnerframework.mjs.map