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