@nsshunt/stsvueutils 1.0.63 → 1.0.65
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/stsvueutils.mjs +1317 -1267
- package/dist/stsvueutils.mjs.map +1 -1
- package/dist/stsvueutils.umd.js +1347 -1297
- package/dist/stsvueutils.umd.js.map +1 -1
- package/package.json +11 -10
- package/types/plugins/stsTestWorkerDefinitions.d.ts +2 -0
- package/types/plugins/stsTestWorkerDefinitions.d.ts.map +1 -1
- package/types/plugins/workerManager.d.ts.map +1 -1
package/dist/stsvueutils.mjs
CHANGED
|
@@ -109,9 +109,9 @@ const STSEmitterPlugin = {
|
|
|
109
109
|
/*! js-cookie v3.0.5 | MIT */
|
|
110
110
|
function assign(target) {
|
|
111
111
|
for (var i = 1; i < arguments.length; i++) {
|
|
112
|
-
var
|
|
113
|
-
for (var key in
|
|
114
|
-
target[key] =
|
|
112
|
+
var source2 = arguments[i];
|
|
113
|
+
for (var key in source2) {
|
|
114
|
+
target[key] = source2[key];
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
return target;
|
|
@@ -409,1005 +409,1024 @@ var IWorkerState = /* @__PURE__ */ ((IWorkerState2) => {
|
|
|
409
409
|
IWorkerState2["stopped"] = "stopped";
|
|
410
410
|
return IWorkerState2;
|
|
411
411
|
})(IWorkerState || {});
|
|
412
|
-
var
|
|
413
|
-
var
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
var
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
412
|
+
var ansiStyles$1 = { exports: {} };
|
|
413
|
+
var colorName;
|
|
414
|
+
var hasRequiredColorName;
|
|
415
|
+
function requireColorName() {
|
|
416
|
+
if (hasRequiredColorName)
|
|
417
|
+
return colorName;
|
|
418
|
+
hasRequiredColorName = 1;
|
|
419
|
+
colorName = {
|
|
420
|
+
"aliceblue": [240, 248, 255],
|
|
421
|
+
"antiquewhite": [250, 235, 215],
|
|
422
|
+
"aqua": [0, 255, 255],
|
|
423
|
+
"aquamarine": [127, 255, 212],
|
|
424
|
+
"azure": [240, 255, 255],
|
|
425
|
+
"beige": [245, 245, 220],
|
|
426
|
+
"bisque": [255, 228, 196],
|
|
427
|
+
"black": [0, 0, 0],
|
|
428
|
+
"blanchedalmond": [255, 235, 205],
|
|
429
|
+
"blue": [0, 0, 255],
|
|
430
|
+
"blueviolet": [138, 43, 226],
|
|
431
|
+
"brown": [165, 42, 42],
|
|
432
|
+
"burlywood": [222, 184, 135],
|
|
433
|
+
"cadetblue": [95, 158, 160],
|
|
434
|
+
"chartreuse": [127, 255, 0],
|
|
435
|
+
"chocolate": [210, 105, 30],
|
|
436
|
+
"coral": [255, 127, 80],
|
|
437
|
+
"cornflowerblue": [100, 149, 237],
|
|
438
|
+
"cornsilk": [255, 248, 220],
|
|
439
|
+
"crimson": [220, 20, 60],
|
|
440
|
+
"cyan": [0, 255, 255],
|
|
441
|
+
"darkblue": [0, 0, 139],
|
|
442
|
+
"darkcyan": [0, 139, 139],
|
|
443
|
+
"darkgoldenrod": [184, 134, 11],
|
|
444
|
+
"darkgray": [169, 169, 169],
|
|
445
|
+
"darkgreen": [0, 100, 0],
|
|
446
|
+
"darkgrey": [169, 169, 169],
|
|
447
|
+
"darkkhaki": [189, 183, 107],
|
|
448
|
+
"darkmagenta": [139, 0, 139],
|
|
449
|
+
"darkolivegreen": [85, 107, 47],
|
|
450
|
+
"darkorange": [255, 140, 0],
|
|
451
|
+
"darkorchid": [153, 50, 204],
|
|
452
|
+
"darkred": [139, 0, 0],
|
|
453
|
+
"darksalmon": [233, 150, 122],
|
|
454
|
+
"darkseagreen": [143, 188, 143],
|
|
455
|
+
"darkslateblue": [72, 61, 139],
|
|
456
|
+
"darkslategray": [47, 79, 79],
|
|
457
|
+
"darkslategrey": [47, 79, 79],
|
|
458
|
+
"darkturquoise": [0, 206, 209],
|
|
459
|
+
"darkviolet": [148, 0, 211],
|
|
460
|
+
"deeppink": [255, 20, 147],
|
|
461
|
+
"deepskyblue": [0, 191, 255],
|
|
462
|
+
"dimgray": [105, 105, 105],
|
|
463
|
+
"dimgrey": [105, 105, 105],
|
|
464
|
+
"dodgerblue": [30, 144, 255],
|
|
465
|
+
"firebrick": [178, 34, 34],
|
|
466
|
+
"floralwhite": [255, 250, 240],
|
|
467
|
+
"forestgreen": [34, 139, 34],
|
|
468
|
+
"fuchsia": [255, 0, 255],
|
|
469
|
+
"gainsboro": [220, 220, 220],
|
|
470
|
+
"ghostwhite": [248, 248, 255],
|
|
471
|
+
"gold": [255, 215, 0],
|
|
472
|
+
"goldenrod": [218, 165, 32],
|
|
473
|
+
"gray": [128, 128, 128],
|
|
474
|
+
"green": [0, 128, 0],
|
|
475
|
+
"greenyellow": [173, 255, 47],
|
|
476
|
+
"grey": [128, 128, 128],
|
|
477
|
+
"honeydew": [240, 255, 240],
|
|
478
|
+
"hotpink": [255, 105, 180],
|
|
479
|
+
"indianred": [205, 92, 92],
|
|
480
|
+
"indigo": [75, 0, 130],
|
|
481
|
+
"ivory": [255, 255, 240],
|
|
482
|
+
"khaki": [240, 230, 140],
|
|
483
|
+
"lavender": [230, 230, 250],
|
|
484
|
+
"lavenderblush": [255, 240, 245],
|
|
485
|
+
"lawngreen": [124, 252, 0],
|
|
486
|
+
"lemonchiffon": [255, 250, 205],
|
|
487
|
+
"lightblue": [173, 216, 230],
|
|
488
|
+
"lightcoral": [240, 128, 128],
|
|
489
|
+
"lightcyan": [224, 255, 255],
|
|
490
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
491
|
+
"lightgray": [211, 211, 211],
|
|
492
|
+
"lightgreen": [144, 238, 144],
|
|
493
|
+
"lightgrey": [211, 211, 211],
|
|
494
|
+
"lightpink": [255, 182, 193],
|
|
495
|
+
"lightsalmon": [255, 160, 122],
|
|
496
|
+
"lightseagreen": [32, 178, 170],
|
|
497
|
+
"lightskyblue": [135, 206, 250],
|
|
498
|
+
"lightslategray": [119, 136, 153],
|
|
499
|
+
"lightslategrey": [119, 136, 153],
|
|
500
|
+
"lightsteelblue": [176, 196, 222],
|
|
501
|
+
"lightyellow": [255, 255, 224],
|
|
502
|
+
"lime": [0, 255, 0],
|
|
503
|
+
"limegreen": [50, 205, 50],
|
|
504
|
+
"linen": [250, 240, 230],
|
|
505
|
+
"magenta": [255, 0, 255],
|
|
506
|
+
"maroon": [128, 0, 0],
|
|
507
|
+
"mediumaquamarine": [102, 205, 170],
|
|
508
|
+
"mediumblue": [0, 0, 205],
|
|
509
|
+
"mediumorchid": [186, 85, 211],
|
|
510
|
+
"mediumpurple": [147, 112, 219],
|
|
511
|
+
"mediumseagreen": [60, 179, 113],
|
|
512
|
+
"mediumslateblue": [123, 104, 238],
|
|
513
|
+
"mediumspringgreen": [0, 250, 154],
|
|
514
|
+
"mediumturquoise": [72, 209, 204],
|
|
515
|
+
"mediumvioletred": [199, 21, 133],
|
|
516
|
+
"midnightblue": [25, 25, 112],
|
|
517
|
+
"mintcream": [245, 255, 250],
|
|
518
|
+
"mistyrose": [255, 228, 225],
|
|
519
|
+
"moccasin": [255, 228, 181],
|
|
520
|
+
"navajowhite": [255, 222, 173],
|
|
521
|
+
"navy": [0, 0, 128],
|
|
522
|
+
"oldlace": [253, 245, 230],
|
|
523
|
+
"olive": [128, 128, 0],
|
|
524
|
+
"olivedrab": [107, 142, 35],
|
|
525
|
+
"orange": [255, 165, 0],
|
|
526
|
+
"orangered": [255, 69, 0],
|
|
527
|
+
"orchid": [218, 112, 214],
|
|
528
|
+
"palegoldenrod": [238, 232, 170],
|
|
529
|
+
"palegreen": [152, 251, 152],
|
|
530
|
+
"paleturquoise": [175, 238, 238],
|
|
531
|
+
"palevioletred": [219, 112, 147],
|
|
532
|
+
"papayawhip": [255, 239, 213],
|
|
533
|
+
"peachpuff": [255, 218, 185],
|
|
534
|
+
"peru": [205, 133, 63],
|
|
535
|
+
"pink": [255, 192, 203],
|
|
536
|
+
"plum": [221, 160, 221],
|
|
537
|
+
"powderblue": [176, 224, 230],
|
|
538
|
+
"purple": [128, 0, 128],
|
|
539
|
+
"rebeccapurple": [102, 51, 153],
|
|
540
|
+
"red": [255, 0, 0],
|
|
541
|
+
"rosybrown": [188, 143, 143],
|
|
542
|
+
"royalblue": [65, 105, 225],
|
|
543
|
+
"saddlebrown": [139, 69, 19],
|
|
544
|
+
"salmon": [250, 128, 114],
|
|
545
|
+
"sandybrown": [244, 164, 96],
|
|
546
|
+
"seagreen": [46, 139, 87],
|
|
547
|
+
"seashell": [255, 245, 238],
|
|
548
|
+
"sienna": [160, 82, 45],
|
|
549
|
+
"silver": [192, 192, 192],
|
|
550
|
+
"skyblue": [135, 206, 235],
|
|
551
|
+
"slateblue": [106, 90, 205],
|
|
552
|
+
"slategray": [112, 128, 144],
|
|
553
|
+
"slategrey": [112, 128, 144],
|
|
554
|
+
"snow": [255, 250, 250],
|
|
555
|
+
"springgreen": [0, 255, 127],
|
|
556
|
+
"steelblue": [70, 130, 180],
|
|
557
|
+
"tan": [210, 180, 140],
|
|
558
|
+
"teal": [0, 128, 128],
|
|
559
|
+
"thistle": [216, 191, 216],
|
|
560
|
+
"tomato": [255, 99, 71],
|
|
561
|
+
"turquoise": [64, 224, 208],
|
|
562
|
+
"violet": [238, 130, 238],
|
|
563
|
+
"wheat": [245, 222, 179],
|
|
564
|
+
"white": [255, 255, 255],
|
|
565
|
+
"whitesmoke": [245, 245, 245],
|
|
566
|
+
"yellow": [255, 255, 0],
|
|
567
|
+
"yellowgreen": [154, 205, 50]
|
|
568
|
+
};
|
|
569
|
+
return colorName;
|
|
570
|
+
}
|
|
571
|
+
var conversions;
|
|
572
|
+
var hasRequiredConversions;
|
|
573
|
+
function requireConversions() {
|
|
574
|
+
if (hasRequiredConversions)
|
|
575
|
+
return conversions;
|
|
576
|
+
hasRequiredConversions = 1;
|
|
577
|
+
const cssKeywords = requireColorName();
|
|
578
|
+
const reverseKeywords = {};
|
|
579
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
576
580
|
reverseKeywords[cssKeywords[key]] = key;
|
|
577
581
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
for (
|
|
597
|
-
|
|
598
|
-
if (!("channels" in convert$1[model])) {
|
|
582
|
+
const convert = {
|
|
583
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
584
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
585
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
586
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
587
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
588
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
589
|
+
lab: { channels: 3, labels: "lab" },
|
|
590
|
+
lch: { channels: 3, labels: "lch" },
|
|
591
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
592
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
593
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
594
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
595
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
596
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
597
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
598
|
+
};
|
|
599
|
+
conversions = convert;
|
|
600
|
+
for (const model of Object.keys(convert)) {
|
|
601
|
+
if (!("channels" in convert[model])) {
|
|
599
602
|
throw new Error("missing channels property: " + model);
|
|
600
603
|
}
|
|
601
|
-
if (!("labels" in convert
|
|
604
|
+
if (!("labels" in convert[model])) {
|
|
602
605
|
throw new Error("missing channel labels property: " + model);
|
|
603
606
|
}
|
|
604
|
-
if (convert
|
|
607
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
605
608
|
throw new Error("channel and label counts mismatch: " + model);
|
|
606
609
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
delete convert
|
|
610
|
-
|
|
611
|
-
Object.defineProperty(convert
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
h = 2 + (b - r) / delta;
|
|
631
|
-
} else if (b === max) {
|
|
632
|
-
h = 4 + (r - g) / delta;
|
|
633
|
-
}
|
|
634
|
-
h = Math.min(h * 60, 360);
|
|
635
|
-
if (h < 0) {
|
|
636
|
-
h += 360;
|
|
637
|
-
}
|
|
638
|
-
l = (min + max) / 2;
|
|
639
|
-
if (max === min) {
|
|
640
|
-
s = 0;
|
|
641
|
-
} else if (l <= 0.5) {
|
|
642
|
-
s = delta / (max + min);
|
|
643
|
-
} else {
|
|
644
|
-
s = delta / (2 - max - min);
|
|
645
|
-
}
|
|
646
|
-
return [h, s * 100, l * 100];
|
|
647
|
-
};
|
|
648
|
-
convert$1.rgb.hsv = function(rgb) {
|
|
649
|
-
var rdif;
|
|
650
|
-
var gdif;
|
|
651
|
-
var bdif;
|
|
652
|
-
var h;
|
|
653
|
-
var s;
|
|
654
|
-
var r = rgb[0] / 255;
|
|
655
|
-
var g = rgb[1] / 255;
|
|
656
|
-
var b = rgb[2] / 255;
|
|
657
|
-
var v = Math.max(r, g, b);
|
|
658
|
-
var diff = v - Math.min(r, g, b);
|
|
659
|
-
var diffc = function(c) {
|
|
660
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
661
|
-
};
|
|
662
|
-
if (diff === 0) {
|
|
663
|
-
h = s = 0;
|
|
664
|
-
} else {
|
|
665
|
-
s = diff / v;
|
|
666
|
-
rdif = diffc(r);
|
|
667
|
-
gdif = diffc(g);
|
|
668
|
-
bdif = diffc(b);
|
|
669
|
-
if (r === v) {
|
|
670
|
-
h = bdif - gdif;
|
|
671
|
-
} else if (g === v) {
|
|
672
|
-
h = 1 / 3 + rdif - bdif;
|
|
673
|
-
} else if (b === v) {
|
|
674
|
-
h = 2 / 3 + gdif - rdif;
|
|
610
|
+
const { channels, labels } = convert[model];
|
|
611
|
+
delete convert[model].channels;
|
|
612
|
+
delete convert[model].labels;
|
|
613
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
614
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
615
|
+
}
|
|
616
|
+
convert.rgb.hsl = function(rgb) {
|
|
617
|
+
const r = rgb[0] / 255;
|
|
618
|
+
const g = rgb[1] / 255;
|
|
619
|
+
const b = rgb[2] / 255;
|
|
620
|
+
const min = Math.min(r, g, b);
|
|
621
|
+
const max = Math.max(r, g, b);
|
|
622
|
+
const delta = max - min;
|
|
623
|
+
let h;
|
|
624
|
+
let s;
|
|
625
|
+
if (max === min) {
|
|
626
|
+
h = 0;
|
|
627
|
+
} else if (r === max) {
|
|
628
|
+
h = (g - b) / delta;
|
|
629
|
+
} else if (g === max) {
|
|
630
|
+
h = 2 + (b - r) / delta;
|
|
631
|
+
} else if (b === max) {
|
|
632
|
+
h = 4 + (r - g) / delta;
|
|
675
633
|
}
|
|
634
|
+
h = Math.min(h * 60, 360);
|
|
676
635
|
if (h < 0) {
|
|
677
|
-
h +=
|
|
678
|
-
} else if (h > 1) {
|
|
679
|
-
h -= 1;
|
|
636
|
+
h += 360;
|
|
680
637
|
}
|
|
638
|
+
const l = (min + max) / 2;
|
|
639
|
+
if (max === min) {
|
|
640
|
+
s = 0;
|
|
641
|
+
} else if (l <= 0.5) {
|
|
642
|
+
s = delta / (max + min);
|
|
643
|
+
} else {
|
|
644
|
+
s = delta / (2 - max - min);
|
|
645
|
+
}
|
|
646
|
+
return [h, s * 100, l * 100];
|
|
647
|
+
};
|
|
648
|
+
convert.rgb.hsv = function(rgb) {
|
|
649
|
+
let rdif;
|
|
650
|
+
let gdif;
|
|
651
|
+
let bdif;
|
|
652
|
+
let h;
|
|
653
|
+
let s;
|
|
654
|
+
const r = rgb[0] / 255;
|
|
655
|
+
const g = rgb[1] / 255;
|
|
656
|
+
const b = rgb[2] / 255;
|
|
657
|
+
const v = Math.max(r, g, b);
|
|
658
|
+
const diff = v - Math.min(r, g, b);
|
|
659
|
+
const diffc = function(c) {
|
|
660
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
661
|
+
};
|
|
662
|
+
if (diff === 0) {
|
|
663
|
+
h = 0;
|
|
664
|
+
s = 0;
|
|
665
|
+
} else {
|
|
666
|
+
s = diff / v;
|
|
667
|
+
rdif = diffc(r);
|
|
668
|
+
gdif = diffc(g);
|
|
669
|
+
bdif = diffc(b);
|
|
670
|
+
if (r === v) {
|
|
671
|
+
h = bdif - gdif;
|
|
672
|
+
} else if (g === v) {
|
|
673
|
+
h = 1 / 3 + rdif - bdif;
|
|
674
|
+
} else if (b === v) {
|
|
675
|
+
h = 2 / 3 + gdif - rdif;
|
|
676
|
+
}
|
|
677
|
+
if (h < 0) {
|
|
678
|
+
h += 1;
|
|
679
|
+
} else if (h > 1) {
|
|
680
|
+
h -= 1;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return [
|
|
684
|
+
h * 360,
|
|
685
|
+
s * 100,
|
|
686
|
+
v * 100
|
|
687
|
+
];
|
|
688
|
+
};
|
|
689
|
+
convert.rgb.hwb = function(rgb) {
|
|
690
|
+
const r = rgb[0];
|
|
691
|
+
const g = rgb[1];
|
|
692
|
+
let b = rgb[2];
|
|
693
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
694
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
695
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
696
|
+
return [h, w * 100, b * 100];
|
|
697
|
+
};
|
|
698
|
+
convert.rgb.cmyk = function(rgb) {
|
|
699
|
+
const r = rgb[0] / 255;
|
|
700
|
+
const g = rgb[1] / 255;
|
|
701
|
+
const b = rgb[2] / 255;
|
|
702
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
703
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
704
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
705
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
706
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
707
|
+
};
|
|
708
|
+
function comparativeDistance(x, y) {
|
|
709
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
681
710
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
var h = convert$1.rgb.hsl(rgb)[0];
|
|
693
|
-
var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
694
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
695
|
-
return [h, w * 100, b * 100];
|
|
696
|
-
};
|
|
697
|
-
convert$1.rgb.cmyk = function(rgb) {
|
|
698
|
-
var r = rgb[0] / 255;
|
|
699
|
-
var g = rgb[1] / 255;
|
|
700
|
-
var b = rgb[2] / 255;
|
|
701
|
-
var c;
|
|
702
|
-
var m;
|
|
703
|
-
var y;
|
|
704
|
-
var k;
|
|
705
|
-
k = Math.min(1 - r, 1 - g, 1 - b);
|
|
706
|
-
c = (1 - r - k) / (1 - k) || 0;
|
|
707
|
-
m = (1 - g - k) / (1 - k) || 0;
|
|
708
|
-
y = (1 - b - k) / (1 - k) || 0;
|
|
709
|
-
return [c * 100, m * 100, y * 100, k * 100];
|
|
710
|
-
};
|
|
711
|
-
function comparativeDistance(x, y) {
|
|
712
|
-
return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
|
|
713
|
-
}
|
|
714
|
-
convert$1.rgb.keyword = function(rgb) {
|
|
715
|
-
var reversed = reverseKeywords[rgb];
|
|
716
|
-
if (reversed) {
|
|
717
|
-
return reversed;
|
|
718
|
-
}
|
|
719
|
-
var currentClosestDistance = Infinity;
|
|
720
|
-
var currentClosestKeyword;
|
|
721
|
-
for (var keyword in cssKeywords) {
|
|
722
|
-
if (cssKeywords.hasOwnProperty(keyword)) {
|
|
723
|
-
var value = cssKeywords[keyword];
|
|
724
|
-
var distance = comparativeDistance(rgb, value);
|
|
711
|
+
convert.rgb.keyword = function(rgb) {
|
|
712
|
+
const reversed = reverseKeywords[rgb];
|
|
713
|
+
if (reversed) {
|
|
714
|
+
return reversed;
|
|
715
|
+
}
|
|
716
|
+
let currentClosestDistance = Infinity;
|
|
717
|
+
let currentClosestKeyword;
|
|
718
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
719
|
+
const value = cssKeywords[keyword];
|
|
720
|
+
const distance = comparativeDistance(rgb, value);
|
|
725
721
|
if (distance < currentClosestDistance) {
|
|
726
722
|
currentClosestDistance = distance;
|
|
727
723
|
currentClosestKeyword = keyword;
|
|
728
724
|
}
|
|
729
725
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
convert
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
if (s === 0) {
|
|
777
|
-
val = l * 255;
|
|
778
|
-
return [val, val, val];
|
|
779
|
-
}
|
|
780
|
-
if (l < 0.5) {
|
|
781
|
-
t2 = l * (1 + s);
|
|
782
|
-
} else {
|
|
783
|
-
t2 = l + s - l * s;
|
|
784
|
-
}
|
|
785
|
-
t1 = 2 * l - t2;
|
|
786
|
-
rgb = [0, 0, 0];
|
|
787
|
-
for (var i = 0; i < 3; i++) {
|
|
788
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
789
|
-
if (t3 < 0) {
|
|
790
|
-
t3++;
|
|
791
|
-
}
|
|
792
|
-
if (t3 > 1) {
|
|
793
|
-
t3--;
|
|
794
|
-
}
|
|
795
|
-
if (6 * t3 < 1) {
|
|
796
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
797
|
-
} else if (2 * t3 < 1) {
|
|
798
|
-
val = t2;
|
|
799
|
-
} else if (3 * t3 < 2) {
|
|
800
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
726
|
+
return currentClosestKeyword;
|
|
727
|
+
};
|
|
728
|
+
convert.keyword.rgb = function(keyword) {
|
|
729
|
+
return cssKeywords[keyword];
|
|
730
|
+
};
|
|
731
|
+
convert.rgb.xyz = function(rgb) {
|
|
732
|
+
let r = rgb[0] / 255;
|
|
733
|
+
let g = rgb[1] / 255;
|
|
734
|
+
let b = rgb[2] / 255;
|
|
735
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
736
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
737
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
738
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
739
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
740
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
741
|
+
return [x * 100, y * 100, z * 100];
|
|
742
|
+
};
|
|
743
|
+
convert.rgb.lab = function(rgb) {
|
|
744
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
745
|
+
let x = xyz[0];
|
|
746
|
+
let y = xyz[1];
|
|
747
|
+
let z = xyz[2];
|
|
748
|
+
x /= 95.047;
|
|
749
|
+
y /= 100;
|
|
750
|
+
z /= 108.883;
|
|
751
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
752
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
753
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
754
|
+
const l = 116 * y - 16;
|
|
755
|
+
const a = 500 * (x - y);
|
|
756
|
+
const b = 200 * (y - z);
|
|
757
|
+
return [l, a, b];
|
|
758
|
+
};
|
|
759
|
+
convert.hsl.rgb = function(hsl) {
|
|
760
|
+
const h = hsl[0] / 360;
|
|
761
|
+
const s = hsl[1] / 100;
|
|
762
|
+
const l = hsl[2] / 100;
|
|
763
|
+
let t2;
|
|
764
|
+
let t3;
|
|
765
|
+
let val;
|
|
766
|
+
if (s === 0) {
|
|
767
|
+
val = l * 255;
|
|
768
|
+
return [val, val, val];
|
|
769
|
+
}
|
|
770
|
+
if (l < 0.5) {
|
|
771
|
+
t2 = l * (1 + s);
|
|
801
772
|
} else {
|
|
802
|
-
|
|
773
|
+
t2 = l + s - l * s;
|
|
803
774
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
var lmin = Math.max(l, 0.01);
|
|
814
|
-
var sv;
|
|
815
|
-
var v;
|
|
816
|
-
l *= 2;
|
|
817
|
-
s *= l <= 1 ? l : 2 - l;
|
|
818
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
819
|
-
v = (l + s) / 2;
|
|
820
|
-
sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
821
|
-
return [h, sv * 100, v * 100];
|
|
822
|
-
};
|
|
823
|
-
convert$1.hsv.rgb = function(hsv) {
|
|
824
|
-
var h = hsv[0] / 60;
|
|
825
|
-
var s = hsv[1] / 100;
|
|
826
|
-
var v = hsv[2] / 100;
|
|
827
|
-
var hi = Math.floor(h) % 6;
|
|
828
|
-
var f = h - Math.floor(h);
|
|
829
|
-
var p = 255 * v * (1 - s);
|
|
830
|
-
var q = 255 * v * (1 - s * f);
|
|
831
|
-
var t = 255 * v * (1 - s * (1 - f));
|
|
832
|
-
v *= 255;
|
|
833
|
-
switch (hi) {
|
|
834
|
-
case 0:
|
|
835
|
-
return [v, t, p];
|
|
836
|
-
case 1:
|
|
837
|
-
return [q, v, p];
|
|
838
|
-
case 2:
|
|
839
|
-
return [p, v, t];
|
|
840
|
-
case 3:
|
|
841
|
-
return [p, q, v];
|
|
842
|
-
case 4:
|
|
843
|
-
return [t, p, v];
|
|
844
|
-
case 5:
|
|
845
|
-
return [v, p, q];
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
convert$1.hsv.hsl = function(hsv) {
|
|
849
|
-
var h = hsv[0];
|
|
850
|
-
var s = hsv[1] / 100;
|
|
851
|
-
var v = hsv[2] / 100;
|
|
852
|
-
var vmin = Math.max(v, 0.01);
|
|
853
|
-
var lmin;
|
|
854
|
-
var sl;
|
|
855
|
-
var l;
|
|
856
|
-
l = (2 - s) * v;
|
|
857
|
-
lmin = (2 - s) * vmin;
|
|
858
|
-
sl = s * vmin;
|
|
859
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
860
|
-
sl = sl || 0;
|
|
861
|
-
l /= 2;
|
|
862
|
-
return [h, sl * 100, l * 100];
|
|
863
|
-
};
|
|
864
|
-
convert$1.hwb.rgb = function(hwb) {
|
|
865
|
-
var h = hwb[0] / 360;
|
|
866
|
-
var wh = hwb[1] / 100;
|
|
867
|
-
var bl = hwb[2] / 100;
|
|
868
|
-
var ratio = wh + bl;
|
|
869
|
-
var i;
|
|
870
|
-
var v;
|
|
871
|
-
var f;
|
|
872
|
-
var n;
|
|
873
|
-
if (ratio > 1) {
|
|
874
|
-
wh /= ratio;
|
|
875
|
-
bl /= ratio;
|
|
876
|
-
}
|
|
877
|
-
i = Math.floor(6 * h);
|
|
878
|
-
v = 1 - bl;
|
|
879
|
-
f = 6 * h - i;
|
|
880
|
-
if ((i & 1) !== 0) {
|
|
881
|
-
f = 1 - f;
|
|
882
|
-
}
|
|
883
|
-
n = wh + f * (v - wh);
|
|
884
|
-
var r;
|
|
885
|
-
var g;
|
|
886
|
-
var b;
|
|
887
|
-
switch (i) {
|
|
888
|
-
default:
|
|
889
|
-
case 6:
|
|
890
|
-
case 0:
|
|
891
|
-
r = v;
|
|
892
|
-
g = n;
|
|
893
|
-
b = wh;
|
|
894
|
-
break;
|
|
895
|
-
case 1:
|
|
896
|
-
r = n;
|
|
897
|
-
g = v;
|
|
898
|
-
b = wh;
|
|
899
|
-
break;
|
|
900
|
-
case 2:
|
|
901
|
-
r = wh;
|
|
902
|
-
g = v;
|
|
903
|
-
b = n;
|
|
904
|
-
break;
|
|
905
|
-
case 3:
|
|
906
|
-
r = wh;
|
|
907
|
-
g = n;
|
|
908
|
-
b = v;
|
|
909
|
-
break;
|
|
910
|
-
case 4:
|
|
911
|
-
r = n;
|
|
912
|
-
g = wh;
|
|
913
|
-
b = v;
|
|
914
|
-
break;
|
|
915
|
-
case 5:
|
|
916
|
-
r = v;
|
|
917
|
-
g = wh;
|
|
918
|
-
b = n;
|
|
919
|
-
break;
|
|
920
|
-
}
|
|
921
|
-
return [r * 255, g * 255, b * 255];
|
|
922
|
-
};
|
|
923
|
-
convert$1.cmyk.rgb = function(cmyk) {
|
|
924
|
-
var c = cmyk[0] / 100;
|
|
925
|
-
var m = cmyk[1] / 100;
|
|
926
|
-
var y = cmyk[2] / 100;
|
|
927
|
-
var k = cmyk[3] / 100;
|
|
928
|
-
var r;
|
|
929
|
-
var g;
|
|
930
|
-
var b;
|
|
931
|
-
r = 1 - Math.min(1, c * (1 - k) + k);
|
|
932
|
-
g = 1 - Math.min(1, m * (1 - k) + k);
|
|
933
|
-
b = 1 - Math.min(1, y * (1 - k) + k);
|
|
934
|
-
return [r * 255, g * 255, b * 255];
|
|
935
|
-
};
|
|
936
|
-
convert$1.xyz.rgb = function(xyz) {
|
|
937
|
-
var x = xyz[0] / 100;
|
|
938
|
-
var y = xyz[1] / 100;
|
|
939
|
-
var z = xyz[2] / 100;
|
|
940
|
-
var r;
|
|
941
|
-
var g;
|
|
942
|
-
var b;
|
|
943
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
944
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
945
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
946
|
-
r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : r * 12.92;
|
|
947
|
-
g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : g * 12.92;
|
|
948
|
-
b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : b * 12.92;
|
|
949
|
-
r = Math.min(Math.max(0, r), 1);
|
|
950
|
-
g = Math.min(Math.max(0, g), 1);
|
|
951
|
-
b = Math.min(Math.max(0, b), 1);
|
|
952
|
-
return [r * 255, g * 255, b * 255];
|
|
953
|
-
};
|
|
954
|
-
convert$1.xyz.lab = function(xyz) {
|
|
955
|
-
var x = xyz[0];
|
|
956
|
-
var y = xyz[1];
|
|
957
|
-
var z = xyz[2];
|
|
958
|
-
var l;
|
|
959
|
-
var a;
|
|
960
|
-
var b;
|
|
961
|
-
x /= 95.047;
|
|
962
|
-
y /= 100;
|
|
963
|
-
z /= 108.883;
|
|
964
|
-
x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
965
|
-
y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
966
|
-
z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
967
|
-
l = 116 * y - 16;
|
|
968
|
-
a = 500 * (x - y);
|
|
969
|
-
b = 200 * (y - z);
|
|
970
|
-
return [l, a, b];
|
|
971
|
-
};
|
|
972
|
-
convert$1.lab.xyz = function(lab) {
|
|
973
|
-
var l = lab[0];
|
|
974
|
-
var a = lab[1];
|
|
975
|
-
var b = lab[2];
|
|
976
|
-
var x;
|
|
977
|
-
var y;
|
|
978
|
-
var z;
|
|
979
|
-
y = (l + 16) / 116;
|
|
980
|
-
x = a / 500 + y;
|
|
981
|
-
z = y - b / 200;
|
|
982
|
-
var y2 = Math.pow(y, 3);
|
|
983
|
-
var x2 = Math.pow(x, 3);
|
|
984
|
-
var z2 = Math.pow(z, 3);
|
|
985
|
-
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
986
|
-
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
987
|
-
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
988
|
-
x *= 95.047;
|
|
989
|
-
y *= 100;
|
|
990
|
-
z *= 108.883;
|
|
991
|
-
return [x, y, z];
|
|
992
|
-
};
|
|
993
|
-
convert$1.lab.lch = function(lab) {
|
|
994
|
-
var l = lab[0];
|
|
995
|
-
var a = lab[1];
|
|
996
|
-
var b = lab[2];
|
|
997
|
-
var hr;
|
|
998
|
-
var h;
|
|
999
|
-
var c;
|
|
1000
|
-
hr = Math.atan2(b, a);
|
|
1001
|
-
h = hr * 360 / 2 / Math.PI;
|
|
1002
|
-
if (h < 0) {
|
|
1003
|
-
h += 360;
|
|
1004
|
-
}
|
|
1005
|
-
c = Math.sqrt(a * a + b * b);
|
|
1006
|
-
return [l, c, h];
|
|
1007
|
-
};
|
|
1008
|
-
convert$1.lch.lab = function(lch) {
|
|
1009
|
-
var l = lch[0];
|
|
1010
|
-
var c = lch[1];
|
|
1011
|
-
var h = lch[2];
|
|
1012
|
-
var a;
|
|
1013
|
-
var b;
|
|
1014
|
-
var hr;
|
|
1015
|
-
hr = h / 360 * 2 * Math.PI;
|
|
1016
|
-
a = c * Math.cos(hr);
|
|
1017
|
-
b = c * Math.sin(hr);
|
|
1018
|
-
return [l, a, b];
|
|
1019
|
-
};
|
|
1020
|
-
convert$1.rgb.ansi16 = function(args) {
|
|
1021
|
-
var r = args[0];
|
|
1022
|
-
var g = args[1];
|
|
1023
|
-
var b = args[2];
|
|
1024
|
-
var value = 1 in arguments ? arguments[1] : convert$1.rgb.hsv(args)[2];
|
|
1025
|
-
value = Math.round(value / 50);
|
|
1026
|
-
if (value === 0) {
|
|
1027
|
-
return 30;
|
|
1028
|
-
}
|
|
1029
|
-
var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
1030
|
-
if (value === 2) {
|
|
1031
|
-
ansi += 60;
|
|
1032
|
-
}
|
|
1033
|
-
return ansi;
|
|
1034
|
-
};
|
|
1035
|
-
convert$1.hsv.ansi16 = function(args) {
|
|
1036
|
-
return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
|
|
1037
|
-
};
|
|
1038
|
-
convert$1.rgb.ansi256 = function(args) {
|
|
1039
|
-
var r = args[0];
|
|
1040
|
-
var g = args[1];
|
|
1041
|
-
var b = args[2];
|
|
1042
|
-
if (r === g && g === b) {
|
|
1043
|
-
if (r < 8) {
|
|
1044
|
-
return 16;
|
|
1045
|
-
}
|
|
1046
|
-
if (r > 248) {
|
|
1047
|
-
return 231;
|
|
1048
|
-
}
|
|
1049
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
1050
|
-
}
|
|
1051
|
-
var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
1052
|
-
return ansi;
|
|
1053
|
-
};
|
|
1054
|
-
convert$1.ansi16.rgb = function(args) {
|
|
1055
|
-
var color = args % 10;
|
|
1056
|
-
if (color === 0 || color === 7) {
|
|
1057
|
-
if (args > 50) {
|
|
1058
|
-
color += 3.5;
|
|
1059
|
-
}
|
|
1060
|
-
color = color / 10.5 * 255;
|
|
1061
|
-
return [color, color, color];
|
|
1062
|
-
}
|
|
1063
|
-
var mult = (~~(args > 50) + 1) * 0.5;
|
|
1064
|
-
var r = (color & 1) * mult * 255;
|
|
1065
|
-
var g = (color >> 1 & 1) * mult * 255;
|
|
1066
|
-
var b = (color >> 2 & 1) * mult * 255;
|
|
1067
|
-
return [r, g, b];
|
|
1068
|
-
};
|
|
1069
|
-
convert$1.ansi256.rgb = function(args) {
|
|
1070
|
-
if (args >= 232) {
|
|
1071
|
-
var c = (args - 232) * 10 + 8;
|
|
1072
|
-
return [c, c, c];
|
|
1073
|
-
}
|
|
1074
|
-
args -= 16;
|
|
1075
|
-
var rem;
|
|
1076
|
-
var r = Math.floor(args / 36) / 5 * 255;
|
|
1077
|
-
var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
1078
|
-
var b = rem % 6 / 5 * 255;
|
|
1079
|
-
return [r, g, b];
|
|
1080
|
-
};
|
|
1081
|
-
convert$1.rgb.hex = function(args) {
|
|
1082
|
-
var integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
1083
|
-
var string = integer.toString(16).toUpperCase();
|
|
1084
|
-
return "000000".substring(string.length) + string;
|
|
1085
|
-
};
|
|
1086
|
-
convert$1.hex.rgb = function(args) {
|
|
1087
|
-
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
1088
|
-
if (!match) {
|
|
1089
|
-
return [0, 0, 0];
|
|
1090
|
-
}
|
|
1091
|
-
var colorString = match[0];
|
|
1092
|
-
if (match[0].length === 3) {
|
|
1093
|
-
colorString = colorString.split("").map(function(char) {
|
|
1094
|
-
return char + char;
|
|
1095
|
-
}).join("");
|
|
1096
|
-
}
|
|
1097
|
-
var integer = parseInt(colorString, 16);
|
|
1098
|
-
var r = integer >> 16 & 255;
|
|
1099
|
-
var g = integer >> 8 & 255;
|
|
1100
|
-
var b = integer & 255;
|
|
1101
|
-
return [r, g, b];
|
|
1102
|
-
};
|
|
1103
|
-
convert$1.rgb.hcg = function(rgb) {
|
|
1104
|
-
var r = rgb[0] / 255;
|
|
1105
|
-
var g = rgb[1] / 255;
|
|
1106
|
-
var b = rgb[2] / 255;
|
|
1107
|
-
var max = Math.max(Math.max(r, g), b);
|
|
1108
|
-
var min = Math.min(Math.min(r, g), b);
|
|
1109
|
-
var chroma = max - min;
|
|
1110
|
-
var grayscale;
|
|
1111
|
-
var hue;
|
|
1112
|
-
if (chroma < 1) {
|
|
1113
|
-
grayscale = min / (1 - chroma);
|
|
1114
|
-
} else {
|
|
1115
|
-
grayscale = 0;
|
|
1116
|
-
}
|
|
1117
|
-
if (chroma <= 0) {
|
|
1118
|
-
hue = 0;
|
|
1119
|
-
} else if (max === r) {
|
|
1120
|
-
hue = (g - b) / chroma % 6;
|
|
1121
|
-
} else if (max === g) {
|
|
1122
|
-
hue = 2 + (b - r) / chroma;
|
|
1123
|
-
} else {
|
|
1124
|
-
hue = 4 + (r - g) / chroma + 4;
|
|
1125
|
-
}
|
|
1126
|
-
hue /= 6;
|
|
1127
|
-
hue %= 1;
|
|
1128
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
1129
|
-
};
|
|
1130
|
-
convert$1.hsl.hcg = function(hsl) {
|
|
1131
|
-
var s = hsl[1] / 100;
|
|
1132
|
-
var l = hsl[2] / 100;
|
|
1133
|
-
var c = 1;
|
|
1134
|
-
var f = 0;
|
|
1135
|
-
if (l < 0.5) {
|
|
1136
|
-
c = 2 * s * l;
|
|
1137
|
-
} else {
|
|
1138
|
-
c = 2 * s * (1 - l);
|
|
1139
|
-
}
|
|
1140
|
-
if (c < 1) {
|
|
1141
|
-
f = (l - 0.5 * c) / (1 - c);
|
|
1142
|
-
}
|
|
1143
|
-
return [hsl[0], c * 100, f * 100];
|
|
1144
|
-
};
|
|
1145
|
-
convert$1.hsv.hcg = function(hsv) {
|
|
1146
|
-
var s = hsv[1] / 100;
|
|
1147
|
-
var v = hsv[2] / 100;
|
|
1148
|
-
var c = s * v;
|
|
1149
|
-
var f = 0;
|
|
1150
|
-
if (c < 1) {
|
|
1151
|
-
f = (v - c) / (1 - c);
|
|
1152
|
-
}
|
|
1153
|
-
return [hsv[0], c * 100, f * 100];
|
|
1154
|
-
};
|
|
1155
|
-
convert$1.hcg.rgb = function(hcg) {
|
|
1156
|
-
var h = hcg[0] / 360;
|
|
1157
|
-
var c = hcg[1] / 100;
|
|
1158
|
-
var g = hcg[2] / 100;
|
|
1159
|
-
if (c === 0) {
|
|
1160
|
-
return [g * 255, g * 255, g * 255];
|
|
1161
|
-
}
|
|
1162
|
-
var pure = [0, 0, 0];
|
|
1163
|
-
var hi = h % 1 * 6;
|
|
1164
|
-
var v = hi % 1;
|
|
1165
|
-
var w = 1 - v;
|
|
1166
|
-
var mg = 0;
|
|
1167
|
-
switch (Math.floor(hi)) {
|
|
1168
|
-
case 0:
|
|
1169
|
-
pure[0] = 1;
|
|
1170
|
-
pure[1] = v;
|
|
1171
|
-
pure[2] = 0;
|
|
1172
|
-
break;
|
|
1173
|
-
case 1:
|
|
1174
|
-
pure[0] = w;
|
|
1175
|
-
pure[1] = 1;
|
|
1176
|
-
pure[2] = 0;
|
|
1177
|
-
break;
|
|
1178
|
-
case 2:
|
|
1179
|
-
pure[0] = 0;
|
|
1180
|
-
pure[1] = 1;
|
|
1181
|
-
pure[2] = v;
|
|
1182
|
-
break;
|
|
1183
|
-
case 3:
|
|
1184
|
-
pure[0] = 0;
|
|
1185
|
-
pure[1] = w;
|
|
1186
|
-
pure[2] = 1;
|
|
1187
|
-
break;
|
|
1188
|
-
case 4:
|
|
1189
|
-
pure[0] = v;
|
|
1190
|
-
pure[1] = 0;
|
|
1191
|
-
pure[2] = 1;
|
|
1192
|
-
break;
|
|
1193
|
-
default:
|
|
1194
|
-
pure[0] = 1;
|
|
1195
|
-
pure[1] = 0;
|
|
1196
|
-
pure[2] = w;
|
|
1197
|
-
}
|
|
1198
|
-
mg = (1 - c) * g;
|
|
1199
|
-
return [
|
|
1200
|
-
(c * pure[0] + mg) * 255,
|
|
1201
|
-
(c * pure[1] + mg) * 255,
|
|
1202
|
-
(c * pure[2] + mg) * 255
|
|
1203
|
-
];
|
|
1204
|
-
};
|
|
1205
|
-
convert$1.hcg.hsv = function(hcg) {
|
|
1206
|
-
var c = hcg[1] / 100;
|
|
1207
|
-
var g = hcg[2] / 100;
|
|
1208
|
-
var v = c + g * (1 - c);
|
|
1209
|
-
var f = 0;
|
|
1210
|
-
if (v > 0) {
|
|
1211
|
-
f = c / v;
|
|
1212
|
-
}
|
|
1213
|
-
return [hcg[0], f * 100, v * 100];
|
|
1214
|
-
};
|
|
1215
|
-
convert$1.hcg.hsl = function(hcg) {
|
|
1216
|
-
var c = hcg[1] / 100;
|
|
1217
|
-
var g = hcg[2] / 100;
|
|
1218
|
-
var l = g * (1 - c) + 0.5 * c;
|
|
1219
|
-
var s = 0;
|
|
1220
|
-
if (l > 0 && l < 0.5) {
|
|
1221
|
-
s = c / (2 * l);
|
|
1222
|
-
} else if (l >= 0.5 && l < 1) {
|
|
1223
|
-
s = c / (2 * (1 - l));
|
|
1224
|
-
}
|
|
1225
|
-
return [hcg[0], s * 100, l * 100];
|
|
1226
|
-
};
|
|
1227
|
-
convert$1.hcg.hwb = function(hcg) {
|
|
1228
|
-
var c = hcg[1] / 100;
|
|
1229
|
-
var g = hcg[2] / 100;
|
|
1230
|
-
var v = c + g * (1 - c);
|
|
1231
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
1232
|
-
};
|
|
1233
|
-
convert$1.hwb.hcg = function(hwb) {
|
|
1234
|
-
var w = hwb[1] / 100;
|
|
1235
|
-
var b = hwb[2] / 100;
|
|
1236
|
-
var v = 1 - b;
|
|
1237
|
-
var c = v - w;
|
|
1238
|
-
var g = 0;
|
|
1239
|
-
if (c < 1) {
|
|
1240
|
-
g = (v - c) / (1 - c);
|
|
1241
|
-
}
|
|
1242
|
-
return [hwb[0], c * 100, g * 100];
|
|
1243
|
-
};
|
|
1244
|
-
convert$1.apple.rgb = function(apple) {
|
|
1245
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
1246
|
-
};
|
|
1247
|
-
convert$1.rgb.apple = function(rgb) {
|
|
1248
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
1249
|
-
};
|
|
1250
|
-
convert$1.gray.rgb = function(args) {
|
|
1251
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
1252
|
-
};
|
|
1253
|
-
convert$1.gray.hsl = convert$1.gray.hsv = function(args) {
|
|
1254
|
-
return [0, 0, args[0]];
|
|
1255
|
-
};
|
|
1256
|
-
convert$1.gray.hwb = function(gray) {
|
|
1257
|
-
return [0, 100, gray[0]];
|
|
1258
|
-
};
|
|
1259
|
-
convert$1.gray.cmyk = function(gray) {
|
|
1260
|
-
return [0, 0, 0, gray[0]];
|
|
1261
|
-
};
|
|
1262
|
-
convert$1.gray.lab = function(gray) {
|
|
1263
|
-
return [gray[0], 0, 0];
|
|
1264
|
-
};
|
|
1265
|
-
convert$1.gray.hex = function(gray) {
|
|
1266
|
-
var val = Math.round(gray[0] / 100 * 255) & 255;
|
|
1267
|
-
var integer = (val << 16) + (val << 8) + val;
|
|
1268
|
-
var string = integer.toString(16).toUpperCase();
|
|
1269
|
-
return "000000".substring(string.length) + string;
|
|
1270
|
-
};
|
|
1271
|
-
convert$1.rgb.gray = function(rgb) {
|
|
1272
|
-
var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
1273
|
-
return [val / 255 * 100];
|
|
1274
|
-
};
|
|
1275
|
-
var conversionsExports = conversions$2.exports;
|
|
1276
|
-
var conversions$1 = conversionsExports;
|
|
1277
|
-
function buildGraph() {
|
|
1278
|
-
var graph = {};
|
|
1279
|
-
var models2 = Object.keys(conversions$1);
|
|
1280
|
-
for (var len = models2.length, i = 0; i < len; i++) {
|
|
1281
|
-
graph[models2[i]] = {
|
|
1282
|
-
// http://jsperf.com/1-vs-infinity
|
|
1283
|
-
// micro-opt, but this is simple.
|
|
1284
|
-
distance: -1,
|
|
1285
|
-
parent: null
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
return graph;
|
|
1289
|
-
}
|
|
1290
|
-
function deriveBFS(fromModel) {
|
|
1291
|
-
var graph = buildGraph();
|
|
1292
|
-
var queue = [fromModel];
|
|
1293
|
-
graph[fromModel].distance = 0;
|
|
1294
|
-
while (queue.length) {
|
|
1295
|
-
var current = queue.pop();
|
|
1296
|
-
var adjacents = Object.keys(conversions$1[current]);
|
|
1297
|
-
for (var len = adjacents.length, i = 0; i < len; i++) {
|
|
1298
|
-
var adjacent = adjacents[i];
|
|
1299
|
-
var node = graph[adjacent];
|
|
1300
|
-
if (node.distance === -1) {
|
|
1301
|
-
node.distance = graph[current].distance + 1;
|
|
1302
|
-
node.parent = current;
|
|
1303
|
-
queue.unshift(adjacent);
|
|
775
|
+
const t1 = 2 * l - t2;
|
|
776
|
+
const rgb = [0, 0, 0];
|
|
777
|
+
for (let i = 0; i < 3; i++) {
|
|
778
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
779
|
+
if (t3 < 0) {
|
|
780
|
+
t3++;
|
|
781
|
+
}
|
|
782
|
+
if (t3 > 1) {
|
|
783
|
+
t3--;
|
|
1304
784
|
}
|
|
785
|
+
if (6 * t3 < 1) {
|
|
786
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
787
|
+
} else if (2 * t3 < 1) {
|
|
788
|
+
val = t2;
|
|
789
|
+
} else if (3 * t3 < 2) {
|
|
790
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
791
|
+
} else {
|
|
792
|
+
val = t1;
|
|
793
|
+
}
|
|
794
|
+
rgb[i] = val * 255;
|
|
1305
795
|
}
|
|
1306
|
-
|
|
1307
|
-
return graph;
|
|
1308
|
-
}
|
|
1309
|
-
function link(from, to) {
|
|
1310
|
-
return function(args) {
|
|
1311
|
-
return to(from(args));
|
|
796
|
+
return rgb;
|
|
1312
797
|
};
|
|
798
|
+
convert.hsl.hsv = function(hsl) {
|
|
799
|
+
const h = hsl[0];
|
|
800
|
+
let s = hsl[1] / 100;
|
|
801
|
+
let l = hsl[2] / 100;
|
|
802
|
+
let smin = s;
|
|
803
|
+
const lmin = Math.max(l, 0.01);
|
|
804
|
+
l *= 2;
|
|
805
|
+
s *= l <= 1 ? l : 2 - l;
|
|
806
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
807
|
+
const v = (l + s) / 2;
|
|
808
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
809
|
+
return [h, sv * 100, v * 100];
|
|
810
|
+
};
|
|
811
|
+
convert.hsv.rgb = function(hsv) {
|
|
812
|
+
const h = hsv[0] / 60;
|
|
813
|
+
const s = hsv[1] / 100;
|
|
814
|
+
let v = hsv[2] / 100;
|
|
815
|
+
const hi = Math.floor(h) % 6;
|
|
816
|
+
const f = h - Math.floor(h);
|
|
817
|
+
const p = 255 * v * (1 - s);
|
|
818
|
+
const q = 255 * v * (1 - s * f);
|
|
819
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
820
|
+
v *= 255;
|
|
821
|
+
switch (hi) {
|
|
822
|
+
case 0:
|
|
823
|
+
return [v, t, p];
|
|
824
|
+
case 1:
|
|
825
|
+
return [q, v, p];
|
|
826
|
+
case 2:
|
|
827
|
+
return [p, v, t];
|
|
828
|
+
case 3:
|
|
829
|
+
return [p, q, v];
|
|
830
|
+
case 4:
|
|
831
|
+
return [t, p, v];
|
|
832
|
+
case 5:
|
|
833
|
+
return [v, p, q];
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
convert.hsv.hsl = function(hsv) {
|
|
837
|
+
const h = hsv[0];
|
|
838
|
+
const s = hsv[1] / 100;
|
|
839
|
+
const v = hsv[2] / 100;
|
|
840
|
+
const vmin = Math.max(v, 0.01);
|
|
841
|
+
let sl;
|
|
842
|
+
let l;
|
|
843
|
+
l = (2 - s) * v;
|
|
844
|
+
const lmin = (2 - s) * vmin;
|
|
845
|
+
sl = s * vmin;
|
|
846
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
847
|
+
sl = sl || 0;
|
|
848
|
+
l /= 2;
|
|
849
|
+
return [h, sl * 100, l * 100];
|
|
850
|
+
};
|
|
851
|
+
convert.hwb.rgb = function(hwb) {
|
|
852
|
+
const h = hwb[0] / 360;
|
|
853
|
+
let wh = hwb[1] / 100;
|
|
854
|
+
let bl = hwb[2] / 100;
|
|
855
|
+
const ratio = wh + bl;
|
|
856
|
+
let f;
|
|
857
|
+
if (ratio > 1) {
|
|
858
|
+
wh /= ratio;
|
|
859
|
+
bl /= ratio;
|
|
860
|
+
}
|
|
861
|
+
const i = Math.floor(6 * h);
|
|
862
|
+
const v = 1 - bl;
|
|
863
|
+
f = 6 * h - i;
|
|
864
|
+
if ((i & 1) !== 0) {
|
|
865
|
+
f = 1 - f;
|
|
866
|
+
}
|
|
867
|
+
const n = wh + f * (v - wh);
|
|
868
|
+
let r;
|
|
869
|
+
let g;
|
|
870
|
+
let b;
|
|
871
|
+
switch (i) {
|
|
872
|
+
default:
|
|
873
|
+
case 6:
|
|
874
|
+
case 0:
|
|
875
|
+
r = v;
|
|
876
|
+
g = n;
|
|
877
|
+
b = wh;
|
|
878
|
+
break;
|
|
879
|
+
case 1:
|
|
880
|
+
r = n;
|
|
881
|
+
g = v;
|
|
882
|
+
b = wh;
|
|
883
|
+
break;
|
|
884
|
+
case 2:
|
|
885
|
+
r = wh;
|
|
886
|
+
g = v;
|
|
887
|
+
b = n;
|
|
888
|
+
break;
|
|
889
|
+
case 3:
|
|
890
|
+
r = wh;
|
|
891
|
+
g = n;
|
|
892
|
+
b = v;
|
|
893
|
+
break;
|
|
894
|
+
case 4:
|
|
895
|
+
r = n;
|
|
896
|
+
g = wh;
|
|
897
|
+
b = v;
|
|
898
|
+
break;
|
|
899
|
+
case 5:
|
|
900
|
+
r = v;
|
|
901
|
+
g = wh;
|
|
902
|
+
b = n;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
return [r * 255, g * 255, b * 255];
|
|
906
|
+
};
|
|
907
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
908
|
+
const c = cmyk[0] / 100;
|
|
909
|
+
const m = cmyk[1] / 100;
|
|
910
|
+
const y = cmyk[2] / 100;
|
|
911
|
+
const k = cmyk[3] / 100;
|
|
912
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
913
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
914
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
915
|
+
return [r * 255, g * 255, b * 255];
|
|
916
|
+
};
|
|
917
|
+
convert.xyz.rgb = function(xyz) {
|
|
918
|
+
const x = xyz[0] / 100;
|
|
919
|
+
const y = xyz[1] / 100;
|
|
920
|
+
const z = xyz[2] / 100;
|
|
921
|
+
let r;
|
|
922
|
+
let g;
|
|
923
|
+
let b;
|
|
924
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
925
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
926
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
927
|
+
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
928
|
+
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
929
|
+
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
930
|
+
r = Math.min(Math.max(0, r), 1);
|
|
931
|
+
g = Math.min(Math.max(0, g), 1);
|
|
932
|
+
b = Math.min(Math.max(0, b), 1);
|
|
933
|
+
return [r * 255, g * 255, b * 255];
|
|
934
|
+
};
|
|
935
|
+
convert.xyz.lab = function(xyz) {
|
|
936
|
+
let x = xyz[0];
|
|
937
|
+
let y = xyz[1];
|
|
938
|
+
let z = xyz[2];
|
|
939
|
+
x /= 95.047;
|
|
940
|
+
y /= 100;
|
|
941
|
+
z /= 108.883;
|
|
942
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
943
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
944
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
945
|
+
const l = 116 * y - 16;
|
|
946
|
+
const a = 500 * (x - y);
|
|
947
|
+
const b = 200 * (y - z);
|
|
948
|
+
return [l, a, b];
|
|
949
|
+
};
|
|
950
|
+
convert.lab.xyz = function(lab) {
|
|
951
|
+
const l = lab[0];
|
|
952
|
+
const a = lab[1];
|
|
953
|
+
const b = lab[2];
|
|
954
|
+
let x;
|
|
955
|
+
let y;
|
|
956
|
+
let z;
|
|
957
|
+
y = (l + 16) / 116;
|
|
958
|
+
x = a / 500 + y;
|
|
959
|
+
z = y - b / 200;
|
|
960
|
+
const y2 = y ** 3;
|
|
961
|
+
const x2 = x ** 3;
|
|
962
|
+
const z2 = z ** 3;
|
|
963
|
+
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
964
|
+
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
965
|
+
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
966
|
+
x *= 95.047;
|
|
967
|
+
y *= 100;
|
|
968
|
+
z *= 108.883;
|
|
969
|
+
return [x, y, z];
|
|
970
|
+
};
|
|
971
|
+
convert.lab.lch = function(lab) {
|
|
972
|
+
const l = lab[0];
|
|
973
|
+
const a = lab[1];
|
|
974
|
+
const b = lab[2];
|
|
975
|
+
let h;
|
|
976
|
+
const hr = Math.atan2(b, a);
|
|
977
|
+
h = hr * 360 / 2 / Math.PI;
|
|
978
|
+
if (h < 0) {
|
|
979
|
+
h += 360;
|
|
980
|
+
}
|
|
981
|
+
const c = Math.sqrt(a * a + b * b);
|
|
982
|
+
return [l, c, h];
|
|
983
|
+
};
|
|
984
|
+
convert.lch.lab = function(lch) {
|
|
985
|
+
const l = lch[0];
|
|
986
|
+
const c = lch[1];
|
|
987
|
+
const h = lch[2];
|
|
988
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
989
|
+
const a = c * Math.cos(hr);
|
|
990
|
+
const b = c * Math.sin(hr);
|
|
991
|
+
return [l, a, b];
|
|
992
|
+
};
|
|
993
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
994
|
+
const [r, g, b] = args;
|
|
995
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
996
|
+
value = Math.round(value / 50);
|
|
997
|
+
if (value === 0) {
|
|
998
|
+
return 30;
|
|
999
|
+
}
|
|
1000
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
1001
|
+
if (value === 2) {
|
|
1002
|
+
ansi += 60;
|
|
1003
|
+
}
|
|
1004
|
+
return ansi;
|
|
1005
|
+
};
|
|
1006
|
+
convert.hsv.ansi16 = function(args) {
|
|
1007
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
1008
|
+
};
|
|
1009
|
+
convert.rgb.ansi256 = function(args) {
|
|
1010
|
+
const r = args[0];
|
|
1011
|
+
const g = args[1];
|
|
1012
|
+
const b = args[2];
|
|
1013
|
+
if (r === g && g === b) {
|
|
1014
|
+
if (r < 8) {
|
|
1015
|
+
return 16;
|
|
1016
|
+
}
|
|
1017
|
+
if (r > 248) {
|
|
1018
|
+
return 231;
|
|
1019
|
+
}
|
|
1020
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
1021
|
+
}
|
|
1022
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
1023
|
+
return ansi;
|
|
1024
|
+
};
|
|
1025
|
+
convert.ansi16.rgb = function(args) {
|
|
1026
|
+
let color = args % 10;
|
|
1027
|
+
if (color === 0 || color === 7) {
|
|
1028
|
+
if (args > 50) {
|
|
1029
|
+
color += 3.5;
|
|
1030
|
+
}
|
|
1031
|
+
color = color / 10.5 * 255;
|
|
1032
|
+
return [color, color, color];
|
|
1033
|
+
}
|
|
1034
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
1035
|
+
const r = (color & 1) * mult * 255;
|
|
1036
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
1037
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
1038
|
+
return [r, g, b];
|
|
1039
|
+
};
|
|
1040
|
+
convert.ansi256.rgb = function(args) {
|
|
1041
|
+
if (args >= 232) {
|
|
1042
|
+
const c = (args - 232) * 10 + 8;
|
|
1043
|
+
return [c, c, c];
|
|
1044
|
+
}
|
|
1045
|
+
args -= 16;
|
|
1046
|
+
let rem;
|
|
1047
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
1048
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
1049
|
+
const b = rem % 6 / 5 * 255;
|
|
1050
|
+
return [r, g, b];
|
|
1051
|
+
};
|
|
1052
|
+
convert.rgb.hex = function(args) {
|
|
1053
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
1054
|
+
const string = integer.toString(16).toUpperCase();
|
|
1055
|
+
return "000000".substring(string.length) + string;
|
|
1056
|
+
};
|
|
1057
|
+
convert.hex.rgb = function(args) {
|
|
1058
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
1059
|
+
if (!match) {
|
|
1060
|
+
return [0, 0, 0];
|
|
1061
|
+
}
|
|
1062
|
+
let colorString = match[0];
|
|
1063
|
+
if (match[0].length === 3) {
|
|
1064
|
+
colorString = colorString.split("").map((char) => {
|
|
1065
|
+
return char + char;
|
|
1066
|
+
}).join("");
|
|
1067
|
+
}
|
|
1068
|
+
const integer = parseInt(colorString, 16);
|
|
1069
|
+
const r = integer >> 16 & 255;
|
|
1070
|
+
const g = integer >> 8 & 255;
|
|
1071
|
+
const b = integer & 255;
|
|
1072
|
+
return [r, g, b];
|
|
1073
|
+
};
|
|
1074
|
+
convert.rgb.hcg = function(rgb) {
|
|
1075
|
+
const r = rgb[0] / 255;
|
|
1076
|
+
const g = rgb[1] / 255;
|
|
1077
|
+
const b = rgb[2] / 255;
|
|
1078
|
+
const max = Math.max(Math.max(r, g), b);
|
|
1079
|
+
const min = Math.min(Math.min(r, g), b);
|
|
1080
|
+
const chroma = max - min;
|
|
1081
|
+
let grayscale;
|
|
1082
|
+
let hue;
|
|
1083
|
+
if (chroma < 1) {
|
|
1084
|
+
grayscale = min / (1 - chroma);
|
|
1085
|
+
} else {
|
|
1086
|
+
grayscale = 0;
|
|
1087
|
+
}
|
|
1088
|
+
if (chroma <= 0) {
|
|
1089
|
+
hue = 0;
|
|
1090
|
+
} else if (max === r) {
|
|
1091
|
+
hue = (g - b) / chroma % 6;
|
|
1092
|
+
} else if (max === g) {
|
|
1093
|
+
hue = 2 + (b - r) / chroma;
|
|
1094
|
+
} else {
|
|
1095
|
+
hue = 4 + (r - g) / chroma;
|
|
1096
|
+
}
|
|
1097
|
+
hue /= 6;
|
|
1098
|
+
hue %= 1;
|
|
1099
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
1100
|
+
};
|
|
1101
|
+
convert.hsl.hcg = function(hsl) {
|
|
1102
|
+
const s = hsl[1] / 100;
|
|
1103
|
+
const l = hsl[2] / 100;
|
|
1104
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
1105
|
+
let f = 0;
|
|
1106
|
+
if (c < 1) {
|
|
1107
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
1108
|
+
}
|
|
1109
|
+
return [hsl[0], c * 100, f * 100];
|
|
1110
|
+
};
|
|
1111
|
+
convert.hsv.hcg = function(hsv) {
|
|
1112
|
+
const s = hsv[1] / 100;
|
|
1113
|
+
const v = hsv[2] / 100;
|
|
1114
|
+
const c = s * v;
|
|
1115
|
+
let f = 0;
|
|
1116
|
+
if (c < 1) {
|
|
1117
|
+
f = (v - c) / (1 - c);
|
|
1118
|
+
}
|
|
1119
|
+
return [hsv[0], c * 100, f * 100];
|
|
1120
|
+
};
|
|
1121
|
+
convert.hcg.rgb = function(hcg) {
|
|
1122
|
+
const h = hcg[0] / 360;
|
|
1123
|
+
const c = hcg[1] / 100;
|
|
1124
|
+
const g = hcg[2] / 100;
|
|
1125
|
+
if (c === 0) {
|
|
1126
|
+
return [g * 255, g * 255, g * 255];
|
|
1127
|
+
}
|
|
1128
|
+
const pure = [0, 0, 0];
|
|
1129
|
+
const hi = h % 1 * 6;
|
|
1130
|
+
const v = hi % 1;
|
|
1131
|
+
const w = 1 - v;
|
|
1132
|
+
let mg = 0;
|
|
1133
|
+
switch (Math.floor(hi)) {
|
|
1134
|
+
case 0:
|
|
1135
|
+
pure[0] = 1;
|
|
1136
|
+
pure[1] = v;
|
|
1137
|
+
pure[2] = 0;
|
|
1138
|
+
break;
|
|
1139
|
+
case 1:
|
|
1140
|
+
pure[0] = w;
|
|
1141
|
+
pure[1] = 1;
|
|
1142
|
+
pure[2] = 0;
|
|
1143
|
+
break;
|
|
1144
|
+
case 2:
|
|
1145
|
+
pure[0] = 0;
|
|
1146
|
+
pure[1] = 1;
|
|
1147
|
+
pure[2] = v;
|
|
1148
|
+
break;
|
|
1149
|
+
case 3:
|
|
1150
|
+
pure[0] = 0;
|
|
1151
|
+
pure[1] = w;
|
|
1152
|
+
pure[2] = 1;
|
|
1153
|
+
break;
|
|
1154
|
+
case 4:
|
|
1155
|
+
pure[0] = v;
|
|
1156
|
+
pure[1] = 0;
|
|
1157
|
+
pure[2] = 1;
|
|
1158
|
+
break;
|
|
1159
|
+
default:
|
|
1160
|
+
pure[0] = 1;
|
|
1161
|
+
pure[1] = 0;
|
|
1162
|
+
pure[2] = w;
|
|
1163
|
+
}
|
|
1164
|
+
mg = (1 - c) * g;
|
|
1165
|
+
return [
|
|
1166
|
+
(c * pure[0] + mg) * 255,
|
|
1167
|
+
(c * pure[1] + mg) * 255,
|
|
1168
|
+
(c * pure[2] + mg) * 255
|
|
1169
|
+
];
|
|
1170
|
+
};
|
|
1171
|
+
convert.hcg.hsv = function(hcg) {
|
|
1172
|
+
const c = hcg[1] / 100;
|
|
1173
|
+
const g = hcg[2] / 100;
|
|
1174
|
+
const v = c + g * (1 - c);
|
|
1175
|
+
let f = 0;
|
|
1176
|
+
if (v > 0) {
|
|
1177
|
+
f = c / v;
|
|
1178
|
+
}
|
|
1179
|
+
return [hcg[0], f * 100, v * 100];
|
|
1180
|
+
};
|
|
1181
|
+
convert.hcg.hsl = function(hcg) {
|
|
1182
|
+
const c = hcg[1] / 100;
|
|
1183
|
+
const g = hcg[2] / 100;
|
|
1184
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
1185
|
+
let s = 0;
|
|
1186
|
+
if (l > 0 && l < 0.5) {
|
|
1187
|
+
s = c / (2 * l);
|
|
1188
|
+
} else if (l >= 0.5 && l < 1) {
|
|
1189
|
+
s = c / (2 * (1 - l));
|
|
1190
|
+
}
|
|
1191
|
+
return [hcg[0], s * 100, l * 100];
|
|
1192
|
+
};
|
|
1193
|
+
convert.hcg.hwb = function(hcg) {
|
|
1194
|
+
const c = hcg[1] / 100;
|
|
1195
|
+
const g = hcg[2] / 100;
|
|
1196
|
+
const v = c + g * (1 - c);
|
|
1197
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
1198
|
+
};
|
|
1199
|
+
convert.hwb.hcg = function(hwb) {
|
|
1200
|
+
const w = hwb[1] / 100;
|
|
1201
|
+
const b = hwb[2] / 100;
|
|
1202
|
+
const v = 1 - b;
|
|
1203
|
+
const c = v - w;
|
|
1204
|
+
let g = 0;
|
|
1205
|
+
if (c < 1) {
|
|
1206
|
+
g = (v - c) / (1 - c);
|
|
1207
|
+
}
|
|
1208
|
+
return [hwb[0], c * 100, g * 100];
|
|
1209
|
+
};
|
|
1210
|
+
convert.apple.rgb = function(apple) {
|
|
1211
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
1212
|
+
};
|
|
1213
|
+
convert.rgb.apple = function(rgb) {
|
|
1214
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
1215
|
+
};
|
|
1216
|
+
convert.gray.rgb = function(args) {
|
|
1217
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
1218
|
+
};
|
|
1219
|
+
convert.gray.hsl = function(args) {
|
|
1220
|
+
return [0, 0, args[0]];
|
|
1221
|
+
};
|
|
1222
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
1223
|
+
convert.gray.hwb = function(gray) {
|
|
1224
|
+
return [0, 100, gray[0]];
|
|
1225
|
+
};
|
|
1226
|
+
convert.gray.cmyk = function(gray) {
|
|
1227
|
+
return [0, 0, 0, gray[0]];
|
|
1228
|
+
};
|
|
1229
|
+
convert.gray.lab = function(gray) {
|
|
1230
|
+
return [gray[0], 0, 0];
|
|
1231
|
+
};
|
|
1232
|
+
convert.gray.hex = function(gray) {
|
|
1233
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
1234
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
1235
|
+
const string = integer.toString(16).toUpperCase();
|
|
1236
|
+
return "000000".substring(string.length) + string;
|
|
1237
|
+
};
|
|
1238
|
+
convert.rgb.gray = function(rgb) {
|
|
1239
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
1240
|
+
return [val / 255 * 100];
|
|
1241
|
+
};
|
|
1242
|
+
return conversions;
|
|
1313
1243
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1244
|
+
var route;
|
|
1245
|
+
var hasRequiredRoute;
|
|
1246
|
+
function requireRoute() {
|
|
1247
|
+
if (hasRequiredRoute)
|
|
1248
|
+
return route;
|
|
1249
|
+
hasRequiredRoute = 1;
|
|
1250
|
+
const conversions2 = requireConversions();
|
|
1251
|
+
function buildGraph() {
|
|
1252
|
+
const graph = {};
|
|
1253
|
+
const models = Object.keys(conversions2);
|
|
1254
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
1255
|
+
graph[models[i]] = {
|
|
1256
|
+
// http://jsperf.com/1-vs-infinity
|
|
1257
|
+
// micro-opt, but this is simple.
|
|
1258
|
+
distance: -1,
|
|
1259
|
+
parent: null
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
return graph;
|
|
1263
|
+
}
|
|
1264
|
+
function deriveBFS(fromModel) {
|
|
1265
|
+
const graph = buildGraph();
|
|
1266
|
+
const queue = [fromModel];
|
|
1267
|
+
graph[fromModel].distance = 0;
|
|
1268
|
+
while (queue.length) {
|
|
1269
|
+
const current = queue.pop();
|
|
1270
|
+
const adjacents = Object.keys(conversions2[current]);
|
|
1271
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
1272
|
+
const adjacent = adjacents[i];
|
|
1273
|
+
const node = graph[adjacent];
|
|
1274
|
+
if (node.distance === -1) {
|
|
1275
|
+
node.distance = graph[current].distance + 1;
|
|
1276
|
+
node.parent = current;
|
|
1277
|
+
queue.unshift(adjacent);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
return graph;
|
|
1322
1282
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
var graph = deriveBFS(fromModel);
|
|
1328
|
-
var conversion = {};
|
|
1329
|
-
var models2 = Object.keys(graph);
|
|
1330
|
-
for (var len = models2.length, i = 0; i < len; i++) {
|
|
1331
|
-
var toModel = models2[i];
|
|
1332
|
-
var node = graph[toModel];
|
|
1333
|
-
if (node.parent === null) {
|
|
1334
|
-
continue;
|
|
1335
|
-
}
|
|
1336
|
-
conversion[toModel] = wrapConversion(toModel, graph);
|
|
1283
|
+
function link(from, to) {
|
|
1284
|
+
return function(args) {
|
|
1285
|
+
return to(from(args));
|
|
1286
|
+
};
|
|
1337
1287
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1288
|
+
function wrapConversion(toModel, graph) {
|
|
1289
|
+
const path = [graph[toModel].parent, toModel];
|
|
1290
|
+
let fn = conversions2[graph[toModel].parent][toModel];
|
|
1291
|
+
let cur = graph[toModel].parent;
|
|
1292
|
+
while (graph[cur].parent) {
|
|
1293
|
+
path.unshift(graph[cur].parent);
|
|
1294
|
+
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
1295
|
+
cur = graph[cur].parent;
|
|
1296
|
+
}
|
|
1297
|
+
fn.conversion = path;
|
|
1298
|
+
return fn;
|
|
1299
|
+
}
|
|
1300
|
+
route = function(fromModel) {
|
|
1301
|
+
const graph = deriveBFS(fromModel);
|
|
1302
|
+
const conversion = {};
|
|
1303
|
+
const models = Object.keys(graph);
|
|
1304
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
1305
|
+
const toModel = models[i];
|
|
1306
|
+
const node = graph[toModel];
|
|
1307
|
+
if (node.parent === null) {
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
1311
|
+
}
|
|
1312
|
+
return conversion;
|
|
1353
1313
|
};
|
|
1354
|
-
|
|
1355
|
-
wrappedFn.conversion = fn.conversion;
|
|
1356
|
-
}
|
|
1357
|
-
return wrappedFn;
|
|
1314
|
+
return route;
|
|
1358
1315
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1316
|
+
var colorConvert;
|
|
1317
|
+
var hasRequiredColorConvert;
|
|
1318
|
+
function requireColorConvert() {
|
|
1319
|
+
if (hasRequiredColorConvert)
|
|
1320
|
+
return colorConvert;
|
|
1321
|
+
hasRequiredColorConvert = 1;
|
|
1322
|
+
const conversions2 = requireConversions();
|
|
1323
|
+
const route2 = requireRoute();
|
|
1324
|
+
const convert = {};
|
|
1325
|
+
const models = Object.keys(conversions2);
|
|
1326
|
+
function wrapRaw(fn) {
|
|
1327
|
+
const wrappedFn = function(...args) {
|
|
1328
|
+
const arg0 = args[0];
|
|
1329
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
1330
|
+
return arg0;
|
|
1371
1331
|
}
|
|
1332
|
+
if (arg0.length > 1) {
|
|
1333
|
+
args = arg0;
|
|
1334
|
+
}
|
|
1335
|
+
return fn(args);
|
|
1336
|
+
};
|
|
1337
|
+
if ("conversion" in fn) {
|
|
1338
|
+
wrappedFn.conversion = fn.conversion;
|
|
1372
1339
|
}
|
|
1373
|
-
return
|
|
1374
|
-
};
|
|
1375
|
-
if ("conversion" in fn) {
|
|
1376
|
-
wrappedFn.conversion = fn.conversion;
|
|
1340
|
+
return wrappedFn;
|
|
1377
1341
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1342
|
+
function wrapRounded(fn) {
|
|
1343
|
+
const wrappedFn = function(...args) {
|
|
1344
|
+
const arg0 = args[0];
|
|
1345
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
1346
|
+
return arg0;
|
|
1347
|
+
}
|
|
1348
|
+
if (arg0.length > 1) {
|
|
1349
|
+
args = arg0;
|
|
1350
|
+
}
|
|
1351
|
+
const result = fn(args);
|
|
1352
|
+
if (typeof result === "object") {
|
|
1353
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
1354
|
+
result[i] = Math.round(result[i]);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return result;
|
|
1358
|
+
};
|
|
1359
|
+
if ("conversion" in fn) {
|
|
1360
|
+
wrappedFn.conversion = fn.conversion;
|
|
1361
|
+
}
|
|
1362
|
+
return wrappedFn;
|
|
1363
|
+
}
|
|
1364
|
+
models.forEach((fromModel) => {
|
|
1365
|
+
convert[fromModel] = {};
|
|
1366
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
1367
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
1368
|
+
const routes = route2(fromModel);
|
|
1369
|
+
const routeModels = Object.keys(routes);
|
|
1370
|
+
routeModels.forEach((toModel) => {
|
|
1371
|
+
const fn = routes[toModel];
|
|
1372
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1373
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1374
|
+
});
|
|
1390
1375
|
});
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1376
|
+
colorConvert = convert;
|
|
1377
|
+
return colorConvert;
|
|
1378
|
+
}
|
|
1379
|
+
ansiStyles$1.exports;
|
|
1394
1380
|
(function(module) {
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1397
|
-
const code = fn.apply(colorConvert$1, arguments);
|
|
1381
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1382
|
+
const code = fn(...args);
|
|
1398
1383
|
return `\x1B[${code + offset}m`;
|
|
1399
1384
|
};
|
|
1400
|
-
const wrapAnsi256 = (fn, offset) =>
|
|
1401
|
-
const code = fn
|
|
1385
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1386
|
+
const code = fn(...args);
|
|
1402
1387
|
return `\x1B[${38 + offset};5;${code}m`;
|
|
1403
1388
|
};
|
|
1404
|
-
const wrapAnsi16m = (fn, offset) =>
|
|
1405
|
-
const rgb = fn
|
|
1389
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1390
|
+
const rgb = fn(...args);
|
|
1406
1391
|
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1407
1392
|
};
|
|
1393
|
+
const ansi2ansi = (n) => n;
|
|
1394
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1395
|
+
const setLazyProperty = (object, property, get) => {
|
|
1396
|
+
Object.defineProperty(object, property, {
|
|
1397
|
+
get: () => {
|
|
1398
|
+
const value = get();
|
|
1399
|
+
Object.defineProperty(object, property, {
|
|
1400
|
+
value,
|
|
1401
|
+
enumerable: true,
|
|
1402
|
+
configurable: true
|
|
1403
|
+
});
|
|
1404
|
+
return value;
|
|
1405
|
+
},
|
|
1406
|
+
enumerable: true,
|
|
1407
|
+
configurable: true
|
|
1408
|
+
});
|
|
1409
|
+
};
|
|
1410
|
+
let colorConvert2;
|
|
1411
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1412
|
+
if (colorConvert2 === void 0) {
|
|
1413
|
+
colorConvert2 = requireColorConvert();
|
|
1414
|
+
}
|
|
1415
|
+
const offset = isBackground ? 10 : 0;
|
|
1416
|
+
const styles2 = {};
|
|
1417
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1418
|
+
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1419
|
+
if (sourceSpace === targetSpace) {
|
|
1420
|
+
styles2[name] = wrap(identity, offset);
|
|
1421
|
+
} else if (typeof suite === "object") {
|
|
1422
|
+
styles2[name] = wrap(suite[targetSpace], offset);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
return styles2;
|
|
1426
|
+
};
|
|
1408
1427
|
function assembleStyles() {
|
|
1409
1428
|
const codes = /* @__PURE__ */ new Map();
|
|
1410
|
-
const
|
|
1429
|
+
const styles2 = {
|
|
1411
1430
|
modifier: {
|
|
1412
1431
|
reset: [0, 0],
|
|
1413
1432
|
// 21 isn't widely supported and 22 does the same thing
|
|
@@ -1428,8 +1447,8 @@ ansiStyles.exports;
|
|
|
1428
1447
|
magenta: [35, 39],
|
|
1429
1448
|
cyan: [36, 39],
|
|
1430
1449
|
white: [37, 39],
|
|
1431
|
-
gray: [90, 39],
|
|
1432
1450
|
// Bright color
|
|
1451
|
+
blackBright: [90, 39],
|
|
1433
1452
|
redBright: [91, 39],
|
|
1434
1453
|
greenBright: [92, 39],
|
|
1435
1454
|
yellowBright: [93, 39],
|
|
@@ -1458,352 +1477,369 @@ ansiStyles.exports;
|
|
|
1458
1477
|
bgWhiteBright: [107, 49]
|
|
1459
1478
|
}
|
|
1460
1479
|
};
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1480
|
+
styles2.color.gray = styles2.color.blackBright;
|
|
1481
|
+
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1482
|
+
styles2.color.grey = styles2.color.blackBright;
|
|
1483
|
+
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1484
|
+
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1485
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
1486
|
+
styles2[styleName] = {
|
|
1467
1487
|
open: `\x1B[${style[0]}m`,
|
|
1468
1488
|
close: `\x1B[${style[1]}m`
|
|
1469
1489
|
};
|
|
1470
|
-
group[styleName] =
|
|
1490
|
+
group[styleName] = styles2[styleName];
|
|
1471
1491
|
codes.set(style[0], style[1]);
|
|
1472
1492
|
}
|
|
1473
|
-
Object.defineProperty(
|
|
1493
|
+
Object.defineProperty(styles2, groupName, {
|
|
1474
1494
|
value: group,
|
|
1475
1495
|
enumerable: false
|
|
1476
1496
|
});
|
|
1477
|
-
Object.defineProperty(styles, "codes", {
|
|
1478
|
-
value: codes,
|
|
1479
|
-
enumerable: false
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
const ansi2ansi = (n) => n;
|
|
1483
|
-
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1484
|
-
styles.color.close = "\x1B[39m";
|
|
1485
|
-
styles.bgColor.close = "\x1B[49m";
|
|
1486
|
-
styles.color.ansi = {
|
|
1487
|
-
ansi: wrapAnsi16(ansi2ansi, 0)
|
|
1488
|
-
};
|
|
1489
|
-
styles.color.ansi256 = {
|
|
1490
|
-
ansi256: wrapAnsi256(ansi2ansi, 0)
|
|
1491
|
-
};
|
|
1492
|
-
styles.color.ansi16m = {
|
|
1493
|
-
rgb: wrapAnsi16m(rgb2rgb, 0)
|
|
1494
|
-
};
|
|
1495
|
-
styles.bgColor.ansi = {
|
|
1496
|
-
ansi: wrapAnsi16(ansi2ansi, 10)
|
|
1497
|
-
};
|
|
1498
|
-
styles.bgColor.ansi256 = {
|
|
1499
|
-
ansi256: wrapAnsi256(ansi2ansi, 10)
|
|
1500
|
-
};
|
|
1501
|
-
styles.bgColor.ansi16m = {
|
|
1502
|
-
rgb: wrapAnsi16m(rgb2rgb, 10)
|
|
1503
|
-
};
|
|
1504
|
-
for (let key of Object.keys(colorConvert$1)) {
|
|
1505
|
-
if (typeof colorConvert$1[key] !== "object") {
|
|
1506
|
-
continue;
|
|
1507
|
-
}
|
|
1508
|
-
const suite = colorConvert$1[key];
|
|
1509
|
-
if (key === "ansi16") {
|
|
1510
|
-
key = "ansi";
|
|
1511
|
-
}
|
|
1512
|
-
if ("ansi16" in suite) {
|
|
1513
|
-
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
|
1514
|
-
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
|
1515
|
-
}
|
|
1516
|
-
if ("ansi256" in suite) {
|
|
1517
|
-
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
|
1518
|
-
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
|
1519
|
-
}
|
|
1520
|
-
if ("rgb" in suite) {
|
|
1521
|
-
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
|
1522
|
-
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
|
1523
|
-
}
|
|
1524
1497
|
}
|
|
1525
|
-
|
|
1498
|
+
Object.defineProperty(styles2, "codes", {
|
|
1499
|
+
value: codes,
|
|
1500
|
+
enumerable: false
|
|
1501
|
+
});
|
|
1502
|
+
styles2.color.close = "\x1B[39m";
|
|
1503
|
+
styles2.bgColor.close = "\x1B[49m";
|
|
1504
|
+
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1505
|
+
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1506
|
+
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1507
|
+
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1508
|
+
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1509
|
+
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1510
|
+
return styles2;
|
|
1526
1511
|
}
|
|
1527
1512
|
Object.defineProperty(module, "exports", {
|
|
1528
1513
|
enumerable: true,
|
|
1529
1514
|
get: assembleStyles
|
|
1530
1515
|
});
|
|
1531
|
-
})(ansiStyles);
|
|
1532
|
-
var ansiStylesExports = ansiStyles.exports;
|
|
1516
|
+
})(ansiStyles$1);
|
|
1517
|
+
var ansiStylesExports = ansiStyles$1.exports;
|
|
1533
1518
|
var browser = {
|
|
1534
1519
|
stdout: false,
|
|
1535
1520
|
stderr: false
|
|
1536
1521
|
};
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1522
|
+
const stringReplaceAll$1 = (string, substring, replacer) => {
|
|
1523
|
+
let index = string.indexOf(substring);
|
|
1524
|
+
if (index === -1) {
|
|
1525
|
+
return string;
|
|
1526
|
+
}
|
|
1527
|
+
const substringLength = substring.length;
|
|
1528
|
+
let endIndex = 0;
|
|
1529
|
+
let returnValue = "";
|
|
1530
|
+
do {
|
|
1531
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1532
|
+
endIndex = index + substringLength;
|
|
1533
|
+
index = string.indexOf(substring, endIndex);
|
|
1534
|
+
} while (index !== -1);
|
|
1535
|
+
returnValue += string.substr(endIndex);
|
|
1536
|
+
return returnValue;
|
|
1537
|
+
};
|
|
1538
|
+
const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
|
|
1539
|
+
let endIndex = 0;
|
|
1540
|
+
let returnValue = "";
|
|
1541
|
+
do {
|
|
1542
|
+
const gotCR = string[index - 1] === "\r";
|
|
1543
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1544
|
+
endIndex = index + 1;
|
|
1545
|
+
index = string.indexOf("\n", endIndex);
|
|
1546
|
+
} while (index !== -1);
|
|
1547
|
+
returnValue += string.substr(endIndex);
|
|
1548
|
+
return returnValue;
|
|
1549
|
+
};
|
|
1550
|
+
var util = {
|
|
1551
|
+
stringReplaceAll: stringReplaceAll$1,
|
|
1552
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
|
1553
|
+
};
|
|
1554
|
+
var templates;
|
|
1555
|
+
var hasRequiredTemplates;
|
|
1556
|
+
function requireTemplates() {
|
|
1557
|
+
if (hasRequiredTemplates)
|
|
1558
|
+
return templates;
|
|
1559
|
+
hasRequiredTemplates = 1;
|
|
1560
|
+
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;
|
|
1561
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1562
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1563
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1564
|
+
const ESCAPES = /* @__PURE__ */ new Map([
|
|
1565
|
+
["n", "\n"],
|
|
1566
|
+
["r", "\r"],
|
|
1567
|
+
["t", " "],
|
|
1568
|
+
["b", "\b"],
|
|
1569
|
+
["f", "\f"],
|
|
1570
|
+
["v", "\v"],
|
|
1571
|
+
["0", "\0"],
|
|
1572
|
+
["\\", "\\"],
|
|
1573
|
+
["e", "\x1B"],
|
|
1574
|
+
["a", "\x07"]
|
|
1575
|
+
]);
|
|
1576
|
+
function unescape(c) {
|
|
1577
|
+
const u = c[0] === "u";
|
|
1578
|
+
const bracket = c[1] === "{";
|
|
1579
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1580
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1570
1581
|
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1574
|
-
function parseStyle(style) {
|
|
1575
|
-
STYLE_REGEX.lastIndex = 0;
|
|
1576
|
-
const results = [];
|
|
1577
|
-
let matches;
|
|
1578
|
-
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1579
|
-
const name = matches[1];
|
|
1580
|
-
if (matches[2]) {
|
|
1581
|
-
const args = parseArguments(name, matches[2]);
|
|
1582
|
-
results.push([name].concat(args));
|
|
1583
|
-
} else {
|
|
1584
|
-
results.push([name]);
|
|
1582
|
+
if (u && bracket) {
|
|
1583
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1585
1584
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
for (const
|
|
1593
|
-
|
|
1585
|
+
return ESCAPES.get(c) || c;
|
|
1586
|
+
}
|
|
1587
|
+
function parseArguments(name, arguments_) {
|
|
1588
|
+
const results = [];
|
|
1589
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1590
|
+
let matches;
|
|
1591
|
+
for (const chunk of chunks) {
|
|
1592
|
+
const number = Number(chunk);
|
|
1593
|
+
if (!Number.isNaN(number)) {
|
|
1594
|
+
results.push(number);
|
|
1595
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1596
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape2, character) => escape2 ? unescape(escape2) : character));
|
|
1597
|
+
} else {
|
|
1598
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1599
|
+
}
|
|
1594
1600
|
}
|
|
1601
|
+
return results;
|
|
1602
|
+
}
|
|
1603
|
+
function parseStyle(style) {
|
|
1604
|
+
STYLE_REGEX.lastIndex = 0;
|
|
1605
|
+
const results = [];
|
|
1606
|
+
let matches;
|
|
1607
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1608
|
+
const name = matches[1];
|
|
1609
|
+
if (matches[2]) {
|
|
1610
|
+
const args = parseArguments(name, matches[2]);
|
|
1611
|
+
results.push([name].concat(args));
|
|
1612
|
+
} else {
|
|
1613
|
+
results.push([name]);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
return results;
|
|
1595
1617
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1618
|
+
function buildStyle(chalk2, styles2) {
|
|
1619
|
+
const enabled = {};
|
|
1620
|
+
for (const layer of styles2) {
|
|
1621
|
+
for (const style of layer.styles) {
|
|
1622
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
let current = chalk2;
|
|
1626
|
+
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1627
|
+
if (!Array.isArray(styles3)) {
|
|
1628
|
+
continue;
|
|
1629
|
+
}
|
|
1599
1630
|
if (!(styleName in current)) {
|
|
1600
1631
|
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1601
1632
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1633
|
+
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1634
|
+
}
|
|
1635
|
+
return current;
|
|
1636
|
+
}
|
|
1637
|
+
templates = (chalk2, temporary) => {
|
|
1638
|
+
const styles2 = [];
|
|
1639
|
+
const chunks = [];
|
|
1640
|
+
let chunk = [];
|
|
1641
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1642
|
+
if (escapeCharacter) {
|
|
1643
|
+
chunk.push(unescape(escapeCharacter));
|
|
1644
|
+
} else if (style) {
|
|
1645
|
+
const string = chunk.join("");
|
|
1646
|
+
chunk = [];
|
|
1647
|
+
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
1648
|
+
styles2.push({ inverse, styles: parseStyle(style) });
|
|
1649
|
+
} else if (close) {
|
|
1650
|
+
if (styles2.length === 0) {
|
|
1651
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
1652
|
+
}
|
|
1653
|
+
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
1654
|
+
chunk = [];
|
|
1655
|
+
styles2.pop();
|
|
1604
1656
|
} else {
|
|
1605
|
-
|
|
1657
|
+
chunk.push(character);
|
|
1606
1658
|
}
|
|
1659
|
+
});
|
|
1660
|
+
chunks.push(chunk.join(""));
|
|
1661
|
+
if (styles2.length > 0) {
|
|
1662
|
+
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1663
|
+
throw new Error(errMessage);
|
|
1607
1664
|
}
|
|
1665
|
+
return chunks.join("");
|
|
1666
|
+
};
|
|
1667
|
+
return templates;
|
|
1668
|
+
}
|
|
1669
|
+
const ansiStyles = ansiStylesExports;
|
|
1670
|
+
const { stdout: stdoutColor, stderr: stderrColor } = browser;
|
|
1671
|
+
const {
|
|
1672
|
+
stringReplaceAll,
|
|
1673
|
+
stringEncaseCRLFWithFirstIndex
|
|
1674
|
+
} = util;
|
|
1675
|
+
const { isArray } = Array;
|
|
1676
|
+
const levelMapping = [
|
|
1677
|
+
"ansi",
|
|
1678
|
+
"ansi",
|
|
1679
|
+
"ansi256",
|
|
1680
|
+
"ansi16m"
|
|
1681
|
+
];
|
|
1682
|
+
const styles = /* @__PURE__ */ Object.create(null);
|
|
1683
|
+
const applyOptions = (object, options = {}) => {
|
|
1684
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1685
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1686
|
+
}
|
|
1687
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1688
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1689
|
+
};
|
|
1690
|
+
class ChalkClass {
|
|
1691
|
+
constructor(options) {
|
|
1692
|
+
return chalkFactory(options);
|
|
1608
1693
|
}
|
|
1609
|
-
return current;
|
|
1610
1694
|
}
|
|
1611
|
-
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1695
|
+
const chalkFactory = (options) => {
|
|
1696
|
+
const chalk2 = {};
|
|
1697
|
+
applyOptions(chalk2, options);
|
|
1698
|
+
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
1699
|
+
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
1700
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1701
|
+
chalk2.template.constructor = () => {
|
|
1702
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1703
|
+
};
|
|
1704
|
+
chalk2.template.Instance = ChalkClass;
|
|
1705
|
+
return chalk2.template;
|
|
1706
|
+
};
|
|
1707
|
+
function Chalk(options) {
|
|
1708
|
+
return chalkFactory(options);
|
|
1709
|
+
}
|
|
1710
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
1711
|
+
styles[styleName] = {
|
|
1712
|
+
get() {
|
|
1713
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
1714
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
1715
|
+
return builder;
|
|
1632
1716
|
}
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
styles.visible = {
|
|
1720
|
+
get() {
|
|
1721
|
+
const builder = createBuilder(this, this._styler, true);
|
|
1722
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
1723
|
+
return builder;
|
|
1638
1724
|
}
|
|
1639
|
-
return chunks.join("");
|
|
1640
1725
|
};
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
const styles = /* @__PURE__ */ Object.create(null);
|
|
1650
|
-
function applyOptions(obj, options) {
|
|
1651
|
-
options = options || {};
|
|
1652
|
-
const scLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1653
|
-
obj.level = options.level === void 0 ? scLevel : options.level;
|
|
1654
|
-
obj.enabled = "enabled" in options ? options.enabled : obj.level > 0;
|
|
1655
|
-
}
|
|
1656
|
-
function Chalk(options) {
|
|
1657
|
-
if (!this || !(this instanceof Chalk) || this.template) {
|
|
1658
|
-
const chalk2 = {};
|
|
1659
|
-
applyOptions(chalk2, options);
|
|
1660
|
-
chalk2.template = function() {
|
|
1661
|
-
const args = [].slice.call(arguments);
|
|
1662
|
-
return chalkTag.apply(null, [chalk2.template].concat(args));
|
|
1726
|
+
const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1727
|
+
for (const model of usedModels) {
|
|
1728
|
+
styles[model] = {
|
|
1729
|
+
get() {
|
|
1730
|
+
const { level } = this;
|
|
1731
|
+
return function(...arguments_) {
|
|
1732
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
1733
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
1663
1734
|
};
|
|
1664
|
-
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
1665
|
-
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1666
|
-
chalk2.template.constructor = Chalk;
|
|
1667
|
-
return chalk2.template;
|
|
1668
1735
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
for (const key of Object.keys(ansiStyles2)) {
|
|
1675
|
-
ansiStyles2[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles2[key].close), "g");
|
|
1676
|
-
styles[key] = {
|
|
1677
|
-
get() {
|
|
1678
|
-
const codes = ansiStyles2[key];
|
|
1679
|
-
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
|
|
1680
|
-
}
|
|
1681
|
-
};
|
|
1682
|
-
}
|
|
1683
|
-
styles.visible = {
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
for (const model of usedModels) {
|
|
1739
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1740
|
+
styles[bgModel] = {
|
|
1684
1741
|
get() {
|
|
1685
|
-
|
|
1742
|
+
const { level } = this;
|
|
1743
|
+
return function(...arguments_) {
|
|
1744
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
1745
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
1746
|
+
};
|
|
1686
1747
|
}
|
|
1687
1748
|
};
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
close: ansiStyles2.color.close,
|
|
1701
|
-
closeRe: ansiStyles2.color.closeRe
|
|
1702
|
-
};
|
|
1703
|
-
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
|
1704
|
-
};
|
|
1705
|
-
}
|
|
1706
|
-
};
|
|
1707
|
-
}
|
|
1708
|
-
ansiStyles2.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles2.bgColor.close), "g");
|
|
1709
|
-
for (const model of Object.keys(ansiStyles2.bgColor.ansi)) {
|
|
1710
|
-
if (skipModels.has(model)) {
|
|
1711
|
-
continue;
|
|
1712
|
-
}
|
|
1713
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1714
|
-
styles[bgModel] = {
|
|
1715
|
-
get() {
|
|
1716
|
-
const level = this.level;
|
|
1717
|
-
return function() {
|
|
1718
|
-
const open = ansiStyles2.bgColor[levelMapping[level]][model].apply(null, arguments);
|
|
1719
|
-
const codes = {
|
|
1720
|
-
open,
|
|
1721
|
-
close: ansiStyles2.bgColor.close,
|
|
1722
|
-
closeRe: ansiStyles2.bgColor.closeRe
|
|
1723
|
-
};
|
|
1724
|
-
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
|
1725
|
-
};
|
|
1726
|
-
}
|
|
1727
|
-
};
|
|
1749
|
+
}
|
|
1750
|
+
const proto = Object.defineProperties(() => {
|
|
1751
|
+
}, {
|
|
1752
|
+
...styles,
|
|
1753
|
+
level: {
|
|
1754
|
+
enumerable: true,
|
|
1755
|
+
get() {
|
|
1756
|
+
return this._generator.level;
|
|
1757
|
+
},
|
|
1758
|
+
set(level) {
|
|
1759
|
+
this._generator.level = level;
|
|
1760
|
+
}
|
|
1728
1761
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
enumerable: true,
|
|
1740
|
-
get() {
|
|
1741
|
-
return self.level;
|
|
1742
|
-
},
|
|
1743
|
-
set(level) {
|
|
1744
|
-
self.level = level;
|
|
1745
|
-
}
|
|
1746
|
-
});
|
|
1747
|
-
Object.defineProperty(builder, "enabled", {
|
|
1748
|
-
enumerable: true,
|
|
1749
|
-
get() {
|
|
1750
|
-
return self.enabled;
|
|
1751
|
-
},
|
|
1752
|
-
set(enabled) {
|
|
1753
|
-
self.enabled = enabled;
|
|
1754
|
-
}
|
|
1755
|
-
});
|
|
1756
|
-
builder.hasGrey = this.hasGrey || key === "gray" || key === "grey";
|
|
1757
|
-
builder.__proto__ = proto;
|
|
1758
|
-
return builder;
|
|
1762
|
+
});
|
|
1763
|
+
const createStyler = (open, close, parent) => {
|
|
1764
|
+
let openAll;
|
|
1765
|
+
let closeAll;
|
|
1766
|
+
if (parent === void 0) {
|
|
1767
|
+
openAll = open;
|
|
1768
|
+
closeAll = close;
|
|
1769
|
+
} else {
|
|
1770
|
+
openAll = parent.openAll + open;
|
|
1771
|
+
closeAll = close + parent.closeAll;
|
|
1759
1772
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
if (!this.enabled || this.level <= 0 || !str) {
|
|
1773
|
-
return this._empty ? "" : str;
|
|
1774
|
-
}
|
|
1775
|
-
const originalDim = ansiStyles2.dim.open;
|
|
1776
|
-
if (isSimpleWindowsTerm && this.hasGrey) {
|
|
1777
|
-
ansiStyles2.dim.open = "";
|
|
1773
|
+
return {
|
|
1774
|
+
open,
|
|
1775
|
+
close,
|
|
1776
|
+
openAll,
|
|
1777
|
+
closeAll,
|
|
1778
|
+
parent
|
|
1779
|
+
};
|
|
1780
|
+
};
|
|
1781
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
|
1782
|
+
const builder = (...arguments_) => {
|
|
1783
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
1784
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
1778
1785
|
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1786
|
+
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1787
|
+
};
|
|
1788
|
+
Object.setPrototypeOf(builder, proto);
|
|
1789
|
+
builder._generator = self;
|
|
1790
|
+
builder._styler = _styler;
|
|
1791
|
+
builder._isEmpty = _isEmpty;
|
|
1792
|
+
return builder;
|
|
1793
|
+
};
|
|
1794
|
+
const applyStyle = (self, string) => {
|
|
1795
|
+
if (self.level <= 0 || !string) {
|
|
1796
|
+
return self._isEmpty ? "" : string;
|
|
1797
|
+
}
|
|
1798
|
+
let styler = self._styler;
|
|
1799
|
+
if (styler === void 0) {
|
|
1800
|
+
return string;
|
|
1801
|
+
}
|
|
1802
|
+
const { openAll, closeAll } = styler;
|
|
1803
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
1804
|
+
while (styler !== void 0) {
|
|
1805
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
1806
|
+
styler = styler.parent;
|
|
1782
1807
|
}
|
|
1783
|
-
ansiStyles2.dim.open = originalDim;
|
|
1784
|
-
return str;
|
|
1785
1808
|
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
return
|
|
1809
|
+
const lfIndex = string.indexOf("\n");
|
|
1810
|
+
if (lfIndex !== -1) {
|
|
1811
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1812
|
+
}
|
|
1813
|
+
return openAll + string + closeAll;
|
|
1814
|
+
};
|
|
1815
|
+
let template;
|
|
1816
|
+
const chalkTag = (chalk2, ...strings) => {
|
|
1817
|
+
const [firstString] = strings;
|
|
1818
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
1819
|
+
return strings.join(" ");
|
|
1820
|
+
}
|
|
1821
|
+
const arguments_ = strings.slice(1);
|
|
1822
|
+
const parts = [firstString.raw[0]];
|
|
1823
|
+
for (let i = 1; i < firstString.length; i++) {
|
|
1824
|
+
parts.push(
|
|
1825
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1826
|
+
String(firstString.raw[i])
|
|
1827
|
+
);
|
|
1797
1828
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
const chalk =
|
|
1829
|
+
if (template === void 0) {
|
|
1830
|
+
template = requireTemplates();
|
|
1831
|
+
}
|
|
1832
|
+
return template(chalk2, parts.join(""));
|
|
1833
|
+
};
|
|
1834
|
+
Object.defineProperties(Chalk.prototype, styles);
|
|
1835
|
+
const chalk = Chalk();
|
|
1836
|
+
chalk.supportsColor = stdoutColor;
|
|
1837
|
+
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1838
|
+
chalk.stderr.supportsColor = stderrColor;
|
|
1839
|
+
var source = chalk;
|
|
1840
|
+
const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
1805
1841
|
const debug$2 = debugModule(`proc:${process.pid}:workerManager`);
|
|
1806
|
-
chalk.level = 3;
|
|
1842
|
+
chalk$1.level = 3;
|
|
1807
1843
|
class STSWorkerManager {
|
|
1808
1844
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1809
1845
|
constructor(app, options) {
|
|
@@ -1836,7 +1872,7 @@ class STSWorkerManager {
|
|
|
1836
1872
|
StopRunner: (runner) => __privateGet(this, _StopRunner).call(this, stsWorkerEx, runner),
|
|
1837
1873
|
Stop: async () => __privateGet(this, _StopWorker).call(this, stsWorkerEx)
|
|
1838
1874
|
};
|
|
1839
|
-
__privateGet(this, _STSInstrumentController).LogEx(chalk.yellow(`Creating new worker: [${stsWorkerEx.id}]`));
|
|
1875
|
+
__privateGet(this, _STSInstrumentController).LogEx(chalk$1.yellow(`Creating new worker: [${stsWorkerEx.id}]`));
|
|
1840
1876
|
console.log(`Adding worker: [${stsWorkerEx.id}]`);
|
|
1841
1877
|
stsWorkerEx.worker.onmessage = function(data) {
|
|
1842
1878
|
console.log(data.data);
|
|
@@ -1878,7 +1914,7 @@ class STSWorkerManager {
|
|
|
1878
1914
|
const runnerEx = __privateGet(this, _CreateAsyncRunner).call(this, stsWorkerEx, runnerOptions);
|
|
1879
1915
|
stsWorkerEx.runnersEx[runnerEx.id] = runnerEx;
|
|
1880
1916
|
__privateGet(this, _SetRunnerIntoWorker).call(this, stsWorkerEx, runnerEx);
|
|
1881
|
-
runnerEx.publishInstrumentController.LogEx(chalk.green(`Added runner: [${runnerEx.id}] into worker: [${stsWorkerEx.id}]`));
|
|
1917
|
+
runnerEx.publishInstrumentController.LogEx(chalk$1.green(`Added runner: [${runnerEx.id}] into worker: [${stsWorkerEx.id}]`));
|
|
1882
1918
|
return runnerEx;
|
|
1883
1919
|
});
|
|
1884
1920
|
__privateAdd(this, _SetRunnerIntoWorker, (workerEx, runnerEx) => {
|
|
@@ -1929,6 +1965,18 @@ class STSWorkerManager {
|
|
|
1929
1965
|
});
|
|
1930
1966
|
update = true;
|
|
1931
1967
|
}
|
|
1968
|
+
if (runner.instrumentData.authenticationErrorCount) {
|
|
1969
|
+
runnerEx.publishInstrumentController.UpdateInstrument(Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, {
|
|
1970
|
+
val: runnerEx.instrumentData.authenticationCount
|
|
1971
|
+
});
|
|
1972
|
+
update = true;
|
|
1973
|
+
}
|
|
1974
|
+
if (runner.instrumentData.authenticationRetryCount) {
|
|
1975
|
+
runnerEx.publishInstrumentController.UpdateInstrument(Gauge.AUTHENTICATION_RETRY_COUNT_GAUGE, {
|
|
1976
|
+
val: runnerEx.instrumentData.authenticationCount
|
|
1977
|
+
});
|
|
1978
|
+
update = true;
|
|
1979
|
+
}
|
|
1932
1980
|
if (runner.instrumentData.coreCount) {
|
|
1933
1981
|
runnerEx.publishInstrumentController.UpdateInstrument(Gauge.CORE_COUNT_GAUGE, {
|
|
1934
1982
|
val: runnerEx.instrumentData.coreCount
|
|
@@ -1996,7 +2044,7 @@ class STSWorkerManager {
|
|
|
1996
2044
|
});
|
|
1997
2045
|
__privateAdd(this, _CreateAsyncRunner, (workerEx, runnerOptions) => {
|
|
1998
2046
|
__privateWrapper(this, _runner)._++;
|
|
1999
|
-
__privateGet(this, _STSInstrumentController).LogEx(chalk.yellow(`Creating new async runner: [${__privateGet(this, _runner)}]`));
|
|
2047
|
+
__privateGet(this, _STSInstrumentController).LogEx(chalk$1.yellow(`Creating new async runner: [${__privateGet(this, _runner)}]`));
|
|
2000
2048
|
const asyncRunnerContext = {
|
|
2001
2049
|
nid: `${workerEx.workerThreadWorkerOptions.hostName}${ModelDelimeter.COMPONENT_SEPERATOR}${workerEx.workerThreadWorkerOptions.agentId}-${workerEx.workerThreadWorkerOptions.userAgent}${ModelDelimeter.NID_SEPERATOR}worker${workerEx.id}${ModelDelimeter.SEPERATOR}${__privateGet(this, _runner)}`,
|
|
2002
2050
|
id: __privateGet(this, _runner).toString(),
|
|
@@ -2016,6 +2064,8 @@ class STSWorkerManager {
|
|
|
2016
2064
|
errorCount: 0,
|
|
2017
2065
|
retryCount: 0,
|
|
2018
2066
|
authenticationCount: 0,
|
|
2067
|
+
authenticationErrorCount: 0,
|
|
2068
|
+
authenticationRetryCount: 0,
|
|
2019
2069
|
velocity: 0,
|
|
2020
2070
|
coreCount: 0,
|
|
2021
2071
|
timer: 0,
|