@optique/core 1.1.0-dev.2054 → 1.1.0-dev.2065
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/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/valueparser.cjs +1463 -0
- package/dist/valueparser.d.cts +241 -1
- package/dist/valueparser.d.ts +241 -1
- package/dist/valueparser.js +1462 -1
- package/package.json +1 -1
package/dist/valueparser.cjs
CHANGED
|
@@ -504,6 +504,1467 @@ function float(options = {}) {
|
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
506
|
}
|
|
507
|
+
const SI_MULTIPLIERS = {
|
|
508
|
+
b: 1,
|
|
509
|
+
kb: 1e3,
|
|
510
|
+
mb: 1e6,
|
|
511
|
+
gb: 1e9,
|
|
512
|
+
tb: 1e12,
|
|
513
|
+
pb: 1e15,
|
|
514
|
+
eb: 1e18
|
|
515
|
+
};
|
|
516
|
+
const IEC_MULTIPLIERS = {
|
|
517
|
+
b: 1,
|
|
518
|
+
kb: 1024,
|
|
519
|
+
mb: 1024 ** 2,
|
|
520
|
+
gb: 1024 ** 3,
|
|
521
|
+
tb: 1024 ** 4,
|
|
522
|
+
pb: 1024 ** 5,
|
|
523
|
+
eb: 1024 ** 6,
|
|
524
|
+
kib: 1024,
|
|
525
|
+
mib: 1024 ** 2,
|
|
526
|
+
gib: 1024 ** 3,
|
|
527
|
+
tib: 1024 ** 4,
|
|
528
|
+
pib: 1024 ** 5,
|
|
529
|
+
eib: 1024 ** 6
|
|
530
|
+
};
|
|
531
|
+
const IEC_ONLY_MULTIPLIERS = {
|
|
532
|
+
kib: 1024,
|
|
533
|
+
mib: 1024 ** 2,
|
|
534
|
+
gib: 1024 ** 3,
|
|
535
|
+
tib: 1024 ** 4,
|
|
536
|
+
pib: 1024 ** 5,
|
|
537
|
+
eib: 1024 ** 6
|
|
538
|
+
};
|
|
539
|
+
const FILE_SIZE_REGEX = /^([+-]?(?:\d+\.?\d*|\d*\.\d+))\s*([a-zA-Z]*)$/;
|
|
540
|
+
/**
|
|
541
|
+
* Formats `bytes` using the most readable unit from the given ordered list.
|
|
542
|
+
* Falls back to `"${bytes}B"`.
|
|
543
|
+
*
|
|
544
|
+
* A unit is chosen only when the formatted value round-trips exactly: the
|
|
545
|
+
* rounded quotient must lie in [1, 1000) and `rounded * size === bytes` must
|
|
546
|
+
* hold in float64 arithmetic. This guarantees `parse(format(x)) === x`.
|
|
547
|
+
*/
|
|
548
|
+
function formatWithUnits(bytes, units) {
|
|
549
|
+
if (bytes === 0) return "0B";
|
|
550
|
+
const absBytes = Math.abs(bytes);
|
|
551
|
+
for (const [unit, size] of units) {
|
|
552
|
+
if (absBytes < size) continue;
|
|
553
|
+
const v = bytes / size;
|
|
554
|
+
const rounded = Math.round(v * 100) / 100;
|
|
555
|
+
const absRounded = Math.abs(rounded);
|
|
556
|
+
if (absRounded >= 1 && absRounded < 1e3 && rounded * size === bytes) return `${rounded}${unit}`;
|
|
557
|
+
}
|
|
558
|
+
return `${bytes}B`;
|
|
559
|
+
}
|
|
560
|
+
const FORMAT_UNITS_DEFAULT = [
|
|
561
|
+
["EiB", 1024 ** 6],
|
|
562
|
+
["PiB", 1024 ** 5],
|
|
563
|
+
["TiB", 1024 ** 4],
|
|
564
|
+
["GiB", 1024 ** 3],
|
|
565
|
+
["MiB", 1024 ** 2],
|
|
566
|
+
["KiB", 1024],
|
|
567
|
+
["EB", 1e18],
|
|
568
|
+
["PB", 1e15],
|
|
569
|
+
["TB", 1e12],
|
|
570
|
+
["GB", 1e9],
|
|
571
|
+
["MB", 1e6],
|
|
572
|
+
["KB", 1e3]
|
|
573
|
+
];
|
|
574
|
+
const FORMAT_UNITS_SI_AS_BINARY = [
|
|
575
|
+
["EB", 1024 ** 6],
|
|
576
|
+
["PB", 1024 ** 5],
|
|
577
|
+
["TB", 1024 ** 4],
|
|
578
|
+
["GB", 1024 ** 3],
|
|
579
|
+
["MB", 1024 ** 2],
|
|
580
|
+
["KB", 1024]
|
|
581
|
+
];
|
|
582
|
+
const BIGINT_SI_MULTIPLIERS = {
|
|
583
|
+
b: 1n,
|
|
584
|
+
kb: 1000n,
|
|
585
|
+
mb: 1000000n,
|
|
586
|
+
gb: 1000000000n,
|
|
587
|
+
tb: 1000000000000n,
|
|
588
|
+
pb: 1000000000000000n,
|
|
589
|
+
eb: 1000000000000000000n
|
|
590
|
+
};
|
|
591
|
+
const BIGINT_IEC_MULTIPLIERS = {
|
|
592
|
+
b: 1n,
|
|
593
|
+
kb: 1024n,
|
|
594
|
+
mb: 1024n ** 2n,
|
|
595
|
+
gb: 1024n ** 3n,
|
|
596
|
+
tb: 1024n ** 4n,
|
|
597
|
+
pb: 1024n ** 5n,
|
|
598
|
+
eb: 1024n ** 6n,
|
|
599
|
+
kib: 1024n,
|
|
600
|
+
mib: 1024n ** 2n,
|
|
601
|
+
gib: 1024n ** 3n,
|
|
602
|
+
tib: 1024n ** 4n,
|
|
603
|
+
pib: 1024n ** 5n,
|
|
604
|
+
eib: 1024n ** 6n
|
|
605
|
+
};
|
|
606
|
+
const BIGINT_IEC_ONLY_MULTIPLIERS = {
|
|
607
|
+
kib: 1024n,
|
|
608
|
+
mib: 1024n ** 2n,
|
|
609
|
+
gib: 1024n ** 3n,
|
|
610
|
+
tib: 1024n ** 4n,
|
|
611
|
+
pib: 1024n ** 5n,
|
|
612
|
+
eib: 1024n ** 6n
|
|
613
|
+
};
|
|
614
|
+
const BIGINT_FORMAT_UNITS_DEFAULT = [
|
|
615
|
+
["EiB", 1024n ** 6n],
|
|
616
|
+
["PiB", 1024n ** 5n],
|
|
617
|
+
["TiB", 1024n ** 4n],
|
|
618
|
+
["GiB", 1024n ** 3n],
|
|
619
|
+
["MiB", 1024n ** 2n],
|
|
620
|
+
["KiB", 1024n],
|
|
621
|
+
["EB", 1000000000000000000n],
|
|
622
|
+
["PB", 1000000000000000n],
|
|
623
|
+
["TB", 1000000000000n],
|
|
624
|
+
["GB", 1000000000n],
|
|
625
|
+
["MB", 1000000n],
|
|
626
|
+
["KB", 1000n]
|
|
627
|
+
];
|
|
628
|
+
const BIGINT_FORMAT_UNITS_SI_AS_BINARY = [
|
|
629
|
+
["EB", 1024n ** 6n],
|
|
630
|
+
["PB", 1024n ** 5n],
|
|
631
|
+
["TB", 1024n ** 4n],
|
|
632
|
+
["GB", 1024n ** 3n],
|
|
633
|
+
["MB", 1024n ** 2n],
|
|
634
|
+
["KB", 1024n]
|
|
635
|
+
];
|
|
636
|
+
/**
|
|
637
|
+
* Formats a bigint byte count using the most readable unit. Falls back to
|
|
638
|
+
* `"${value}B"`. Tries exact integers, then 1 and 2 decimal places.
|
|
639
|
+
*/
|
|
640
|
+
function formatBigIntBytes(value, units) {
|
|
641
|
+
if (value === 0n) return "0B";
|
|
642
|
+
const absValue = value < 0n ? -value : value;
|
|
643
|
+
for (const [unit, size] of units) {
|
|
644
|
+
if (absValue < size) continue;
|
|
645
|
+
if (value % size === 0n) {
|
|
646
|
+
const v = value / size;
|
|
647
|
+
const absV = v < 0n ? -v : v;
|
|
648
|
+
if (absV >= 1n && absV < 1000n) return `${v}${unit}`;
|
|
649
|
+
}
|
|
650
|
+
const v100 = value * 100n;
|
|
651
|
+
if (v100 % size === 0n) {
|
|
652
|
+
const q = v100 / size;
|
|
653
|
+
const absQ = q < 0n ? -q : q;
|
|
654
|
+
if (absQ >= 100n && absQ < 100000n) {
|
|
655
|
+
const intPart = q / 100n;
|
|
656
|
+
const decPart = absQ % 100n;
|
|
657
|
+
if (decPart % 10n === 0n) return `${intPart}.${decPart / 10n}${unit}`;
|
|
658
|
+
return `${intPart}.${String(decPart).padStart(2, "0")}${unit}`;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return `${value}B`;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Core computation: parses `numStr` as a decimal rational, multiplies by
|
|
666
|
+
* `mBig`, and returns the exact integer result as a `bigint`, or `null` when
|
|
667
|
+
* the result would be fractional. The safe-integer range check is NOT applied
|
|
668
|
+
* here; callers add it as needed.
|
|
669
|
+
*/
|
|
670
|
+
function parseExactBytesRaw(numStr, mBig) {
|
|
671
|
+
const negative = numStr.startsWith("-");
|
|
672
|
+
const absStr = numStr.startsWith("+") || numStr.startsWith("-") ? numStr.slice(1) : numStr;
|
|
673
|
+
const dotIdx = absStr.indexOf(".");
|
|
674
|
+
const intPart = dotIdx < 0 ? absStr : absStr.slice(0, dotIdx);
|
|
675
|
+
const fracPart = dotIdx < 0 ? "" : absStr.slice(dotIdx + 1);
|
|
676
|
+
const numeratorStr = ((intPart || "0") + fracPart).replace(/^0+/, "") || "0";
|
|
677
|
+
const numerator = BigInt(numeratorStr) * (negative ? -1n : 1n);
|
|
678
|
+
const denominator = 10n ** BigInt(fracPart.length);
|
|
679
|
+
const bytesNumerator = numerator * mBig;
|
|
680
|
+
if (bytesNumerator % denominator !== 0n) return null;
|
|
681
|
+
return bytesNumerator / denominator;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Parses `numStr` as a decimal rational and multiplies by `multiplier`,
|
|
685
|
+
* returning the exact integer result as a safe `number`, or `null` when the
|
|
686
|
+
* result would be fractional or outside `Number.MAX_SAFE_INTEGER`.
|
|
687
|
+
*
|
|
688
|
+
* All arithmetic is performed with `bigint` to avoid float64 precision loss
|
|
689
|
+
* (e.g. `"1.0000000000000001"` must not silently round to `1`).
|
|
690
|
+
*/
|
|
691
|
+
function parseExactBytes(numStr, multiplier) {
|
|
692
|
+
const bytes = parseExactBytesRaw(numStr, BigInt(multiplier));
|
|
693
|
+
if (bytes == null) return null;
|
|
694
|
+
const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);
|
|
695
|
+
if (bytes < -maxSafe || bytes > maxSafe) return null;
|
|
696
|
+
return Number(bytes);
|
|
697
|
+
}
|
|
698
|
+
const FILE_SIZE_UNITS = [
|
|
699
|
+
"B",
|
|
700
|
+
"KB",
|
|
701
|
+
"MB",
|
|
702
|
+
"GB",
|
|
703
|
+
"TB",
|
|
704
|
+
"PB",
|
|
705
|
+
"EB",
|
|
706
|
+
"KiB",
|
|
707
|
+
"MiB",
|
|
708
|
+
"GiB",
|
|
709
|
+
"TiB",
|
|
710
|
+
"PiB",
|
|
711
|
+
"EiB"
|
|
712
|
+
];
|
|
713
|
+
/**
|
|
714
|
+
* Creates a {@link ValueParser} for human-readable file/data size strings such
|
|
715
|
+
* as `"10MB"`, `"1.5GiB"`, or `"512B"`. The parsed value is a `number` or
|
|
716
|
+
* `bigint` representing the equivalent byte count.
|
|
717
|
+
*
|
|
718
|
+
* Supported units:
|
|
719
|
+
*
|
|
720
|
+
* | Unit | Bytes (default) |
|
|
721
|
+
* |------|----------------|
|
|
722
|
+
* | B | 1 |
|
|
723
|
+
* | KB | 1 000 |
|
|
724
|
+
* | MB | 1 000 000 |
|
|
725
|
+
* | GB | 1 000 000 000 |
|
|
726
|
+
* | KiB | 1 024 |
|
|
727
|
+
* | MiB | 1 048 576 |
|
|
728
|
+
* | GiB | 1 073 741 824 |
|
|
729
|
+
* | … | … |
|
|
730
|
+
*
|
|
731
|
+
* Unit suffixes are matched case-insensitively, so `"1kb"`, `"1KB"`, and
|
|
732
|
+
* `"1Kb"` are all equivalent.
|
|
733
|
+
*
|
|
734
|
+
* @param options Configuration options for the file size parser.
|
|
735
|
+
* @returns A {@link ValueParser} that parses file size strings into byte
|
|
736
|
+
* counts.
|
|
737
|
+
* @throws {TypeError} If `type` is neither `"number"` nor `"bigint"`, if
|
|
738
|
+
* `metavar` is an empty string, if `allowNegative` or `siAsBinary` is not
|
|
739
|
+
* a boolean, or if `defaultUnit` is not a valid {@link FileSizeUnit}.
|
|
740
|
+
* @since 1.1.0
|
|
741
|
+
*/
|
|
742
|
+
function fileSize(options = {}) {
|
|
743
|
+
if (options.type !== void 0 && options.type !== "number" && options.type !== "bigint") throw new TypeError(`Expected type to be "number" or "bigint", but got: ${String(options.type)}.`);
|
|
744
|
+
const metavar = options.metavar ?? "SIZE";
|
|
745
|
+
require_nonempty.ensureNonEmptyString(metavar);
|
|
746
|
+
checkBooleanOption(options, "allowNegative");
|
|
747
|
+
checkBooleanOption(options, "siAsBinary");
|
|
748
|
+
checkEnumOption(options, "defaultUnit", FILE_SIZE_UNITS);
|
|
749
|
+
const siAsBinary = options.siAsBinary ?? false;
|
|
750
|
+
function invalidFormatError(input) {
|
|
751
|
+
return {
|
|
752
|
+
success: false,
|
|
753
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : require_message.message`Expected a file size like ${"10MB"} or ${"1.5GiB"}, but got ${input}.`
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
if (options.type === "bigint") {
|
|
757
|
+
const bigintMultiplierMap = siAsBinary ? BIGINT_IEC_MULTIPLIERS : {
|
|
758
|
+
...BIGINT_SI_MULTIPLIERS,
|
|
759
|
+
...BIGINT_IEC_ONLY_MULTIPLIERS
|
|
760
|
+
};
|
|
761
|
+
const bigintFormatUnits = siAsBinary ? BIGINT_FORMAT_UNITS_SI_AS_BINARY : BIGINT_FORMAT_UNITS_DEFAULT;
|
|
762
|
+
const numberFormatUnits = siAsBinary ? FORMAT_UNITS_SI_AS_BINARY : FORMAT_UNITS_DEFAULT;
|
|
763
|
+
return {
|
|
764
|
+
mode: "sync",
|
|
765
|
+
metavar,
|
|
766
|
+
placeholder: options.placeholder ?? 0n,
|
|
767
|
+
parse(input) {
|
|
768
|
+
const match = FILE_SIZE_REGEX.exec(input.trim());
|
|
769
|
+
if (match == null) return invalidFormatError(input);
|
|
770
|
+
const numStr = match[1];
|
|
771
|
+
const unitStr = match[2].toLowerCase();
|
|
772
|
+
let mBig;
|
|
773
|
+
if (unitStr === "") {
|
|
774
|
+
if (options.defaultUnit == null) return invalidFormatError(input);
|
|
775
|
+
mBig = bigintMultiplierMap[options.defaultUnit.toLowerCase()];
|
|
776
|
+
} else {
|
|
777
|
+
const m = bigintMultiplierMap[unitStr];
|
|
778
|
+
if (m == null) return invalidFormatError(input);
|
|
779
|
+
mBig = m;
|
|
780
|
+
}
|
|
781
|
+
const bytes = parseExactBytesRaw(numStr, mBig);
|
|
782
|
+
if (bytes == null) return invalidFormatError(input);
|
|
783
|
+
if (!(options.allowNegative ?? false) && bytes < 0n) return {
|
|
784
|
+
success: false,
|
|
785
|
+
error: options.errors?.negativeNotAllowed ? typeof options.errors.negativeNotAllowed === "function" ? options.errors.negativeNotAllowed(bytes) : options.errors.negativeNotAllowed : require_message.message`Expected a non-negative file size, but got ${input}.`
|
|
786
|
+
};
|
|
787
|
+
return {
|
|
788
|
+
success: true,
|
|
789
|
+
value: bytes
|
|
790
|
+
};
|
|
791
|
+
},
|
|
792
|
+
format(value) {
|
|
793
|
+
const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);
|
|
794
|
+
if (value >= -maxSafe && value <= maxSafe) return formatWithUnits(Number(value), numberFormatUnits);
|
|
795
|
+
return formatBigIntBytes(value, bigintFormatUnits);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
const multiplierMap = siAsBinary ? IEC_MULTIPLIERS : {
|
|
800
|
+
...SI_MULTIPLIERS,
|
|
801
|
+
...IEC_ONLY_MULTIPLIERS
|
|
802
|
+
};
|
|
803
|
+
const formatUnits = siAsBinary ? FORMAT_UNITS_SI_AS_BINARY : FORMAT_UNITS_DEFAULT;
|
|
804
|
+
return {
|
|
805
|
+
mode: "sync",
|
|
806
|
+
metavar,
|
|
807
|
+
placeholder: options.placeholder ?? 0,
|
|
808
|
+
parse(input) {
|
|
809
|
+
const match = FILE_SIZE_REGEX.exec(input.trim());
|
|
810
|
+
if (match == null) return invalidFormatError(input);
|
|
811
|
+
const numStr = match[1];
|
|
812
|
+
const unitStr = match[2].toLowerCase();
|
|
813
|
+
let multiplier;
|
|
814
|
+
if (unitStr === "") {
|
|
815
|
+
if (options.defaultUnit == null) return invalidFormatError(input);
|
|
816
|
+
multiplier = multiplierMap[options.defaultUnit.toLowerCase()];
|
|
817
|
+
} else {
|
|
818
|
+
const m = multiplierMap[unitStr];
|
|
819
|
+
if (m == null) return invalidFormatError(input);
|
|
820
|
+
multiplier = m;
|
|
821
|
+
}
|
|
822
|
+
const bytes = parseExactBytes(numStr, multiplier);
|
|
823
|
+
if (bytes == null) return invalidFormatError(input);
|
|
824
|
+
if (!(options.allowNegative ?? false) && bytes < 0) return {
|
|
825
|
+
success: false,
|
|
826
|
+
error: options.errors?.negativeNotAllowed ? typeof options.errors.negativeNotAllowed === "function" ? options.errors.negativeNotAllowed(bytes) : options.errors.negativeNotAllowed : require_message.message`Expected a non-negative file size, but got ${input}.`
|
|
827
|
+
};
|
|
828
|
+
return {
|
|
829
|
+
success: true,
|
|
830
|
+
value: bytes
|
|
831
|
+
};
|
|
832
|
+
},
|
|
833
|
+
format(value) {
|
|
834
|
+
return formatWithUnits(value, formatUnits);
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
const CSS_NAMED_COLORS = {
|
|
839
|
+
aliceblue: {
|
|
840
|
+
r: 240,
|
|
841
|
+
g: 248,
|
|
842
|
+
b: 255,
|
|
843
|
+
a: 1
|
|
844
|
+
},
|
|
845
|
+
antiquewhite: {
|
|
846
|
+
r: 250,
|
|
847
|
+
g: 235,
|
|
848
|
+
b: 215,
|
|
849
|
+
a: 1
|
|
850
|
+
},
|
|
851
|
+
aqua: {
|
|
852
|
+
r: 0,
|
|
853
|
+
g: 255,
|
|
854
|
+
b: 255,
|
|
855
|
+
a: 1
|
|
856
|
+
},
|
|
857
|
+
aquamarine: {
|
|
858
|
+
r: 127,
|
|
859
|
+
g: 255,
|
|
860
|
+
b: 212,
|
|
861
|
+
a: 1
|
|
862
|
+
},
|
|
863
|
+
azure: {
|
|
864
|
+
r: 240,
|
|
865
|
+
g: 255,
|
|
866
|
+
b: 255,
|
|
867
|
+
a: 1
|
|
868
|
+
},
|
|
869
|
+
beige: {
|
|
870
|
+
r: 245,
|
|
871
|
+
g: 245,
|
|
872
|
+
b: 220,
|
|
873
|
+
a: 1
|
|
874
|
+
},
|
|
875
|
+
bisque: {
|
|
876
|
+
r: 255,
|
|
877
|
+
g: 228,
|
|
878
|
+
b: 196,
|
|
879
|
+
a: 1
|
|
880
|
+
},
|
|
881
|
+
black: {
|
|
882
|
+
r: 0,
|
|
883
|
+
g: 0,
|
|
884
|
+
b: 0,
|
|
885
|
+
a: 1
|
|
886
|
+
},
|
|
887
|
+
blanchedalmond: {
|
|
888
|
+
r: 255,
|
|
889
|
+
g: 235,
|
|
890
|
+
b: 205,
|
|
891
|
+
a: 1
|
|
892
|
+
},
|
|
893
|
+
blue: {
|
|
894
|
+
r: 0,
|
|
895
|
+
g: 0,
|
|
896
|
+
b: 255,
|
|
897
|
+
a: 1
|
|
898
|
+
},
|
|
899
|
+
blueviolet: {
|
|
900
|
+
r: 138,
|
|
901
|
+
g: 43,
|
|
902
|
+
b: 226,
|
|
903
|
+
a: 1
|
|
904
|
+
},
|
|
905
|
+
brown: {
|
|
906
|
+
r: 165,
|
|
907
|
+
g: 42,
|
|
908
|
+
b: 42,
|
|
909
|
+
a: 1
|
|
910
|
+
},
|
|
911
|
+
burlywood: {
|
|
912
|
+
r: 222,
|
|
913
|
+
g: 184,
|
|
914
|
+
b: 135,
|
|
915
|
+
a: 1
|
|
916
|
+
},
|
|
917
|
+
cadetblue: {
|
|
918
|
+
r: 95,
|
|
919
|
+
g: 158,
|
|
920
|
+
b: 160,
|
|
921
|
+
a: 1
|
|
922
|
+
},
|
|
923
|
+
chartreuse: {
|
|
924
|
+
r: 127,
|
|
925
|
+
g: 255,
|
|
926
|
+
b: 0,
|
|
927
|
+
a: 1
|
|
928
|
+
},
|
|
929
|
+
chocolate: {
|
|
930
|
+
r: 210,
|
|
931
|
+
g: 105,
|
|
932
|
+
b: 30,
|
|
933
|
+
a: 1
|
|
934
|
+
},
|
|
935
|
+
coral: {
|
|
936
|
+
r: 255,
|
|
937
|
+
g: 127,
|
|
938
|
+
b: 80,
|
|
939
|
+
a: 1
|
|
940
|
+
},
|
|
941
|
+
cornflowerblue: {
|
|
942
|
+
r: 100,
|
|
943
|
+
g: 149,
|
|
944
|
+
b: 237,
|
|
945
|
+
a: 1
|
|
946
|
+
},
|
|
947
|
+
cornsilk: {
|
|
948
|
+
r: 255,
|
|
949
|
+
g: 248,
|
|
950
|
+
b: 220,
|
|
951
|
+
a: 1
|
|
952
|
+
},
|
|
953
|
+
crimson: {
|
|
954
|
+
r: 220,
|
|
955
|
+
g: 20,
|
|
956
|
+
b: 60,
|
|
957
|
+
a: 1
|
|
958
|
+
},
|
|
959
|
+
cyan: {
|
|
960
|
+
r: 0,
|
|
961
|
+
g: 255,
|
|
962
|
+
b: 255,
|
|
963
|
+
a: 1
|
|
964
|
+
},
|
|
965
|
+
darkblue: {
|
|
966
|
+
r: 0,
|
|
967
|
+
g: 0,
|
|
968
|
+
b: 139,
|
|
969
|
+
a: 1
|
|
970
|
+
},
|
|
971
|
+
darkcyan: {
|
|
972
|
+
r: 0,
|
|
973
|
+
g: 139,
|
|
974
|
+
b: 139,
|
|
975
|
+
a: 1
|
|
976
|
+
},
|
|
977
|
+
darkgoldenrod: {
|
|
978
|
+
r: 184,
|
|
979
|
+
g: 134,
|
|
980
|
+
b: 11,
|
|
981
|
+
a: 1
|
|
982
|
+
},
|
|
983
|
+
darkgray: {
|
|
984
|
+
r: 169,
|
|
985
|
+
g: 169,
|
|
986
|
+
b: 169,
|
|
987
|
+
a: 1
|
|
988
|
+
},
|
|
989
|
+
darkgreen: {
|
|
990
|
+
r: 0,
|
|
991
|
+
g: 100,
|
|
992
|
+
b: 0,
|
|
993
|
+
a: 1
|
|
994
|
+
},
|
|
995
|
+
darkgrey: {
|
|
996
|
+
r: 169,
|
|
997
|
+
g: 169,
|
|
998
|
+
b: 169,
|
|
999
|
+
a: 1
|
|
1000
|
+
},
|
|
1001
|
+
darkkhaki: {
|
|
1002
|
+
r: 189,
|
|
1003
|
+
g: 183,
|
|
1004
|
+
b: 107,
|
|
1005
|
+
a: 1
|
|
1006
|
+
},
|
|
1007
|
+
darkmagenta: {
|
|
1008
|
+
r: 139,
|
|
1009
|
+
g: 0,
|
|
1010
|
+
b: 139,
|
|
1011
|
+
a: 1
|
|
1012
|
+
},
|
|
1013
|
+
darkolivegreen: {
|
|
1014
|
+
r: 85,
|
|
1015
|
+
g: 107,
|
|
1016
|
+
b: 47,
|
|
1017
|
+
a: 1
|
|
1018
|
+
},
|
|
1019
|
+
darkorange: {
|
|
1020
|
+
r: 255,
|
|
1021
|
+
g: 140,
|
|
1022
|
+
b: 0,
|
|
1023
|
+
a: 1
|
|
1024
|
+
},
|
|
1025
|
+
darkorchid: {
|
|
1026
|
+
r: 153,
|
|
1027
|
+
g: 50,
|
|
1028
|
+
b: 204,
|
|
1029
|
+
a: 1
|
|
1030
|
+
},
|
|
1031
|
+
darkred: {
|
|
1032
|
+
r: 139,
|
|
1033
|
+
g: 0,
|
|
1034
|
+
b: 0,
|
|
1035
|
+
a: 1
|
|
1036
|
+
},
|
|
1037
|
+
darksalmon: {
|
|
1038
|
+
r: 233,
|
|
1039
|
+
g: 150,
|
|
1040
|
+
b: 122,
|
|
1041
|
+
a: 1
|
|
1042
|
+
},
|
|
1043
|
+
darkseagreen: {
|
|
1044
|
+
r: 143,
|
|
1045
|
+
g: 188,
|
|
1046
|
+
b: 143,
|
|
1047
|
+
a: 1
|
|
1048
|
+
},
|
|
1049
|
+
darkslateblue: {
|
|
1050
|
+
r: 72,
|
|
1051
|
+
g: 61,
|
|
1052
|
+
b: 139,
|
|
1053
|
+
a: 1
|
|
1054
|
+
},
|
|
1055
|
+
darkslategray: {
|
|
1056
|
+
r: 47,
|
|
1057
|
+
g: 79,
|
|
1058
|
+
b: 79,
|
|
1059
|
+
a: 1
|
|
1060
|
+
},
|
|
1061
|
+
darkslategrey: {
|
|
1062
|
+
r: 47,
|
|
1063
|
+
g: 79,
|
|
1064
|
+
b: 79,
|
|
1065
|
+
a: 1
|
|
1066
|
+
},
|
|
1067
|
+
darkturquoise: {
|
|
1068
|
+
r: 0,
|
|
1069
|
+
g: 206,
|
|
1070
|
+
b: 209,
|
|
1071
|
+
a: 1
|
|
1072
|
+
},
|
|
1073
|
+
darkviolet: {
|
|
1074
|
+
r: 148,
|
|
1075
|
+
g: 0,
|
|
1076
|
+
b: 211,
|
|
1077
|
+
a: 1
|
|
1078
|
+
},
|
|
1079
|
+
deeppink: {
|
|
1080
|
+
r: 255,
|
|
1081
|
+
g: 20,
|
|
1082
|
+
b: 147,
|
|
1083
|
+
a: 1
|
|
1084
|
+
},
|
|
1085
|
+
deepskyblue: {
|
|
1086
|
+
r: 0,
|
|
1087
|
+
g: 191,
|
|
1088
|
+
b: 255,
|
|
1089
|
+
a: 1
|
|
1090
|
+
},
|
|
1091
|
+
dimgray: {
|
|
1092
|
+
r: 105,
|
|
1093
|
+
g: 105,
|
|
1094
|
+
b: 105,
|
|
1095
|
+
a: 1
|
|
1096
|
+
},
|
|
1097
|
+
dimgrey: {
|
|
1098
|
+
r: 105,
|
|
1099
|
+
g: 105,
|
|
1100
|
+
b: 105,
|
|
1101
|
+
a: 1
|
|
1102
|
+
},
|
|
1103
|
+
dodgerblue: {
|
|
1104
|
+
r: 30,
|
|
1105
|
+
g: 144,
|
|
1106
|
+
b: 255,
|
|
1107
|
+
a: 1
|
|
1108
|
+
},
|
|
1109
|
+
firebrick: {
|
|
1110
|
+
r: 178,
|
|
1111
|
+
g: 34,
|
|
1112
|
+
b: 34,
|
|
1113
|
+
a: 1
|
|
1114
|
+
},
|
|
1115
|
+
floralwhite: {
|
|
1116
|
+
r: 255,
|
|
1117
|
+
g: 250,
|
|
1118
|
+
b: 240,
|
|
1119
|
+
a: 1
|
|
1120
|
+
},
|
|
1121
|
+
forestgreen: {
|
|
1122
|
+
r: 34,
|
|
1123
|
+
g: 139,
|
|
1124
|
+
b: 34,
|
|
1125
|
+
a: 1
|
|
1126
|
+
},
|
|
1127
|
+
fuchsia: {
|
|
1128
|
+
r: 255,
|
|
1129
|
+
g: 0,
|
|
1130
|
+
b: 255,
|
|
1131
|
+
a: 1
|
|
1132
|
+
},
|
|
1133
|
+
gainsboro: {
|
|
1134
|
+
r: 220,
|
|
1135
|
+
g: 220,
|
|
1136
|
+
b: 220,
|
|
1137
|
+
a: 1
|
|
1138
|
+
},
|
|
1139
|
+
ghostwhite: {
|
|
1140
|
+
r: 248,
|
|
1141
|
+
g: 248,
|
|
1142
|
+
b: 255,
|
|
1143
|
+
a: 1
|
|
1144
|
+
},
|
|
1145
|
+
gold: {
|
|
1146
|
+
r: 255,
|
|
1147
|
+
g: 215,
|
|
1148
|
+
b: 0,
|
|
1149
|
+
a: 1
|
|
1150
|
+
},
|
|
1151
|
+
goldenrod: {
|
|
1152
|
+
r: 218,
|
|
1153
|
+
g: 165,
|
|
1154
|
+
b: 32,
|
|
1155
|
+
a: 1
|
|
1156
|
+
},
|
|
1157
|
+
gray: {
|
|
1158
|
+
r: 128,
|
|
1159
|
+
g: 128,
|
|
1160
|
+
b: 128,
|
|
1161
|
+
a: 1
|
|
1162
|
+
},
|
|
1163
|
+
green: {
|
|
1164
|
+
r: 0,
|
|
1165
|
+
g: 128,
|
|
1166
|
+
b: 0,
|
|
1167
|
+
a: 1
|
|
1168
|
+
},
|
|
1169
|
+
greenyellow: {
|
|
1170
|
+
r: 173,
|
|
1171
|
+
g: 255,
|
|
1172
|
+
b: 47,
|
|
1173
|
+
a: 1
|
|
1174
|
+
},
|
|
1175
|
+
grey: {
|
|
1176
|
+
r: 128,
|
|
1177
|
+
g: 128,
|
|
1178
|
+
b: 128,
|
|
1179
|
+
a: 1
|
|
1180
|
+
},
|
|
1181
|
+
honeydew: {
|
|
1182
|
+
r: 240,
|
|
1183
|
+
g: 255,
|
|
1184
|
+
b: 240,
|
|
1185
|
+
a: 1
|
|
1186
|
+
},
|
|
1187
|
+
hotpink: {
|
|
1188
|
+
r: 255,
|
|
1189
|
+
g: 105,
|
|
1190
|
+
b: 180,
|
|
1191
|
+
a: 1
|
|
1192
|
+
},
|
|
1193
|
+
indianred: {
|
|
1194
|
+
r: 205,
|
|
1195
|
+
g: 92,
|
|
1196
|
+
b: 92,
|
|
1197
|
+
a: 1
|
|
1198
|
+
},
|
|
1199
|
+
indigo: {
|
|
1200
|
+
r: 75,
|
|
1201
|
+
g: 0,
|
|
1202
|
+
b: 130,
|
|
1203
|
+
a: 1
|
|
1204
|
+
},
|
|
1205
|
+
ivory: {
|
|
1206
|
+
r: 255,
|
|
1207
|
+
g: 255,
|
|
1208
|
+
b: 240,
|
|
1209
|
+
a: 1
|
|
1210
|
+
},
|
|
1211
|
+
khaki: {
|
|
1212
|
+
r: 240,
|
|
1213
|
+
g: 230,
|
|
1214
|
+
b: 140,
|
|
1215
|
+
a: 1
|
|
1216
|
+
},
|
|
1217
|
+
lavender: {
|
|
1218
|
+
r: 230,
|
|
1219
|
+
g: 230,
|
|
1220
|
+
b: 250,
|
|
1221
|
+
a: 1
|
|
1222
|
+
},
|
|
1223
|
+
lavenderblush: {
|
|
1224
|
+
r: 255,
|
|
1225
|
+
g: 240,
|
|
1226
|
+
b: 245,
|
|
1227
|
+
a: 1
|
|
1228
|
+
},
|
|
1229
|
+
lawngreen: {
|
|
1230
|
+
r: 124,
|
|
1231
|
+
g: 252,
|
|
1232
|
+
b: 0,
|
|
1233
|
+
a: 1
|
|
1234
|
+
},
|
|
1235
|
+
lemonchiffon: {
|
|
1236
|
+
r: 255,
|
|
1237
|
+
g: 250,
|
|
1238
|
+
b: 205,
|
|
1239
|
+
a: 1
|
|
1240
|
+
},
|
|
1241
|
+
lightblue: {
|
|
1242
|
+
r: 173,
|
|
1243
|
+
g: 216,
|
|
1244
|
+
b: 230,
|
|
1245
|
+
a: 1
|
|
1246
|
+
},
|
|
1247
|
+
lightcoral: {
|
|
1248
|
+
r: 240,
|
|
1249
|
+
g: 128,
|
|
1250
|
+
b: 128,
|
|
1251
|
+
a: 1
|
|
1252
|
+
},
|
|
1253
|
+
lightcyan: {
|
|
1254
|
+
r: 224,
|
|
1255
|
+
g: 255,
|
|
1256
|
+
b: 255,
|
|
1257
|
+
a: 1
|
|
1258
|
+
},
|
|
1259
|
+
lightgoldenrodyellow: {
|
|
1260
|
+
r: 250,
|
|
1261
|
+
g: 250,
|
|
1262
|
+
b: 210,
|
|
1263
|
+
a: 1
|
|
1264
|
+
},
|
|
1265
|
+
lightgray: {
|
|
1266
|
+
r: 211,
|
|
1267
|
+
g: 211,
|
|
1268
|
+
b: 211,
|
|
1269
|
+
a: 1
|
|
1270
|
+
},
|
|
1271
|
+
lightgreen: {
|
|
1272
|
+
r: 144,
|
|
1273
|
+
g: 238,
|
|
1274
|
+
b: 144,
|
|
1275
|
+
a: 1
|
|
1276
|
+
},
|
|
1277
|
+
lightgrey: {
|
|
1278
|
+
r: 211,
|
|
1279
|
+
g: 211,
|
|
1280
|
+
b: 211,
|
|
1281
|
+
a: 1
|
|
1282
|
+
},
|
|
1283
|
+
lightpink: {
|
|
1284
|
+
r: 255,
|
|
1285
|
+
g: 182,
|
|
1286
|
+
b: 193,
|
|
1287
|
+
a: 1
|
|
1288
|
+
},
|
|
1289
|
+
lightsalmon: {
|
|
1290
|
+
r: 255,
|
|
1291
|
+
g: 160,
|
|
1292
|
+
b: 122,
|
|
1293
|
+
a: 1
|
|
1294
|
+
},
|
|
1295
|
+
lightseagreen: {
|
|
1296
|
+
r: 32,
|
|
1297
|
+
g: 178,
|
|
1298
|
+
b: 170,
|
|
1299
|
+
a: 1
|
|
1300
|
+
},
|
|
1301
|
+
lightskyblue: {
|
|
1302
|
+
r: 135,
|
|
1303
|
+
g: 206,
|
|
1304
|
+
b: 250,
|
|
1305
|
+
a: 1
|
|
1306
|
+
},
|
|
1307
|
+
lightslategray: {
|
|
1308
|
+
r: 119,
|
|
1309
|
+
g: 136,
|
|
1310
|
+
b: 153,
|
|
1311
|
+
a: 1
|
|
1312
|
+
},
|
|
1313
|
+
lightslategrey: {
|
|
1314
|
+
r: 119,
|
|
1315
|
+
g: 136,
|
|
1316
|
+
b: 153,
|
|
1317
|
+
a: 1
|
|
1318
|
+
},
|
|
1319
|
+
lightsteelblue: {
|
|
1320
|
+
r: 176,
|
|
1321
|
+
g: 196,
|
|
1322
|
+
b: 222,
|
|
1323
|
+
a: 1
|
|
1324
|
+
},
|
|
1325
|
+
lightyellow: {
|
|
1326
|
+
r: 255,
|
|
1327
|
+
g: 255,
|
|
1328
|
+
b: 224,
|
|
1329
|
+
a: 1
|
|
1330
|
+
},
|
|
1331
|
+
lime: {
|
|
1332
|
+
r: 0,
|
|
1333
|
+
g: 255,
|
|
1334
|
+
b: 0,
|
|
1335
|
+
a: 1
|
|
1336
|
+
},
|
|
1337
|
+
limegreen: {
|
|
1338
|
+
r: 50,
|
|
1339
|
+
g: 205,
|
|
1340
|
+
b: 50,
|
|
1341
|
+
a: 1
|
|
1342
|
+
},
|
|
1343
|
+
linen: {
|
|
1344
|
+
r: 250,
|
|
1345
|
+
g: 240,
|
|
1346
|
+
b: 230,
|
|
1347
|
+
a: 1
|
|
1348
|
+
},
|
|
1349
|
+
magenta: {
|
|
1350
|
+
r: 255,
|
|
1351
|
+
g: 0,
|
|
1352
|
+
b: 255,
|
|
1353
|
+
a: 1
|
|
1354
|
+
},
|
|
1355
|
+
maroon: {
|
|
1356
|
+
r: 128,
|
|
1357
|
+
g: 0,
|
|
1358
|
+
b: 0,
|
|
1359
|
+
a: 1
|
|
1360
|
+
},
|
|
1361
|
+
mediumaquamarine: {
|
|
1362
|
+
r: 102,
|
|
1363
|
+
g: 205,
|
|
1364
|
+
b: 170,
|
|
1365
|
+
a: 1
|
|
1366
|
+
},
|
|
1367
|
+
mediumblue: {
|
|
1368
|
+
r: 0,
|
|
1369
|
+
g: 0,
|
|
1370
|
+
b: 205,
|
|
1371
|
+
a: 1
|
|
1372
|
+
},
|
|
1373
|
+
mediumorchid: {
|
|
1374
|
+
r: 186,
|
|
1375
|
+
g: 85,
|
|
1376
|
+
b: 211,
|
|
1377
|
+
a: 1
|
|
1378
|
+
},
|
|
1379
|
+
mediumpurple: {
|
|
1380
|
+
r: 147,
|
|
1381
|
+
g: 112,
|
|
1382
|
+
b: 219,
|
|
1383
|
+
a: 1
|
|
1384
|
+
},
|
|
1385
|
+
mediumseagreen: {
|
|
1386
|
+
r: 60,
|
|
1387
|
+
g: 179,
|
|
1388
|
+
b: 113,
|
|
1389
|
+
a: 1
|
|
1390
|
+
},
|
|
1391
|
+
mediumslateblue: {
|
|
1392
|
+
r: 123,
|
|
1393
|
+
g: 104,
|
|
1394
|
+
b: 238,
|
|
1395
|
+
a: 1
|
|
1396
|
+
},
|
|
1397
|
+
mediumspringgreen: {
|
|
1398
|
+
r: 0,
|
|
1399
|
+
g: 250,
|
|
1400
|
+
b: 154,
|
|
1401
|
+
a: 1
|
|
1402
|
+
},
|
|
1403
|
+
mediumturquoise: {
|
|
1404
|
+
r: 72,
|
|
1405
|
+
g: 209,
|
|
1406
|
+
b: 204,
|
|
1407
|
+
a: 1
|
|
1408
|
+
},
|
|
1409
|
+
mediumvioletred: {
|
|
1410
|
+
r: 199,
|
|
1411
|
+
g: 21,
|
|
1412
|
+
b: 133,
|
|
1413
|
+
a: 1
|
|
1414
|
+
},
|
|
1415
|
+
midnightblue: {
|
|
1416
|
+
r: 25,
|
|
1417
|
+
g: 25,
|
|
1418
|
+
b: 112,
|
|
1419
|
+
a: 1
|
|
1420
|
+
},
|
|
1421
|
+
mintcream: {
|
|
1422
|
+
r: 245,
|
|
1423
|
+
g: 255,
|
|
1424
|
+
b: 250,
|
|
1425
|
+
a: 1
|
|
1426
|
+
},
|
|
1427
|
+
mistyrose: {
|
|
1428
|
+
r: 255,
|
|
1429
|
+
g: 228,
|
|
1430
|
+
b: 225,
|
|
1431
|
+
a: 1
|
|
1432
|
+
},
|
|
1433
|
+
moccasin: {
|
|
1434
|
+
r: 255,
|
|
1435
|
+
g: 228,
|
|
1436
|
+
b: 181,
|
|
1437
|
+
a: 1
|
|
1438
|
+
},
|
|
1439
|
+
navajowhite: {
|
|
1440
|
+
r: 255,
|
|
1441
|
+
g: 222,
|
|
1442
|
+
b: 173,
|
|
1443
|
+
a: 1
|
|
1444
|
+
},
|
|
1445
|
+
navy: {
|
|
1446
|
+
r: 0,
|
|
1447
|
+
g: 0,
|
|
1448
|
+
b: 128,
|
|
1449
|
+
a: 1
|
|
1450
|
+
},
|
|
1451
|
+
oldlace: {
|
|
1452
|
+
r: 253,
|
|
1453
|
+
g: 245,
|
|
1454
|
+
b: 230,
|
|
1455
|
+
a: 1
|
|
1456
|
+
},
|
|
1457
|
+
olive: {
|
|
1458
|
+
r: 128,
|
|
1459
|
+
g: 128,
|
|
1460
|
+
b: 0,
|
|
1461
|
+
a: 1
|
|
1462
|
+
},
|
|
1463
|
+
olivedrab: {
|
|
1464
|
+
r: 107,
|
|
1465
|
+
g: 142,
|
|
1466
|
+
b: 35,
|
|
1467
|
+
a: 1
|
|
1468
|
+
},
|
|
1469
|
+
orange: {
|
|
1470
|
+
r: 255,
|
|
1471
|
+
g: 165,
|
|
1472
|
+
b: 0,
|
|
1473
|
+
a: 1
|
|
1474
|
+
},
|
|
1475
|
+
orangered: {
|
|
1476
|
+
r: 255,
|
|
1477
|
+
g: 69,
|
|
1478
|
+
b: 0,
|
|
1479
|
+
a: 1
|
|
1480
|
+
},
|
|
1481
|
+
orchid: {
|
|
1482
|
+
r: 218,
|
|
1483
|
+
g: 112,
|
|
1484
|
+
b: 214,
|
|
1485
|
+
a: 1
|
|
1486
|
+
},
|
|
1487
|
+
palegoldenrod: {
|
|
1488
|
+
r: 238,
|
|
1489
|
+
g: 232,
|
|
1490
|
+
b: 170,
|
|
1491
|
+
a: 1
|
|
1492
|
+
},
|
|
1493
|
+
palegreen: {
|
|
1494
|
+
r: 152,
|
|
1495
|
+
g: 251,
|
|
1496
|
+
b: 152,
|
|
1497
|
+
a: 1
|
|
1498
|
+
},
|
|
1499
|
+
paleturquoise: {
|
|
1500
|
+
r: 175,
|
|
1501
|
+
g: 238,
|
|
1502
|
+
b: 238,
|
|
1503
|
+
a: 1
|
|
1504
|
+
},
|
|
1505
|
+
palevioletred: {
|
|
1506
|
+
r: 219,
|
|
1507
|
+
g: 112,
|
|
1508
|
+
b: 147,
|
|
1509
|
+
a: 1
|
|
1510
|
+
},
|
|
1511
|
+
papayawhip: {
|
|
1512
|
+
r: 255,
|
|
1513
|
+
g: 239,
|
|
1514
|
+
b: 213,
|
|
1515
|
+
a: 1
|
|
1516
|
+
},
|
|
1517
|
+
peachpuff: {
|
|
1518
|
+
r: 255,
|
|
1519
|
+
g: 218,
|
|
1520
|
+
b: 185,
|
|
1521
|
+
a: 1
|
|
1522
|
+
},
|
|
1523
|
+
peru: {
|
|
1524
|
+
r: 205,
|
|
1525
|
+
g: 133,
|
|
1526
|
+
b: 63,
|
|
1527
|
+
a: 1
|
|
1528
|
+
},
|
|
1529
|
+
pink: {
|
|
1530
|
+
r: 255,
|
|
1531
|
+
g: 192,
|
|
1532
|
+
b: 203,
|
|
1533
|
+
a: 1
|
|
1534
|
+
},
|
|
1535
|
+
plum: {
|
|
1536
|
+
r: 221,
|
|
1537
|
+
g: 160,
|
|
1538
|
+
b: 221,
|
|
1539
|
+
a: 1
|
|
1540
|
+
},
|
|
1541
|
+
powderblue: {
|
|
1542
|
+
r: 176,
|
|
1543
|
+
g: 224,
|
|
1544
|
+
b: 230,
|
|
1545
|
+
a: 1
|
|
1546
|
+
},
|
|
1547
|
+
purple: {
|
|
1548
|
+
r: 128,
|
|
1549
|
+
g: 0,
|
|
1550
|
+
b: 128,
|
|
1551
|
+
a: 1
|
|
1552
|
+
},
|
|
1553
|
+
rebeccapurple: {
|
|
1554
|
+
r: 102,
|
|
1555
|
+
g: 51,
|
|
1556
|
+
b: 153,
|
|
1557
|
+
a: 1
|
|
1558
|
+
},
|
|
1559
|
+
red: {
|
|
1560
|
+
r: 255,
|
|
1561
|
+
g: 0,
|
|
1562
|
+
b: 0,
|
|
1563
|
+
a: 1
|
|
1564
|
+
},
|
|
1565
|
+
rosybrown: {
|
|
1566
|
+
r: 188,
|
|
1567
|
+
g: 143,
|
|
1568
|
+
b: 143,
|
|
1569
|
+
a: 1
|
|
1570
|
+
},
|
|
1571
|
+
royalblue: {
|
|
1572
|
+
r: 65,
|
|
1573
|
+
g: 105,
|
|
1574
|
+
b: 225,
|
|
1575
|
+
a: 1
|
|
1576
|
+
},
|
|
1577
|
+
saddlebrown: {
|
|
1578
|
+
r: 139,
|
|
1579
|
+
g: 69,
|
|
1580
|
+
b: 19,
|
|
1581
|
+
a: 1
|
|
1582
|
+
},
|
|
1583
|
+
salmon: {
|
|
1584
|
+
r: 250,
|
|
1585
|
+
g: 128,
|
|
1586
|
+
b: 114,
|
|
1587
|
+
a: 1
|
|
1588
|
+
},
|
|
1589
|
+
sandybrown: {
|
|
1590
|
+
r: 244,
|
|
1591
|
+
g: 164,
|
|
1592
|
+
b: 96,
|
|
1593
|
+
a: 1
|
|
1594
|
+
},
|
|
1595
|
+
seagreen: {
|
|
1596
|
+
r: 46,
|
|
1597
|
+
g: 139,
|
|
1598
|
+
b: 87,
|
|
1599
|
+
a: 1
|
|
1600
|
+
},
|
|
1601
|
+
seashell: {
|
|
1602
|
+
r: 255,
|
|
1603
|
+
g: 245,
|
|
1604
|
+
b: 238,
|
|
1605
|
+
a: 1
|
|
1606
|
+
},
|
|
1607
|
+
sienna: {
|
|
1608
|
+
r: 160,
|
|
1609
|
+
g: 82,
|
|
1610
|
+
b: 45,
|
|
1611
|
+
a: 1
|
|
1612
|
+
},
|
|
1613
|
+
silver: {
|
|
1614
|
+
r: 192,
|
|
1615
|
+
g: 192,
|
|
1616
|
+
b: 192,
|
|
1617
|
+
a: 1
|
|
1618
|
+
},
|
|
1619
|
+
skyblue: {
|
|
1620
|
+
r: 135,
|
|
1621
|
+
g: 206,
|
|
1622
|
+
b: 235,
|
|
1623
|
+
a: 1
|
|
1624
|
+
},
|
|
1625
|
+
slateblue: {
|
|
1626
|
+
r: 106,
|
|
1627
|
+
g: 90,
|
|
1628
|
+
b: 205,
|
|
1629
|
+
a: 1
|
|
1630
|
+
},
|
|
1631
|
+
slategray: {
|
|
1632
|
+
r: 112,
|
|
1633
|
+
g: 128,
|
|
1634
|
+
b: 144,
|
|
1635
|
+
a: 1
|
|
1636
|
+
},
|
|
1637
|
+
slategrey: {
|
|
1638
|
+
r: 112,
|
|
1639
|
+
g: 128,
|
|
1640
|
+
b: 144,
|
|
1641
|
+
a: 1
|
|
1642
|
+
},
|
|
1643
|
+
snow: {
|
|
1644
|
+
r: 255,
|
|
1645
|
+
g: 250,
|
|
1646
|
+
b: 250,
|
|
1647
|
+
a: 1
|
|
1648
|
+
},
|
|
1649
|
+
springgreen: {
|
|
1650
|
+
r: 0,
|
|
1651
|
+
g: 255,
|
|
1652
|
+
b: 127,
|
|
1653
|
+
a: 1
|
|
1654
|
+
},
|
|
1655
|
+
steelblue: {
|
|
1656
|
+
r: 70,
|
|
1657
|
+
g: 130,
|
|
1658
|
+
b: 180,
|
|
1659
|
+
a: 1
|
|
1660
|
+
},
|
|
1661
|
+
tan: {
|
|
1662
|
+
r: 210,
|
|
1663
|
+
g: 180,
|
|
1664
|
+
b: 140,
|
|
1665
|
+
a: 1
|
|
1666
|
+
},
|
|
1667
|
+
teal: {
|
|
1668
|
+
r: 0,
|
|
1669
|
+
g: 128,
|
|
1670
|
+
b: 128,
|
|
1671
|
+
a: 1
|
|
1672
|
+
},
|
|
1673
|
+
thistle: {
|
|
1674
|
+
r: 216,
|
|
1675
|
+
g: 191,
|
|
1676
|
+
b: 216,
|
|
1677
|
+
a: 1
|
|
1678
|
+
},
|
|
1679
|
+
tomato: {
|
|
1680
|
+
r: 255,
|
|
1681
|
+
g: 99,
|
|
1682
|
+
b: 71,
|
|
1683
|
+
a: 1
|
|
1684
|
+
},
|
|
1685
|
+
transparent: {
|
|
1686
|
+
r: 0,
|
|
1687
|
+
g: 0,
|
|
1688
|
+
b: 0,
|
|
1689
|
+
a: 0
|
|
1690
|
+
},
|
|
1691
|
+
turquoise: {
|
|
1692
|
+
r: 64,
|
|
1693
|
+
g: 224,
|
|
1694
|
+
b: 208,
|
|
1695
|
+
a: 1
|
|
1696
|
+
},
|
|
1697
|
+
violet: {
|
|
1698
|
+
r: 238,
|
|
1699
|
+
g: 130,
|
|
1700
|
+
b: 238,
|
|
1701
|
+
a: 1
|
|
1702
|
+
},
|
|
1703
|
+
wheat: {
|
|
1704
|
+
r: 245,
|
|
1705
|
+
g: 222,
|
|
1706
|
+
b: 179,
|
|
1707
|
+
a: 1
|
|
1708
|
+
},
|
|
1709
|
+
white: {
|
|
1710
|
+
r: 255,
|
|
1711
|
+
g: 255,
|
|
1712
|
+
b: 255,
|
|
1713
|
+
a: 1
|
|
1714
|
+
},
|
|
1715
|
+
whitesmoke: {
|
|
1716
|
+
r: 245,
|
|
1717
|
+
g: 245,
|
|
1718
|
+
b: 245,
|
|
1719
|
+
a: 1
|
|
1720
|
+
},
|
|
1721
|
+
yellow: {
|
|
1722
|
+
r: 255,
|
|
1723
|
+
g: 255,
|
|
1724
|
+
b: 0,
|
|
1725
|
+
a: 1
|
|
1726
|
+
},
|
|
1727
|
+
yellowgreen: {
|
|
1728
|
+
r: 154,
|
|
1729
|
+
g: 205,
|
|
1730
|
+
b: 50,
|
|
1731
|
+
a: 1
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
const CSS_NAMED_COLOR_KEYS = Object.keys(CSS_NAMED_COLORS);
|
|
1735
|
+
function hslToRgb(h, s, l) {
|
|
1736
|
+
h = (h % 360 + 360) % 360;
|
|
1737
|
+
const a = s * Math.min(l, 1 - l);
|
|
1738
|
+
const f = (n) => {
|
|
1739
|
+
const k = (n + h / 30) % 12;
|
|
1740
|
+
return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
|
|
1741
|
+
};
|
|
1742
|
+
return [
|
|
1743
|
+
Math.round(f(0) * 255),
|
|
1744
|
+
Math.round(f(8) * 255),
|
|
1745
|
+
Math.round(f(4) * 255)
|
|
1746
|
+
];
|
|
1747
|
+
}
|
|
1748
|
+
function rgbToHsl(r, g, b) {
|
|
1749
|
+
const rn = r / 255, gn = g / 255, bn = b / 255;
|
|
1750
|
+
const max = Math.max(rn, gn, bn);
|
|
1751
|
+
const min = Math.min(rn, gn, bn);
|
|
1752
|
+
const l = (max + min) / 2;
|
|
1753
|
+
if (max === min) return [
|
|
1754
|
+
0,
|
|
1755
|
+
0,
|
|
1756
|
+
l * 100
|
|
1757
|
+
];
|
|
1758
|
+
const d = max - min;
|
|
1759
|
+
const s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
1760
|
+
let h;
|
|
1761
|
+
if (max === rn) h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;
|
|
1762
|
+
else if (max === gn) h = ((bn - rn) / d + 2) / 6;
|
|
1763
|
+
else h = ((rn - gn) / d + 4) / 6;
|
|
1764
|
+
return [
|
|
1765
|
+
h * 360,
|
|
1766
|
+
s * 100,
|
|
1767
|
+
l * 100
|
|
1768
|
+
];
|
|
1769
|
+
}
|
|
1770
|
+
const COLOR_HEX_SHORT_REGEX = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/;
|
|
1771
|
+
const COLOR_HEX_LONG_REGEX = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/;
|
|
1772
|
+
const COLOR_NUM_PATTERN = "(?:\\d+(?:\\.\\d*)?|\\d*\\.\\d+)";
|
|
1773
|
+
const COLOR_HUE_PATTERN = `(?:-?${COLOR_NUM_PATTERN})`;
|
|
1774
|
+
const COLOR_RGB_REGEX = new RegExp(`^rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*(?:,\\s*(${COLOR_NUM_PATTERN}))?\\s*\\)$`, "i");
|
|
1775
|
+
const COLOR_HSL_REGEX = new RegExp(`^hsla?\\(\\s*(${COLOR_HUE_PATTERN})\\s*,\\s*(${COLOR_NUM_PATTERN})%\\s*,\\s*(${COLOR_NUM_PATTERN})%\\s*(?:,\\s*(${COLOR_NUM_PATTERN}))?\\s*\\)$`, "i");
|
|
1776
|
+
const VALID_COLOR_FORMATS = [
|
|
1777
|
+
"hex",
|
|
1778
|
+
"rgb",
|
|
1779
|
+
"hsl",
|
|
1780
|
+
"named"
|
|
1781
|
+
];
|
|
1782
|
+
/**
|
|
1783
|
+
* Creates a value parser that accepts CSS color strings and returns a
|
|
1784
|
+
* structured {@link Color} object with normalized RGBA components.
|
|
1785
|
+
*
|
|
1786
|
+
* Supported input notations by default:
|
|
1787
|
+
* - Hex: `#rgb`, `#rrggbb`, `#rgba`, `#rrggbbaa`
|
|
1788
|
+
* - RGB: `rgb(r, g, b)`, `rgba(r, g, b, a)`
|
|
1789
|
+
* - HSL: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
|
|
1790
|
+
* - Named: all 148 CSS Level 4 named colors (e.g., `red`, `rebeccapurple`)
|
|
1791
|
+
*
|
|
1792
|
+
* The `format()` method always outputs canonical lowercase hex
|
|
1793
|
+
* (`#rrggbb` when fully opaque, `#rrggbbaa` otherwise).
|
|
1794
|
+
*
|
|
1795
|
+
* @param options Configuration options for the parser.
|
|
1796
|
+
* @returns A sync value parser producing {@link Color} objects.
|
|
1797
|
+
* @throws {TypeError} If {@link ColorOptions.metavar} is an empty string, or
|
|
1798
|
+
* if {@link ColorOptions.formats} contains an invalid format name.
|
|
1799
|
+
* @throws {RangeError} If {@link ValueParser.format} is called with a
|
|
1800
|
+
* {@link Color} whose `r`, `g`, or `b` channel is not an integer in
|
|
1801
|
+
* 0–255, or whose `a` channel is not a finite number in 0–1.
|
|
1802
|
+
* @since 1.1.0
|
|
1803
|
+
*/
|
|
1804
|
+
function color(options = {}) {
|
|
1805
|
+
const metavar = options.metavar ?? "COLOR";
|
|
1806
|
+
require_nonempty.ensureNonEmptyString(metavar);
|
|
1807
|
+
if (options.formats !== void 0) {
|
|
1808
|
+
for (const fmt of options.formats) if (!VALID_COLOR_FORMATS.includes(fmt)) throw new TypeError(`Expected formats to contain only ${VALID_COLOR_FORMATS.map((v) => JSON.stringify(v)).join(", ")}, but got: ${JSON.stringify(fmt)}.`);
|
|
1809
|
+
}
|
|
1810
|
+
const allowedFormats = options.formats ?? VALID_COLOR_FORMATS;
|
|
1811
|
+
const allowHex = allowedFormats.includes("hex");
|
|
1812
|
+
const allowRgb = allowedFormats.includes("rgb");
|
|
1813
|
+
const allowHsl = allowedFormats.includes("hsl");
|
|
1814
|
+
const allowNamed = allowedFormats.includes("named");
|
|
1815
|
+
const defaultPlaceholder = {
|
|
1816
|
+
r: 0,
|
|
1817
|
+
g: 0,
|
|
1818
|
+
b: 0,
|
|
1819
|
+
a: 1
|
|
1820
|
+
};
|
|
1821
|
+
const formatExamples = [
|
|
1822
|
+
...allowHex ? ["#ff0000"] : [],
|
|
1823
|
+
...allowRgb ? ["rgb(255, 0, 0)"] : [],
|
|
1824
|
+
...allowHsl ? ["hsl(0, 100%, 50%)"] : [],
|
|
1825
|
+
...allowNamed ? ["red"] : []
|
|
1826
|
+
];
|
|
1827
|
+
function invalidFormatError(input) {
|
|
1828
|
+
return {
|
|
1829
|
+
success: false,
|
|
1830
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : require_message.message`Expected a CSS color like ${require_message.valueSet(formatExamples, {
|
|
1831
|
+
fallback: "a valid color",
|
|
1832
|
+
type: "disjunction"
|
|
1833
|
+
})}, but got ${input}.`
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
return {
|
|
1837
|
+
mode: "sync",
|
|
1838
|
+
metavar,
|
|
1839
|
+
placeholder: options.placeholder ?? defaultPlaceholder,
|
|
1840
|
+
parse(input) {
|
|
1841
|
+
const trimmed = input.trim();
|
|
1842
|
+
if (allowHex) {
|
|
1843
|
+
let m = COLOR_HEX_LONG_REGEX.exec(trimmed);
|
|
1844
|
+
if (m != null) {
|
|
1845
|
+
const r = parseInt(m[1], 16);
|
|
1846
|
+
const g = parseInt(m[2], 16);
|
|
1847
|
+
const b = parseInt(m[3], 16);
|
|
1848
|
+
const a = m[4] !== void 0 ? parseInt(m[4], 16) / 255 : 1;
|
|
1849
|
+
return {
|
|
1850
|
+
success: true,
|
|
1851
|
+
value: {
|
|
1852
|
+
r,
|
|
1853
|
+
g,
|
|
1854
|
+
b,
|
|
1855
|
+
a
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
m = COLOR_HEX_SHORT_REGEX.exec(trimmed);
|
|
1860
|
+
if (m != null) {
|
|
1861
|
+
const r = parseInt(m[1] + m[1], 16);
|
|
1862
|
+
const g = parseInt(m[2] + m[2], 16);
|
|
1863
|
+
const b = parseInt(m[3] + m[3], 16);
|
|
1864
|
+
const a = m[4] !== void 0 ? parseInt(m[4] + m[4], 16) / 255 : 1;
|
|
1865
|
+
return {
|
|
1866
|
+
success: true,
|
|
1867
|
+
value: {
|
|
1868
|
+
r,
|
|
1869
|
+
g,
|
|
1870
|
+
b,
|
|
1871
|
+
a
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
if (allowRgb) {
|
|
1877
|
+
const m = COLOR_RGB_REGEX.exec(trimmed);
|
|
1878
|
+
if (m != null) {
|
|
1879
|
+
const r = parseInt(m[1], 10);
|
|
1880
|
+
const g = parseInt(m[2], 10);
|
|
1881
|
+
const b = parseInt(m[3], 10);
|
|
1882
|
+
const aRaw = m[4] !== void 0 ? parseFloat(m[4]) : 1;
|
|
1883
|
+
if (r > 255 || g > 255 || b > 255 || !Number.isFinite(aRaw) || aRaw < 0 || aRaw > 1) return invalidFormatError(input);
|
|
1884
|
+
const a = Math.round(aRaw * 255) / 255;
|
|
1885
|
+
return {
|
|
1886
|
+
success: true,
|
|
1887
|
+
value: {
|
|
1888
|
+
r,
|
|
1889
|
+
g,
|
|
1890
|
+
b,
|
|
1891
|
+
a
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
if (allowHsl) {
|
|
1897
|
+
const m = COLOR_HSL_REGEX.exec(trimmed);
|
|
1898
|
+
if (m != null) {
|
|
1899
|
+
const h = parseFloat(m[1]);
|
|
1900
|
+
const s = parseFloat(m[2]);
|
|
1901
|
+
const l = parseFloat(m[3]);
|
|
1902
|
+
const aRaw = m[4] !== void 0 ? parseFloat(m[4]) : 1;
|
|
1903
|
+
if (!Number.isFinite(h) || !Number.isFinite(s) || s < 0 || s > 100 || !Number.isFinite(l) || l < 0 || l > 100 || !Number.isFinite(aRaw) || aRaw < 0 || aRaw > 1) return invalidFormatError(input);
|
|
1904
|
+
const [r, g, b] = hslToRgb(h, s / 100, l / 100);
|
|
1905
|
+
const a = Math.round(aRaw * 255) / 255;
|
|
1906
|
+
return {
|
|
1907
|
+
success: true,
|
|
1908
|
+
value: {
|
|
1909
|
+
r,
|
|
1910
|
+
g,
|
|
1911
|
+
b,
|
|
1912
|
+
a
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
if (allowNamed) {
|
|
1918
|
+
const key = trimmed.toLowerCase();
|
|
1919
|
+
if (Object.hasOwn(CSS_NAMED_COLORS, key)) return {
|
|
1920
|
+
success: true,
|
|
1921
|
+
value: { ...CSS_NAMED_COLORS[key] }
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
return invalidFormatError(input);
|
|
1925
|
+
},
|
|
1926
|
+
format(value) {
|
|
1927
|
+
const { r, g, b, a } = value;
|
|
1928
|
+
if (!Number.isInteger(r) || r < 0 || r > 255 || !Number.isInteger(g) || g < 0 || g > 255 || !Number.isInteger(b) || b < 0 || b > 255 || !Number.isFinite(a) || a < 0 || a > 1) throw new RangeError(`Color components out of range: r=${r}, g=${g}, b=${b}, a=${a}.`);
|
|
1929
|
+
const aStr = parseFloat(a.toFixed(4));
|
|
1930
|
+
if (allowHex) {
|
|
1931
|
+
const rh = r.toString(16).padStart(2, "0");
|
|
1932
|
+
const gh = g.toString(16).padStart(2, "0");
|
|
1933
|
+
const bh = b.toString(16).padStart(2, "0");
|
|
1934
|
+
if (a === 1) return `#${rh}${gh}${bh}`;
|
|
1935
|
+
const ah = Math.round(a * 255).toString(16).padStart(2, "0");
|
|
1936
|
+
return `#${rh}${gh}${bh}${ah}`;
|
|
1937
|
+
}
|
|
1938
|
+
if (allowRgb) return a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${aStr})`;
|
|
1939
|
+
if (allowHsl) {
|
|
1940
|
+
const [h, s, l] = rgbToHsl(r, g, b);
|
|
1941
|
+
const hStr = parseFloat(h.toFixed(4));
|
|
1942
|
+
const sStr = parseFloat(s.toFixed(4));
|
|
1943
|
+
const lStr = parseFloat(l.toFixed(4));
|
|
1944
|
+
return a === 1 ? `hsl(${hStr}, ${sStr}%, ${lStr}%)` : `hsla(${hStr}, ${sStr}%, ${lStr}%, ${aStr})`;
|
|
1945
|
+
}
|
|
1946
|
+
for (const [name, c] of Object.entries(CSS_NAMED_COLORS)) if (c.r === r && c.g === g && c.b === b && c.a === a) return name;
|
|
1947
|
+
throw new RangeError(`No CSS named color matches { r: ${r}, g: ${g}, b: ${b}, a: ${a} }.`);
|
|
1948
|
+
},
|
|
1949
|
+
normalize(value) {
|
|
1950
|
+
if (!Number.isInteger(value.r) || value.r < 0 || value.r > 255 || !Number.isInteger(value.g) || value.g < 0 || value.g > 255 || !Number.isInteger(value.b) || value.b < 0 || value.b > 255 || !Number.isFinite(value.a) || value.a < 0 || value.a > 1) return value;
|
|
1951
|
+
const a = Math.round(value.a * 255) / 255;
|
|
1952
|
+
return a === value.a ? value : {
|
|
1953
|
+
...value,
|
|
1954
|
+
a
|
|
1955
|
+
};
|
|
1956
|
+
},
|
|
1957
|
+
*suggest(prefix) {
|
|
1958
|
+
if (allowNamed) {
|
|
1959
|
+
const lowerPrefix = prefix.toLowerCase();
|
|
1960
|
+
for (const name of CSS_NAMED_COLOR_KEYS) if (name.startsWith(lowerPrefix)) yield {
|
|
1961
|
+
kind: "literal",
|
|
1962
|
+
text: name
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
507
1968
|
/**
|
|
508
1969
|
* The set of URL schemes that are considered "special" by the WHATWG URL
|
|
509
1970
|
* Standard. These schemes always use the `://` authority syntax.
|
|
@@ -3689,9 +5150,11 @@ exports.checkBooleanOption = checkBooleanOption;
|
|
|
3689
5150
|
exports.checkEnumOption = checkEnumOption;
|
|
3690
5151
|
exports.choice = choice;
|
|
3691
5152
|
exports.cidr = cidr;
|
|
5153
|
+
exports.color = color;
|
|
3692
5154
|
exports.domain = domain;
|
|
3693
5155
|
exports.email = email;
|
|
3694
5156
|
exports.ensureNonEmptyString = require_nonempty.ensureNonEmptyString;
|
|
5157
|
+
exports.fileSize = fileSize;
|
|
3695
5158
|
exports.float = float;
|
|
3696
5159
|
exports.hostname = hostname;
|
|
3697
5160
|
exports.integer = integer;
|