@terrazzo/plugin-css 0.9.1 → 0.10.0
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/CHANGELOG.md +26 -0
- package/dist/index.js +341 -75
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @terrazzo/plugin-css
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#507](https://github.com/terrazzoapp/terrazzo/pull/507) [`0060100`](https://github.com/terrazzoapp/terrazzo/commit/00601002a731dc009fb4ef2b438a01b087325a1a) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ Breaking change: remove HSV as a supported colorSpace, because it’s absent from CSS Color Module 4
|
|
8
|
+
|
|
9
|
+
- [#507](https://github.com/terrazzoapp/terrazzo/pull/507) [`0060100`](https://github.com/terrazzoapp/terrazzo/commit/00601002a731dc009fb4ef2b438a01b087325a1a) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ Breaking change: align color token ranges to CSS Color Module 4. This results in breaking changes to HSL and HWB, which normalize to `0 - 100`, rather than `0 - 1`:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
{
|
|
13
|
+
"colorSpace": "hsl",
|
|
14
|
+
- "components": [270, 0.5, 0.4]
|
|
15
|
+
+ "components": [270, 50, 40]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
All other color spaces should be unaffected, as they were already matching CSS Color Module 4.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#507](https://github.com/terrazzoapp/terrazzo/pull/507) [`0060100`](https://github.com/terrazzoapp/terrazzo/commit/00601002a731dc009fb4ef2b438a01b087325a1a) Thanks [@drwpow](https://github.com/drwpow)! - Fix a98-rgb colorSpace, accidentally referring to it as "a98"
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`0060100`](https://github.com/terrazzoapp/terrazzo/commit/00601002a731dc009fb4ef2b438a01b087325a1a), [`0060100`](https://github.com/terrazzoapp/terrazzo/commit/00601002a731dc009fb4ef2b438a01b087325a1a), [`0060100`](https://github.com/terrazzoapp/terrazzo/commit/00601002a731dc009fb4ef2b438a01b087325a1a)]:
|
|
26
|
+
- @terrazzo/token-tools@0.10.0
|
|
27
|
+
- @terrazzo/cli@0.10.0
|
|
28
|
+
|
|
3
29
|
## 0.9.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -653,7 +653,7 @@ const definition$15 = {
|
|
|
653
653
|
b: 0
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
var definition_default$
|
|
656
|
+
var definition_default$12 = definition$15;
|
|
657
657
|
|
|
658
658
|
//#endregion
|
|
659
659
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/a98/convertA98ToXyz65.js
|
|
@@ -763,7 +763,7 @@ var convertXyz65ToRgb_default = convertXyz65ToRgb;
|
|
|
763
763
|
//#endregion
|
|
764
764
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/a98/definition.js
|
|
765
765
|
const definition$14 = {
|
|
766
|
-
...definition_default$
|
|
766
|
+
...definition_default$12,
|
|
767
767
|
mode: "a98",
|
|
768
768
|
parse: ["a98-rgb"],
|
|
769
769
|
serialize: "a98-rgb",
|
|
@@ -1138,7 +1138,7 @@ const definition$12 = {
|
|
|
1138
1138
|
difference: { h: differenceHueSaturation },
|
|
1139
1139
|
average: { h: averageAngle }
|
|
1140
1140
|
};
|
|
1141
|
-
var definition_default$
|
|
1141
|
+
var definition_default$15 = definition$12;
|
|
1142
1142
|
|
|
1143
1143
|
//#endregion
|
|
1144
1144
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/hwb/convertHwbToRgb.js
|
|
@@ -1229,7 +1229,7 @@ const definition$11 = {
|
|
|
1229
1229
|
difference: { h: differenceHueNaive },
|
|
1230
1230
|
average: { h: averageAngle }
|
|
1231
1231
|
};
|
|
1232
|
-
var definition_default$
|
|
1232
|
+
var definition_default$2 = definition$11;
|
|
1233
1233
|
|
|
1234
1234
|
//#endregion
|
|
1235
1235
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/xyz50/constants.js
|
|
@@ -1388,7 +1388,7 @@ const definition$10 = {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
1390
|
};
|
|
1391
|
-
var definition_default$
|
|
1391
|
+
var definition_default$3 = definition$10;
|
|
1392
1392
|
|
|
1393
1393
|
//#endregion
|
|
1394
1394
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/xyz65/constants.js
|
|
@@ -1454,7 +1454,7 @@ var convertRgbToLab65_default = convertRgbToLab65;
|
|
|
1454
1454
|
//#endregion
|
|
1455
1455
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/lab65/definition.js
|
|
1456
1456
|
const definition$9 = {
|
|
1457
|
-
...definition_default$
|
|
1457
|
+
...definition_default$3,
|
|
1458
1458
|
mode: "lab65",
|
|
1459
1459
|
parse: ["--lab-d65"],
|
|
1460
1460
|
serialize: "--lab-d65",
|
|
@@ -1472,7 +1472,7 @@ const definition$9 = {
|
|
|
1472
1472
|
b: [-107.86, 94.477]
|
|
1473
1473
|
}
|
|
1474
1474
|
};
|
|
1475
|
-
var definition_default$
|
|
1475
|
+
var definition_default$4 = definition$9;
|
|
1476
1476
|
|
|
1477
1477
|
//#endregion
|
|
1478
1478
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/lch/convertLabToLch.js
|
|
@@ -1566,19 +1566,19 @@ const definition$8 = {
|
|
|
1566
1566
|
difference: { h: differenceHueChroma },
|
|
1567
1567
|
average: { h: averageAngle }
|
|
1568
1568
|
};
|
|
1569
|
-
var definition_default$
|
|
1569
|
+
var definition_default$5 = definition$8;
|
|
1570
1570
|
|
|
1571
1571
|
//#endregion
|
|
1572
1572
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/lrgb/definition.js
|
|
1573
1573
|
const definition$7 = {
|
|
1574
|
-
...definition_default$
|
|
1574
|
+
...definition_default$12,
|
|
1575
1575
|
mode: "lrgb",
|
|
1576
1576
|
toMode: { rgb: convertLrgbToRgb_default },
|
|
1577
1577
|
fromMode: { rgb: convertRgbToLrgb_default },
|
|
1578
1578
|
parse: ["srgb-linear"],
|
|
1579
1579
|
serialize: "srgb-linear"
|
|
1580
1580
|
};
|
|
1581
|
-
var definition_default$
|
|
1581
|
+
var definition_default$6 = definition$7;
|
|
1582
1582
|
|
|
1583
1583
|
//#endregion
|
|
1584
1584
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/oklab/convertOklabToLrgb.js
|
|
@@ -1652,7 +1652,7 @@ var parseOklab_default = parseOklab;
|
|
|
1652
1652
|
//#endregion
|
|
1653
1653
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/oklab/definition.js
|
|
1654
1654
|
const definition$6 = {
|
|
1655
|
-
...definition_default$
|
|
1655
|
+
...definition_default$3,
|
|
1656
1656
|
mode: "oklab",
|
|
1657
1657
|
toMode: {
|
|
1658
1658
|
lrgb: convertOklabToLrgb_default,
|
|
@@ -1670,7 +1670,7 @@ const definition$6 = {
|
|
|
1670
1670
|
parse: [parseOklab_default],
|
|
1671
1671
|
serialize: (c$1) => `oklab(${c$1.l !== void 0 ? c$1.l : "none"} ${c$1.a !== void 0 ? c$1.a : "none"} ${c$1.b !== void 0 ? c$1.b : "none"}${c$1.alpha < 1 ? ` / ${c$1.alpha}` : ""})`
|
|
1672
1672
|
};
|
|
1673
|
-
var definition_default$
|
|
1673
|
+
var definition_default$7 = definition$6;
|
|
1674
1674
|
|
|
1675
1675
|
//#endregion
|
|
1676
1676
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/oklch/parseOklch.js
|
|
@@ -1695,7 +1695,7 @@ var parseOklch_default = parseOklch;
|
|
|
1695
1695
|
//#endregion
|
|
1696
1696
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/oklch/definition.js
|
|
1697
1697
|
const definition$5 = {
|
|
1698
|
-
...definition_default$
|
|
1698
|
+
...definition_default$5,
|
|
1699
1699
|
mode: "oklch",
|
|
1700
1700
|
toMode: {
|
|
1701
1701
|
oklab: (c$1) => convertLchToLab_default(c$1, "oklab"),
|
|
@@ -1713,7 +1713,7 @@ const definition$5 = {
|
|
|
1713
1713
|
h: [0, 360]
|
|
1714
1714
|
}
|
|
1715
1715
|
};
|
|
1716
|
-
var definition_default$
|
|
1716
|
+
var definition_default$8 = definition$5;
|
|
1717
1717
|
|
|
1718
1718
|
//#endregion
|
|
1719
1719
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/p3/convertP3ToXyz65.js
|
|
@@ -1749,7 +1749,7 @@ var convertXyz65ToP3_default = convertXyz65ToP3;
|
|
|
1749
1749
|
//#endregion
|
|
1750
1750
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/p3/definition.js
|
|
1751
1751
|
const definition$4 = {
|
|
1752
|
-
...definition_default$
|
|
1752
|
+
...definition_default$12,
|
|
1753
1753
|
mode: "p3",
|
|
1754
1754
|
parse: ["display-p3"],
|
|
1755
1755
|
serialize: "display-p3",
|
|
@@ -1762,7 +1762,7 @@ const definition$4 = {
|
|
|
1762
1762
|
xyz65: convertP3ToXyz65_default
|
|
1763
1763
|
}
|
|
1764
1764
|
};
|
|
1765
|
-
var definition_default$
|
|
1765
|
+
var definition_default$9 = definition$4;
|
|
1766
1766
|
|
|
1767
1767
|
//#endregion
|
|
1768
1768
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/prophoto/convertXyz50ToProphoto.js
|
|
@@ -1811,7 +1811,7 @@ var convertProphotoToXyz50_default = convertProphotoToXyz50;
|
|
|
1811
1811
|
//#endregion
|
|
1812
1812
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/prophoto/definition.js
|
|
1813
1813
|
const definition$3 = {
|
|
1814
|
-
...definition_default$
|
|
1814
|
+
...definition_default$12,
|
|
1815
1815
|
mode: "prophoto",
|
|
1816
1816
|
parse: ["prophoto-rgb"],
|
|
1817
1817
|
serialize: "prophoto-rgb",
|
|
@@ -1824,7 +1824,7 @@ const definition$3 = {
|
|
|
1824
1824
|
rgb: (color) => convertXyz50ToRgb_default(convertProphotoToXyz50_default(color))
|
|
1825
1825
|
}
|
|
1826
1826
|
};
|
|
1827
|
-
var definition_default$
|
|
1827
|
+
var definition_default$10 = definition$3;
|
|
1828
1828
|
|
|
1829
1829
|
//#endregion
|
|
1830
1830
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/rec2020/convertXyz65ToRec2020.js
|
|
@@ -1877,7 +1877,7 @@ var convertRec2020ToXyz65_default = convertRec2020ToXyz65;
|
|
|
1877
1877
|
//#endregion
|
|
1878
1878
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/rec2020/definition.js
|
|
1879
1879
|
const definition$2 = {
|
|
1880
|
-
...definition_default$
|
|
1880
|
+
...definition_default$12,
|
|
1881
1881
|
mode: "rec2020",
|
|
1882
1882
|
fromMode: {
|
|
1883
1883
|
xyz65: convertXyz65ToRec2020_default,
|
|
@@ -1890,7 +1890,7 @@ const definition$2 = {
|
|
|
1890
1890
|
parse: ["rec2020"],
|
|
1891
1891
|
serialize: "rec2020"
|
|
1892
1892
|
};
|
|
1893
|
-
var definition_default$
|
|
1893
|
+
var definition_default$11 = definition$2;
|
|
1894
1894
|
|
|
1895
1895
|
//#endregion
|
|
1896
1896
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/xyz50/definition.js
|
|
@@ -1927,7 +1927,7 @@ const definition$1 = {
|
|
|
1927
1927
|
}
|
|
1928
1928
|
}
|
|
1929
1929
|
};
|
|
1930
|
-
var definition_default$
|
|
1930
|
+
var definition_default$13 = definition$1;
|
|
1931
1931
|
|
|
1932
1932
|
//#endregion
|
|
1933
1933
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/xyz65/convertXyz65ToXyz50.js
|
|
@@ -2000,7 +2000,184 @@ const definition = {
|
|
|
2000
2000
|
}
|
|
2001
2001
|
}
|
|
2002
2002
|
};
|
|
2003
|
-
var definition_default$
|
|
2003
|
+
var definition_default$14 = definition;
|
|
2004
|
+
|
|
2005
|
+
//#endregion
|
|
2006
|
+
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/okhsl/helpers.js
|
|
2007
|
+
function toe(x) {
|
|
2008
|
+
const k_1 = .206;
|
|
2009
|
+
const k_2 = .03;
|
|
2010
|
+
const k_3 = (1 + k_1) / (1 + k_2);
|
|
2011
|
+
return .5 * (k_3 * x - k_1 + Math.sqrt((k_3 * x - k_1) * (k_3 * x - k_1) + 4 * k_2 * k_3 * x));
|
|
2012
|
+
}
|
|
2013
|
+
function toe_inv(x) {
|
|
2014
|
+
const k_1 = .206;
|
|
2015
|
+
const k_2 = .03;
|
|
2016
|
+
const k_3 = (1 + k_1) / (1 + k_2);
|
|
2017
|
+
return (x * x + k_1 * x) / (k_3 * (x + k_2));
|
|
2018
|
+
}
|
|
2019
|
+
function compute_max_saturation(a, b) {
|
|
2020
|
+
let k0, k1, k2, k3, k4, wl, wm, ws;
|
|
2021
|
+
if (-1.88170328 * a - .80936493 * b > 1) {
|
|
2022
|
+
k0 = 1.19086277;
|
|
2023
|
+
k1 = 1.76576728;
|
|
2024
|
+
k2 = .59662641;
|
|
2025
|
+
k3 = .75515197;
|
|
2026
|
+
k4 = .56771245;
|
|
2027
|
+
wl = 4.0767416621;
|
|
2028
|
+
wm = -3.3077115913;
|
|
2029
|
+
ws = .2309699292;
|
|
2030
|
+
} else if (1.81444104 * a - 1.19445276 * b > 1) {
|
|
2031
|
+
k0 = .73956515;
|
|
2032
|
+
k1 = -.45954404;
|
|
2033
|
+
k2 = .08285427;
|
|
2034
|
+
k3 = .1254107;
|
|
2035
|
+
k4 = .14503204;
|
|
2036
|
+
wl = -1.2684380046;
|
|
2037
|
+
wm = 2.6097574011;
|
|
2038
|
+
ws = -.3413193965;
|
|
2039
|
+
} else {
|
|
2040
|
+
k0 = 1.35733652;
|
|
2041
|
+
k1 = -.00915799;
|
|
2042
|
+
k2 = -1.1513021;
|
|
2043
|
+
k3 = -.50559606;
|
|
2044
|
+
k4 = .00692167;
|
|
2045
|
+
wl = -.0041960863;
|
|
2046
|
+
wm = -.7034186147;
|
|
2047
|
+
ws = 1.707614701;
|
|
2048
|
+
}
|
|
2049
|
+
let S = k0 + k1 * a + k2 * b + k3 * a * a + k4 * a * b;
|
|
2050
|
+
let k_l = .3963377774 * a + .2158037573 * b;
|
|
2051
|
+
let k_m = -.1055613458 * a - .0638541728 * b;
|
|
2052
|
+
let k_s = -.0894841775 * a - 1.291485548 * b;
|
|
2053
|
+
{
|
|
2054
|
+
let l_ = 1 + S * k_l;
|
|
2055
|
+
let m_ = 1 + S * k_m;
|
|
2056
|
+
let s_ = 1 + S * k_s;
|
|
2057
|
+
let l = l_ * l_ * l_;
|
|
2058
|
+
let m = m_ * m_ * m_;
|
|
2059
|
+
let s = s_ * s_ * s_;
|
|
2060
|
+
let l_dS = 3 * k_l * l_ * l_;
|
|
2061
|
+
let m_dS = 3 * k_m * m_ * m_;
|
|
2062
|
+
let s_dS = 3 * k_s * s_ * s_;
|
|
2063
|
+
let l_dS2 = 6 * k_l * k_l * l_;
|
|
2064
|
+
let m_dS2 = 6 * k_m * k_m * m_;
|
|
2065
|
+
let s_dS2 = 6 * k_s * k_s * s_;
|
|
2066
|
+
let f$2 = wl * l + wm * m + ws * s;
|
|
2067
|
+
let f1 = wl * l_dS + wm * m_dS + ws * s_dS;
|
|
2068
|
+
let f2 = wl * l_dS2 + wm * m_dS2 + ws * s_dS2;
|
|
2069
|
+
S = S - f$2 * f1 / (f1 * f1 - .5 * f$2 * f2);
|
|
2070
|
+
}
|
|
2071
|
+
return S;
|
|
2072
|
+
}
|
|
2073
|
+
function find_cusp(a, b) {
|
|
2074
|
+
let S_cusp = compute_max_saturation(a, b);
|
|
2075
|
+
let rgb$2 = convertOklabToLrgb_default({
|
|
2076
|
+
l: 1,
|
|
2077
|
+
a: S_cusp * a,
|
|
2078
|
+
b: S_cusp * b
|
|
2079
|
+
});
|
|
2080
|
+
let L_cusp = Math.cbrt(1 / Math.max(rgb$2.r, rgb$2.g, rgb$2.b));
|
|
2081
|
+
let C_cusp = L_cusp * S_cusp;
|
|
2082
|
+
return [L_cusp, C_cusp];
|
|
2083
|
+
}
|
|
2084
|
+
function get_ST_max(a_, b_, cusp = null) {
|
|
2085
|
+
if (!cusp) cusp = find_cusp(a_, b_);
|
|
2086
|
+
let L = cusp[0];
|
|
2087
|
+
let C = cusp[1];
|
|
2088
|
+
return [C / L, C / (1 - L)];
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/okhsv/convertOklabToOkhsv.js
|
|
2093
|
+
function convertOklabToOkhsv(lab) {
|
|
2094
|
+
let l = lab.l !== void 0 ? lab.l : 0;
|
|
2095
|
+
let a = lab.a !== void 0 ? lab.a : 0;
|
|
2096
|
+
let b = lab.b !== void 0 ? lab.b : 0;
|
|
2097
|
+
let c$1 = Math.sqrt(a * a + b * b);
|
|
2098
|
+
let a_ = c$1 ? a / c$1 : 1;
|
|
2099
|
+
let b_ = c$1 ? b / c$1 : 1;
|
|
2100
|
+
let [S_max, T] = get_ST_max(a_, b_);
|
|
2101
|
+
let S_0 = .5;
|
|
2102
|
+
let k$3 = 1 - S_0 / S_max;
|
|
2103
|
+
let t = T / (c$1 + l * T);
|
|
2104
|
+
let L_v = t * l;
|
|
2105
|
+
let C_v = t * c$1;
|
|
2106
|
+
let L_vt = toe_inv(L_v);
|
|
2107
|
+
let C_vt = C_v * L_vt / L_v;
|
|
2108
|
+
let rgb_scale = convertOklabToLrgb_default({
|
|
2109
|
+
l: L_vt,
|
|
2110
|
+
a: a_ * C_vt,
|
|
2111
|
+
b: b_ * C_vt
|
|
2112
|
+
});
|
|
2113
|
+
let scale_L = Math.cbrt(1 / Math.max(rgb_scale.r, rgb_scale.g, rgb_scale.b, 0));
|
|
2114
|
+
l = l / scale_L;
|
|
2115
|
+
c$1 = c$1 / scale_L * toe(l) / l;
|
|
2116
|
+
l = toe(l);
|
|
2117
|
+
const ret = {
|
|
2118
|
+
mode: "okhsv",
|
|
2119
|
+
s: c$1 ? (S_0 + T) * C_v / (T * S_0 + T * k$3 * C_v) : 0,
|
|
2120
|
+
v: l ? l / L_v : 0
|
|
2121
|
+
};
|
|
2122
|
+
if (ret.s) ret.h = normalizeHue_default(Math.atan2(b, a) * 180 / Math.PI);
|
|
2123
|
+
if (lab.alpha !== void 0) ret.alpha = lab.alpha;
|
|
2124
|
+
return ret;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
//#endregion
|
|
2128
|
+
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/okhsv/convertOkhsvToOklab.js
|
|
2129
|
+
function convertOkhsvToOklab(hsv) {
|
|
2130
|
+
const ret = { mode: "oklab" };
|
|
2131
|
+
if (hsv.alpha !== void 0) ret.alpha = hsv.alpha;
|
|
2132
|
+
const h = hsv.h !== void 0 ? hsv.h : 0;
|
|
2133
|
+
const s = hsv.s !== void 0 ? hsv.s : 0;
|
|
2134
|
+
const v = hsv.v !== void 0 ? hsv.v : 0;
|
|
2135
|
+
const a_ = Math.cos(h / 180 * Math.PI);
|
|
2136
|
+
const b_ = Math.sin(h / 180 * Math.PI);
|
|
2137
|
+
const [S_max, T] = get_ST_max(a_, b_);
|
|
2138
|
+
const S_0 = .5;
|
|
2139
|
+
const k$3 = 1 - S_0 / S_max;
|
|
2140
|
+
const L_v = 1 - s * S_0 / (S_0 + T - T * k$3 * s);
|
|
2141
|
+
const C_v = s * T * S_0 / (S_0 + T - T * k$3 * s);
|
|
2142
|
+
const L_vt = toe_inv(L_v);
|
|
2143
|
+
const C_vt = C_v * L_vt / L_v;
|
|
2144
|
+
const rgb_scale = convertOklabToLrgb_default({
|
|
2145
|
+
l: L_vt,
|
|
2146
|
+
a: a_ * C_vt,
|
|
2147
|
+
b: b_ * C_vt
|
|
2148
|
+
});
|
|
2149
|
+
const scale_L = Math.cbrt(1 / Math.max(rgb_scale.r, rgb_scale.g, rgb_scale.b, 0));
|
|
2150
|
+
const L_new = toe_inv(v * L_v);
|
|
2151
|
+
const C = C_v * L_new / L_v;
|
|
2152
|
+
ret.l = L_new * scale_L;
|
|
2153
|
+
ret.a = C * a_ * scale_L;
|
|
2154
|
+
ret.b = C * b_ * scale_L;
|
|
2155
|
+
return ret;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
//#endregion
|
|
2159
|
+
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/okhsv/modeOkhsv.js
|
|
2160
|
+
const modeOkhsv = {
|
|
2161
|
+
...definition_default$15,
|
|
2162
|
+
mode: "okhsv",
|
|
2163
|
+
channels: [
|
|
2164
|
+
"h",
|
|
2165
|
+
"s",
|
|
2166
|
+
"v",
|
|
2167
|
+
"alpha"
|
|
2168
|
+
],
|
|
2169
|
+
parse: ["--okhsv"],
|
|
2170
|
+
serialize: "--okhsv",
|
|
2171
|
+
fromMode: {
|
|
2172
|
+
oklab: convertOklabToOkhsv,
|
|
2173
|
+
rgb: (c$1) => convertOklabToOkhsv(convertRgbToOklab_default(c$1))
|
|
2174
|
+
},
|
|
2175
|
+
toMode: {
|
|
2176
|
+
oklab: convertOkhsvToOklab,
|
|
2177
|
+
rgb: (c$1) => convertOklabToRgb_default(convertOkhsvToOklab(c$1))
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
var modeOkhsv_default = modeOkhsv;
|
|
2004
2181
|
|
|
2005
2182
|
//#endregion
|
|
2006
2183
|
//#region ../../node_modules/.pnpm/culori@4.0.1/node_modules/culori/src/round.js
|
|
@@ -2132,12 +2309,11 @@ function toGamut(dest = "rgb", mode = "oklch", delta = differenceEuclidean("oklc
|
|
|
2132
2309
|
}
|
|
2133
2310
|
|
|
2134
2311
|
//#endregion
|
|
2135
|
-
//#region ../token-tools/dist/string-
|
|
2312
|
+
//#region ../token-tools/dist/string-BwN3ybNv.js
|
|
2136
2313
|
const HEX_RE = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i;
|
|
2137
2314
|
const CULORI_TO_CSS = {
|
|
2138
|
-
a98: "a98",
|
|
2315
|
+
a98: "a98-rgb",
|
|
2139
2316
|
hsl: "hsl",
|
|
2140
|
-
hsv: "hsv",
|
|
2141
2317
|
hwb: "hwb",
|
|
2142
2318
|
lab: "lab",
|
|
2143
2319
|
lab65: "lab-d65",
|
|
@@ -2145,6 +2321,7 @@ const CULORI_TO_CSS = {
|
|
|
2145
2321
|
lrgb: "srgb-linear",
|
|
2146
2322
|
oklab: "oklab",
|
|
2147
2323
|
oklch: "oklch",
|
|
2324
|
+
okhsv: "okhsv",
|
|
2148
2325
|
p3: "display-p3",
|
|
2149
2326
|
prophoto: "prophoto-rgb",
|
|
2150
2327
|
rec2020: "rec2020",
|
|
@@ -2153,20 +2330,21 @@ const CULORI_TO_CSS = {
|
|
|
2153
2330
|
xyz65: "xyz-d65"
|
|
2154
2331
|
};
|
|
2155
2332
|
const CSS_TO_CULORI = {
|
|
2156
|
-
a98: "a98",
|
|
2333
|
+
"a98-rgb": "a98",
|
|
2157
2334
|
"display-p3": "p3",
|
|
2158
2335
|
hsl: "hsl",
|
|
2159
|
-
hsv: "hsv",
|
|
2160
2336
|
hwb: "hwb",
|
|
2161
2337
|
lab: "lab",
|
|
2162
2338
|
"lab-d65": "lab65",
|
|
2163
2339
|
lch: "lch",
|
|
2164
2340
|
oklab: "oklab",
|
|
2165
2341
|
oklch: "oklch",
|
|
2342
|
+
okhsv: "okhsv",
|
|
2166
2343
|
"prophoto-rgb": "prophoto",
|
|
2167
2344
|
rec2020: "rec2020",
|
|
2168
2345
|
srgb: "rgb",
|
|
2169
2346
|
"srgb-linear": "lrgb",
|
|
2347
|
+
xyz: "xyz65",
|
|
2170
2348
|
"xyz-d50": "xyz50",
|
|
2171
2349
|
"xyz-d65": "xyz65"
|
|
2172
2350
|
};
|
|
@@ -2196,26 +2374,22 @@ function parseColor(color) {
|
|
|
2196
2374
|
break;
|
|
2197
2375
|
}
|
|
2198
2376
|
case "hsl": {
|
|
2377
|
+
const maxS = COLORSPACE[colorSpace].ranges[1]?.[1] ?? 1;
|
|
2378
|
+
const maxL = COLORSPACE[colorSpace].ranges[2]?.[1] ?? 1;
|
|
2199
2379
|
components = [
|
|
2200
2380
|
result.h ?? 0,
|
|
2201
|
-
result.s,
|
|
2202
|
-
result.l
|
|
2203
|
-
];
|
|
2204
|
-
break;
|
|
2205
|
-
}
|
|
2206
|
-
case "hsv": {
|
|
2207
|
-
components = [
|
|
2208
|
-
result.h ?? 0,
|
|
2209
|
-
result.s,
|
|
2210
|
-
result.v
|
|
2381
|
+
result.s * maxS,
|
|
2382
|
+
result.l * maxL
|
|
2211
2383
|
];
|
|
2212
2384
|
break;
|
|
2213
2385
|
}
|
|
2214
2386
|
case "hwb": {
|
|
2387
|
+
const maxW = COLORSPACE[colorSpace].ranges[1]?.[1] ?? 1;
|
|
2388
|
+
const maxB = COLORSPACE[colorSpace].ranges[2]?.[1] ?? 1;
|
|
2215
2389
|
components = [
|
|
2216
2390
|
result.h ?? 0,
|
|
2217
|
-
result.w,
|
|
2218
|
-
result.b
|
|
2391
|
+
result.w * maxW,
|
|
2392
|
+
result.b * maxB
|
|
2219
2393
|
];
|
|
2220
2394
|
break;
|
|
2221
2395
|
}
|
|
@@ -2238,6 +2412,14 @@ function parseColor(color) {
|
|
|
2238
2412
|
];
|
|
2239
2413
|
break;
|
|
2240
2414
|
}
|
|
2415
|
+
case "okhsv": {
|
|
2416
|
+
components = [
|
|
2417
|
+
result.h ?? 0,
|
|
2418
|
+
result.s,
|
|
2419
|
+
result.v
|
|
2420
|
+
];
|
|
2421
|
+
break;
|
|
2422
|
+
}
|
|
2241
2423
|
case "xyz50":
|
|
2242
2424
|
case "xyz65": {
|
|
2243
2425
|
components = [
|
|
@@ -2259,7 +2441,7 @@ function parseColor(color) {
|
|
|
2259
2441
|
/** Convert a color token to a Culori color */
|
|
2260
2442
|
function tokenToCulori(value) {
|
|
2261
2443
|
switch (value.colorSpace) {
|
|
2262
|
-
case "a98":
|
|
2444
|
+
case "a98-rgb":
|
|
2263
2445
|
case "display-p3":
|
|
2264
2446
|
case "prophoto-rgb":
|
|
2265
2447
|
case "rec2020":
|
|
@@ -2276,31 +2458,25 @@ function tokenToCulori(value) {
|
|
|
2276
2458
|
}
|
|
2277
2459
|
case "hsl": {
|
|
2278
2460
|
const [h, s, l] = value.components;
|
|
2461
|
+
const maxS = COLORSPACE[value.colorSpace].ranges[1]?.[1] ?? 1;
|
|
2462
|
+
const maxL = COLORSPACE[value.colorSpace].ranges[2]?.[1] ?? 1;
|
|
2279
2463
|
return {
|
|
2280
2464
|
mode: "hsl",
|
|
2281
2465
|
h,
|
|
2282
|
-
s,
|
|
2283
|
-
l,
|
|
2284
|
-
alpha: value.alpha
|
|
2285
|
-
};
|
|
2286
|
-
}
|
|
2287
|
-
case "hsv": {
|
|
2288
|
-
const [h, s, v] = value.components;
|
|
2289
|
-
return {
|
|
2290
|
-
mode: "hsv",
|
|
2291
|
-
h,
|
|
2292
|
-
s,
|
|
2293
|
-
v,
|
|
2466
|
+
s: s / maxS,
|
|
2467
|
+
l: l / maxL,
|
|
2294
2468
|
alpha: value.alpha
|
|
2295
2469
|
};
|
|
2296
2470
|
}
|
|
2297
2471
|
case "hwb": {
|
|
2298
2472
|
const [h, w, b] = value.components;
|
|
2473
|
+
const maxW = COLORSPACE[value.colorSpace].ranges[1]?.[1] ?? 1;
|
|
2474
|
+
const maxB = COLORSPACE[value.colorSpace].ranges[2]?.[1] ?? 1;
|
|
2299
2475
|
return {
|
|
2300
2476
|
mode: "hwb",
|
|
2301
2477
|
h,
|
|
2302
|
-
w,
|
|
2303
|
-
b,
|
|
2478
|
+
w: w / maxW,
|
|
2479
|
+
b: b / maxB,
|
|
2304
2480
|
alpha: value.alpha
|
|
2305
2481
|
};
|
|
2306
2482
|
}
|
|
@@ -2328,20 +2504,22 @@ function tokenToCulori(value) {
|
|
|
2328
2504
|
alpha: value.alpha
|
|
2329
2505
|
};
|
|
2330
2506
|
}
|
|
2331
|
-
case "
|
|
2332
|
-
const [
|
|
2507
|
+
case "okhsv": {
|
|
2508
|
+
const [h, s, v] = value.components;
|
|
2333
2509
|
return {
|
|
2334
|
-
mode:
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2510
|
+
mode: value.colorSpace,
|
|
2511
|
+
h,
|
|
2512
|
+
s,
|
|
2513
|
+
v,
|
|
2338
2514
|
alpha: value.alpha
|
|
2339
2515
|
};
|
|
2340
2516
|
}
|
|
2517
|
+
case "xyz":
|
|
2518
|
+
case "xyz-d50":
|
|
2341
2519
|
case "xyz-d65": {
|
|
2342
2520
|
const [x, y, z] = value.components;
|
|
2343
2521
|
return {
|
|
2344
|
-
mode:
|
|
2522
|
+
mode: CSS_TO_CULORI[value.colorSpace],
|
|
2345
2523
|
x,
|
|
2346
2524
|
y,
|
|
2347
2525
|
z,
|
|
@@ -2351,6 +2529,94 @@ function tokenToCulori(value) {
|
|
|
2351
2529
|
default: throw new Error(`Invalid colorSpace "${value.colorSpace}". Expected one of ${Object.keys(CSS_TO_CULORI).join(", ")}`);
|
|
2352
2530
|
}
|
|
2353
2531
|
}
|
|
2532
|
+
/** Complete list of CSS Module 4 Colorspaces */
|
|
2533
|
+
const COLORSPACE = {
|
|
2534
|
+
"a98-rgb": { ranges: [
|
|
2535
|
+
[0, 1],
|
|
2536
|
+
[0, 1],
|
|
2537
|
+
[0, 1]
|
|
2538
|
+
] },
|
|
2539
|
+
"display-p3": { ranges: [
|
|
2540
|
+
[0, 1],
|
|
2541
|
+
[0, 1],
|
|
2542
|
+
[0, 1]
|
|
2543
|
+
] },
|
|
2544
|
+
hsl: { ranges: [
|
|
2545
|
+
[0, 360],
|
|
2546
|
+
[0, 100],
|
|
2547
|
+
[0, 100]
|
|
2548
|
+
] },
|
|
2549
|
+
hwb: { ranges: [
|
|
2550
|
+
[0, 360],
|
|
2551
|
+
[0, 100],
|
|
2552
|
+
[0, 100]
|
|
2553
|
+
] },
|
|
2554
|
+
lab: { ranges: [
|
|
2555
|
+
[0, 100],
|
|
2556
|
+
[-125, 125],
|
|
2557
|
+
[-125, 125]
|
|
2558
|
+
] },
|
|
2559
|
+
"lab-d65": { ranges: [
|
|
2560
|
+
[0, 100],
|
|
2561
|
+
[-125, 125],
|
|
2562
|
+
[-125, 125]
|
|
2563
|
+
] },
|
|
2564
|
+
lch: { ranges: [
|
|
2565
|
+
[0, 100],
|
|
2566
|
+
[0, 150],
|
|
2567
|
+
[0, 360]
|
|
2568
|
+
] },
|
|
2569
|
+
oklab: { ranges: [
|
|
2570
|
+
[0, 1],
|
|
2571
|
+
[-.4, .4],
|
|
2572
|
+
[-.4, .4]
|
|
2573
|
+
] },
|
|
2574
|
+
oklch: { ranges: [
|
|
2575
|
+
[0, 1],
|
|
2576
|
+
[0, .4],
|
|
2577
|
+
[0, 360]
|
|
2578
|
+
] },
|
|
2579
|
+
okhsv: { ranges: [
|
|
2580
|
+
[0, 360],
|
|
2581
|
+
[0, 1],
|
|
2582
|
+
[0, 1]
|
|
2583
|
+
] },
|
|
2584
|
+
"prophoto-rgb": { ranges: [
|
|
2585
|
+
[0, 1],
|
|
2586
|
+
[0, 1],
|
|
2587
|
+
[0, 1]
|
|
2588
|
+
] },
|
|
2589
|
+
rec2020: { ranges: [
|
|
2590
|
+
[0, 1],
|
|
2591
|
+
[0, 1],
|
|
2592
|
+
[0, 1]
|
|
2593
|
+
] },
|
|
2594
|
+
srgb: { ranges: [
|
|
2595
|
+
[0, 1],
|
|
2596
|
+
[0, 1],
|
|
2597
|
+
[0, 1]
|
|
2598
|
+
] },
|
|
2599
|
+
"srgb-linear": { ranges: [
|
|
2600
|
+
[0, 1],
|
|
2601
|
+
[0, 1],
|
|
2602
|
+
[0, 1]
|
|
2603
|
+
] },
|
|
2604
|
+
"xyz-d50": { ranges: [
|
|
2605
|
+
[0, 1],
|
|
2606
|
+
[0, 1],
|
|
2607
|
+
[0, 1]
|
|
2608
|
+
] },
|
|
2609
|
+
xyz: { ranges: [
|
|
2610
|
+
[0, 1],
|
|
2611
|
+
[0, 1],
|
|
2612
|
+
[0, 1]
|
|
2613
|
+
] },
|
|
2614
|
+
"xyz-d65": { ranges: [
|
|
2615
|
+
[0, 1],
|
|
2616
|
+
[0, 1],
|
|
2617
|
+
[0, 1]
|
|
2618
|
+
] }
|
|
2619
|
+
};
|
|
2354
2620
|
/** Turn a string into kebab-case */
|
|
2355
2621
|
function kebabCase(str) {
|
|
2356
2622
|
let output = "";
|
|
@@ -2552,20 +2818,20 @@ function transformColor(token, options) {
|
|
|
2552
2818
|
const converters = {
|
|
2553
2819
|
a98: useMode(definition_default),
|
|
2554
2820
|
hsl: useMode(definition_default$1),
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
p3: useMode(definition_default$
|
|
2564
|
-
prophoto: useMode(definition_default$
|
|
2565
|
-
rec2020: useMode(definition_default$
|
|
2566
|
-
rgb: useMode(definition_default$
|
|
2567
|
-
xyz50: useMode(definition_default$
|
|
2568
|
-
xyz65: useMode(definition_default$
|
|
2821
|
+
hwb: useMode(definition_default$2),
|
|
2822
|
+
lab: useMode(definition_default$3),
|
|
2823
|
+
lab65: useMode(definition_default$4),
|
|
2824
|
+
lch: useMode(definition_default$5),
|
|
2825
|
+
lrgb: useMode(definition_default$6),
|
|
2826
|
+
oklab: useMode(definition_default$7),
|
|
2827
|
+
oklch: useMode(definition_default$8),
|
|
2828
|
+
okhsv: useMode(modeOkhsv_default),
|
|
2829
|
+
p3: useMode(definition_default$9),
|
|
2830
|
+
prophoto: useMode(definition_default$10),
|
|
2831
|
+
rec2020: useMode(definition_default$11),
|
|
2832
|
+
rgb: useMode(definition_default$12),
|
|
2833
|
+
xyz50: useMode(definition_default$13),
|
|
2834
|
+
xyz65: useMode(definition_default$14)
|
|
2569
2835
|
};
|
|
2570
2836
|
/**
|
|
2571
2837
|
* Downsample color to sRGB/Display P3/Rec2020 colorspaces.
|