storybook 10.0.0-beta.1 → 10.0.0-beta.11
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/assets/server/openBrowser.applescript +94 -0
- package/dist/_browser-chunks/Color-KPLIACXP.js +1569 -0
- package/dist/_browser-chunks/{WithTooltip-ERFLZL6W.js → WithTooltip-SK46ZJ2J.js} +1 -1
- package/dist/_browser-chunks/{chunk-YY5GICNT.js → chunk-6E2SHJSL.js} +175 -32
- package/dist/_browser-chunks/{chunk-EOILZP2R.js → chunk-BOOOPFZF.js} +7 -2
- package/dist/_browser-chunks/{chunk-YWDKX534.js → chunk-FA42P6MO.js} +49 -4
- package/dist/_browser-chunks/chunk-G33S6YM3.js +521 -0
- package/dist/_browser-chunks/{chunk-MZNYTCNT.js → chunk-HMIIJ6UD.js} +6 -6
- package/dist/_browser-chunks/{chunk-4QPX7WIQ.js → chunk-JJZMHC3A.js} +57 -166
- package/dist/_browser-chunks/{chunk-MD2FTHCZ.js → chunk-JVSKG4YS.js} +3 -16
- package/dist/_browser-chunks/{chunk-E7VLET3C.js → chunk-KSCAWCCE.js} +3947 -4291
- package/dist/_browser-chunks/{chunk-PYK5ZTFK.js → chunk-PS3AOQI4.js} +48 -25
- package/dist/_browser-chunks/chunk-QK3L5AXO.js +372 -0
- package/dist/_browser-chunks/chunk-SHR3NNR3.js +5810 -0
- package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +20 -0
- package/dist/_browser-chunks/{chunk-T7RCAJIX.js → chunk-Y3M7TW6K.js} +43 -47
- package/dist/_browser-chunks/{syntaxhighlighter-YYAA4CS4.js → syntaxhighlighter-R46XOLMC.js} +1 -1
- package/dist/_node-chunks/{builder-manager-EXW4ETLN.js → builder-manager-VLFDK43H.js} +45 -155
- package/dist/_node-chunks/camelcase-RENSEFK6.js +18 -0
- package/dist/_node-chunks/{chunk-5ZX5SJOP.js → chunk-4SPBIDJV.js} +162 -103
- package/dist/_node-chunks/{chunk-PMEEE3UE.js → chunk-4WZFG35Z.js} +30 -21
- package/dist/_node-chunks/{chunk-WP7DV5JT.js → chunk-5K7G6NFK.js} +583 -180
- package/dist/_node-chunks/{chunk-FZP2YGG3.js → chunk-5NSMDC6F.js} +7 -7
- package/dist/_node-chunks/{chunk-6CCUFDHU.js → chunk-5THWZTEL.js} +7 -7
- package/dist/_node-chunks/chunk-7MUMULSR.js +79 -0
- package/dist/_node-chunks/chunk-7QAAJL75.js +1540 -0
- package/dist/_node-chunks/{chunk-EO4S3VXL.js → chunk-DVY3VWHZ.js} +653 -775
- package/dist/_node-chunks/{chunk-WDKWVNL2.js → chunk-EBLOP2C5.js} +7 -7
- package/dist/_node-chunks/{chunk-EDBXIJN5.js → chunk-EF56ZUQY.js} +7 -7
- package/dist/_node-chunks/{chunk-F5J33SXQ.js → chunk-ER2UQBIA.js} +7 -7
- package/dist/_node-chunks/chunk-GHICGP2P.js +18 -0
- package/dist/_node-chunks/{chunk-4WNZYNQY.js → chunk-GYBN5GXT.js} +623 -750
- package/dist/_node-chunks/{chunk-2G5THETV.js → chunk-H2YBWE3T.js} +12 -12
- package/dist/_node-chunks/{camelcase-VZZFWA2L.js → chunk-HYMBYTGJ.js} +9 -8
- package/dist/_node-chunks/{chunk-SUMFFLGF.js → chunk-Q5IJJX3T.js} +6 -6
- package/dist/_node-chunks/{chunk-U45F2NP6.js → chunk-QLRMR54O.js} +7 -7
- package/dist/_node-chunks/{chunk-XTSBFCVE.js → chunk-QSNDRP62.js} +7 -7
- package/dist/_node-chunks/chunk-S2RQAF7K.js +4741 -0
- package/dist/_node-chunks/{chunk-2QZOLZDJ.js → chunk-SDZVOIZI.js} +9 -9
- package/dist/_node-chunks/{chunk-VNLBDN2Z.js → chunk-SGJZDMJW.js} +6 -6
- package/dist/_node-chunks/{chunk-PL2PKDRO.js → chunk-TJOIDMXP.js} +60 -102
- package/dist/_node-chunks/{chunk-ICPKUV5G.js → chunk-U2UIPLJI.js} +7 -7
- package/dist/_node-chunks/{chunk-3SGKBLOL.js → chunk-UAMXREF3.js} +8 -8
- package/dist/_node-chunks/{chunk-GVCXNIAA.js → chunk-UC6O5PNX.js} +399 -116
- package/dist/_node-chunks/{chunk-CM3UGTR5.js → chunk-VFUP6Z4J.js} +7 -7
- package/dist/_node-chunks/{chunk-3ZKQWDCG.js → chunk-XKPJCSPD.js} +223 -243
- package/dist/_node-chunks/{chunk-24TGL6EX.js → chunk-XWCQWB3R.js} +8 -8
- package/dist/_node-chunks/{chunk-QC5FE2D7.js → chunk-XYFEBEHY.js} +7 -7
- package/dist/_node-chunks/chunk-YAEIMHFX.js +62 -0
- package/dist/_node-chunks/{chunk-5V6QH7WC.js → chunk-ZHBCPKYD.js} +7 -7
- package/dist/_node-chunks/{dist-VZL6D6Y3.js → dist-A2RPEHEC.js} +9 -9
- package/dist/_node-chunks/{globby-GZXJJ4W6.js → globby-3TWPXGQS.js} +17 -13
- package/dist/_node-chunks/{lib-PHT5GCV2.js → lib-MUNM6ZJ6.js} +40 -16
- package/dist/_node-chunks/{mdx-N42X6CFJ-EPDIV4A2.js → mdx-N42X6CFJ-QQDHJZQ3.js} +8 -8
- package/dist/_node-chunks/{p-limit-AJIFSZTI.js → p-limit-FEN55OV6.js} +76 -10
- package/dist/_node-chunks/{plugin-3VI56CEF.js → plugin-ESAYNJ5V.js} +11 -11
- package/dist/_node-chunks/{plugin-AV4OEKYM.js → plugin-GDMP3JPR.js} +10 -10
- package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-E7J5FKLA.js → webpack-inject-mocker-runtime-plugin-5AKTLYIV.js} +1307 -847
- package/dist/_node-chunks/{webpack-mock-plugin-VTYGW7HO.js → webpack-mock-plugin-AWGZ65AQ.js} +9 -9
- package/dist/babel/index.d.ts +1 -1
- package/dist/babel/index.js +11 -11
- package/dist/bin/core.js +638 -187
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +77 -12
- package/dist/cli/index.d.ts +62 -75
- package/dist/cli/index.js +67 -55
- package/dist/common/index.d.ts +3 -1
- package/dist/common/index.js +22 -22
- package/dist/components/index.d.ts +228 -1
- package/dist/components/index.js +74 -5738
- package/dist/core-events/index.d.ts +18 -2
- package/dist/core-events/index.js +7 -1
- package/dist/core-server/index.d.ts +515 -14
- package/dist/core-server/index.js +4647 -4182
- package/dist/core-server/presets/common-manager.js +1570 -1272
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +691 -38
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -9
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -10
- package/dist/csf/index.d.ts +9 -4
- package/dist/csf/index.js +50 -15
- package/dist/csf-tools/index.d.ts +47 -6
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +4 -4
- package/dist/instrumenter/index.js +1 -1
- package/dist/manager/globals-runtime.js +9230 -18109
- package/dist/manager/globals.d.ts +0 -4
- package/dist/manager/globals.js +1 -6
- package/dist/manager/runtime.js +13194 -11367
- package/dist/manager-api/index.d.ts +513 -5
- package/dist/manager-api/index.js +364 -90
- package/dist/manager-errors.d.ts +501 -0
- package/dist/node-logger/index.d.ts +1 -1
- package/dist/node-logger/index.js +1136 -662
- package/dist/preview/globals.js +1 -1
- package/dist/preview/runtime.js +12103 -21579
- package/dist/preview-api/index.d.ts +70 -71
- package/dist/preview-api/index.js +10 -10
- package/dist/preview-errors.d.ts +501 -0
- package/dist/router/index.d.ts +668 -10
- package/dist/router/index.js +2 -2
- package/dist/server-errors.d.ts +501 -0
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +23 -25
- package/dist/test/index.js +1874 -4024
- package/dist/theming/index.d.ts +2 -2
- package/dist/theming/index.js +6 -6
- package/dist/types/index.d.ts +553 -16
- package/dist/viewport/index.d.ts +36 -4
- package/dist/viewport/index.js +1 -1
- package/package.json +9 -46
- package/dist/_browser-chunks/Color-SFYJJKWL.js +0 -605
- package/dist/_browser-chunks/chunk-DHO2SA6L.js +0 -12
- package/dist/_browser-chunks/chunk-WPHPDNUA.js +0 -974
- package/dist/_node-chunks/chunk-32JYCD74.js +0 -80
- package/dist/_node-chunks/chunk-GE6I3YYG.js +0 -62
- package/dist/_node-chunks/chunk-KXCNXWXI.js +0 -18
- package/dist/_node-chunks/chunk-LAUOYAOX.js +0 -87
- package/dist/_node-chunks/chunk-QJTT4OC2.js +0 -266
- package/dist/_node-chunks/chunk-V2ZF4DUD.js +0 -2377
- package/dist/_node-chunks/chunk-ZMV3WY6R.js +0 -9845
- package/dist/_node-chunks/default-browser-id-JNATP42X.js +0 -1719
|
@@ -1,974 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
__name
|
|
4
|
-
} from "./chunk-MM7DTO55.js";
|
|
5
|
-
|
|
6
|
-
// ../node_modules/color-name/index.js
|
|
7
|
-
var require_color_name = __commonJS({
|
|
8
|
-
"../node_modules/color-name/index.js"(exports, module) {
|
|
9
|
-
"use strict";
|
|
10
|
-
module.exports = {
|
|
11
|
-
"aliceblue": [240, 248, 255],
|
|
12
|
-
"antiquewhite": [250, 235, 215],
|
|
13
|
-
"aqua": [0, 255, 255],
|
|
14
|
-
"aquamarine": [127, 255, 212],
|
|
15
|
-
"azure": [240, 255, 255],
|
|
16
|
-
"beige": [245, 245, 220],
|
|
17
|
-
"bisque": [255, 228, 196],
|
|
18
|
-
"black": [0, 0, 0],
|
|
19
|
-
"blanchedalmond": [255, 235, 205],
|
|
20
|
-
"blue": [0, 0, 255],
|
|
21
|
-
"blueviolet": [138, 43, 226],
|
|
22
|
-
"brown": [165, 42, 42],
|
|
23
|
-
"burlywood": [222, 184, 135],
|
|
24
|
-
"cadetblue": [95, 158, 160],
|
|
25
|
-
"chartreuse": [127, 255, 0],
|
|
26
|
-
"chocolate": [210, 105, 30],
|
|
27
|
-
"coral": [255, 127, 80],
|
|
28
|
-
"cornflowerblue": [100, 149, 237],
|
|
29
|
-
"cornsilk": [255, 248, 220],
|
|
30
|
-
"crimson": [220, 20, 60],
|
|
31
|
-
"cyan": [0, 255, 255],
|
|
32
|
-
"darkblue": [0, 0, 139],
|
|
33
|
-
"darkcyan": [0, 139, 139],
|
|
34
|
-
"darkgoldenrod": [184, 134, 11],
|
|
35
|
-
"darkgray": [169, 169, 169],
|
|
36
|
-
"darkgreen": [0, 100, 0],
|
|
37
|
-
"darkgrey": [169, 169, 169],
|
|
38
|
-
"darkkhaki": [189, 183, 107],
|
|
39
|
-
"darkmagenta": [139, 0, 139],
|
|
40
|
-
"darkolivegreen": [85, 107, 47],
|
|
41
|
-
"darkorange": [255, 140, 0],
|
|
42
|
-
"darkorchid": [153, 50, 204],
|
|
43
|
-
"darkred": [139, 0, 0],
|
|
44
|
-
"darksalmon": [233, 150, 122],
|
|
45
|
-
"darkseagreen": [143, 188, 143],
|
|
46
|
-
"darkslateblue": [72, 61, 139],
|
|
47
|
-
"darkslategray": [47, 79, 79],
|
|
48
|
-
"darkslategrey": [47, 79, 79],
|
|
49
|
-
"darkturquoise": [0, 206, 209],
|
|
50
|
-
"darkviolet": [148, 0, 211],
|
|
51
|
-
"deeppink": [255, 20, 147],
|
|
52
|
-
"deepskyblue": [0, 191, 255],
|
|
53
|
-
"dimgray": [105, 105, 105],
|
|
54
|
-
"dimgrey": [105, 105, 105],
|
|
55
|
-
"dodgerblue": [30, 144, 255],
|
|
56
|
-
"firebrick": [178, 34, 34],
|
|
57
|
-
"floralwhite": [255, 250, 240],
|
|
58
|
-
"forestgreen": [34, 139, 34],
|
|
59
|
-
"fuchsia": [255, 0, 255],
|
|
60
|
-
"gainsboro": [220, 220, 220],
|
|
61
|
-
"ghostwhite": [248, 248, 255],
|
|
62
|
-
"gold": [255, 215, 0],
|
|
63
|
-
"goldenrod": [218, 165, 32],
|
|
64
|
-
"gray": [128, 128, 128],
|
|
65
|
-
"green": [0, 128, 0],
|
|
66
|
-
"greenyellow": [173, 255, 47],
|
|
67
|
-
"grey": [128, 128, 128],
|
|
68
|
-
"honeydew": [240, 255, 240],
|
|
69
|
-
"hotpink": [255, 105, 180],
|
|
70
|
-
"indianred": [205, 92, 92],
|
|
71
|
-
"indigo": [75, 0, 130],
|
|
72
|
-
"ivory": [255, 255, 240],
|
|
73
|
-
"khaki": [240, 230, 140],
|
|
74
|
-
"lavender": [230, 230, 250],
|
|
75
|
-
"lavenderblush": [255, 240, 245],
|
|
76
|
-
"lawngreen": [124, 252, 0],
|
|
77
|
-
"lemonchiffon": [255, 250, 205],
|
|
78
|
-
"lightblue": [173, 216, 230],
|
|
79
|
-
"lightcoral": [240, 128, 128],
|
|
80
|
-
"lightcyan": [224, 255, 255],
|
|
81
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
82
|
-
"lightgray": [211, 211, 211],
|
|
83
|
-
"lightgreen": [144, 238, 144],
|
|
84
|
-
"lightgrey": [211, 211, 211],
|
|
85
|
-
"lightpink": [255, 182, 193],
|
|
86
|
-
"lightsalmon": [255, 160, 122],
|
|
87
|
-
"lightseagreen": [32, 178, 170],
|
|
88
|
-
"lightskyblue": [135, 206, 250],
|
|
89
|
-
"lightslategray": [119, 136, 153],
|
|
90
|
-
"lightslategrey": [119, 136, 153],
|
|
91
|
-
"lightsteelblue": [176, 196, 222],
|
|
92
|
-
"lightyellow": [255, 255, 224],
|
|
93
|
-
"lime": [0, 255, 0],
|
|
94
|
-
"limegreen": [50, 205, 50],
|
|
95
|
-
"linen": [250, 240, 230],
|
|
96
|
-
"magenta": [255, 0, 255],
|
|
97
|
-
"maroon": [128, 0, 0],
|
|
98
|
-
"mediumaquamarine": [102, 205, 170],
|
|
99
|
-
"mediumblue": [0, 0, 205],
|
|
100
|
-
"mediumorchid": [186, 85, 211],
|
|
101
|
-
"mediumpurple": [147, 112, 219],
|
|
102
|
-
"mediumseagreen": [60, 179, 113],
|
|
103
|
-
"mediumslateblue": [123, 104, 238],
|
|
104
|
-
"mediumspringgreen": [0, 250, 154],
|
|
105
|
-
"mediumturquoise": [72, 209, 204],
|
|
106
|
-
"mediumvioletred": [199, 21, 133],
|
|
107
|
-
"midnightblue": [25, 25, 112],
|
|
108
|
-
"mintcream": [245, 255, 250],
|
|
109
|
-
"mistyrose": [255, 228, 225],
|
|
110
|
-
"moccasin": [255, 228, 181],
|
|
111
|
-
"navajowhite": [255, 222, 173],
|
|
112
|
-
"navy": [0, 0, 128],
|
|
113
|
-
"oldlace": [253, 245, 230],
|
|
114
|
-
"olive": [128, 128, 0],
|
|
115
|
-
"olivedrab": [107, 142, 35],
|
|
116
|
-
"orange": [255, 165, 0],
|
|
117
|
-
"orangered": [255, 69, 0],
|
|
118
|
-
"orchid": [218, 112, 214],
|
|
119
|
-
"palegoldenrod": [238, 232, 170],
|
|
120
|
-
"palegreen": [152, 251, 152],
|
|
121
|
-
"paleturquoise": [175, 238, 238],
|
|
122
|
-
"palevioletred": [219, 112, 147],
|
|
123
|
-
"papayawhip": [255, 239, 213],
|
|
124
|
-
"peachpuff": [255, 218, 185],
|
|
125
|
-
"peru": [205, 133, 63],
|
|
126
|
-
"pink": [255, 192, 203],
|
|
127
|
-
"plum": [221, 160, 221],
|
|
128
|
-
"powderblue": [176, 224, 230],
|
|
129
|
-
"purple": [128, 0, 128],
|
|
130
|
-
"rebeccapurple": [102, 51, 153],
|
|
131
|
-
"red": [255, 0, 0],
|
|
132
|
-
"rosybrown": [188, 143, 143],
|
|
133
|
-
"royalblue": [65, 105, 225],
|
|
134
|
-
"saddlebrown": [139, 69, 19],
|
|
135
|
-
"salmon": [250, 128, 114],
|
|
136
|
-
"sandybrown": [244, 164, 96],
|
|
137
|
-
"seagreen": [46, 139, 87],
|
|
138
|
-
"seashell": [255, 245, 238],
|
|
139
|
-
"sienna": [160, 82, 45],
|
|
140
|
-
"silver": [192, 192, 192],
|
|
141
|
-
"skyblue": [135, 206, 235],
|
|
142
|
-
"slateblue": [106, 90, 205],
|
|
143
|
-
"slategray": [112, 128, 144],
|
|
144
|
-
"slategrey": [112, 128, 144],
|
|
145
|
-
"snow": [255, 250, 250],
|
|
146
|
-
"springgreen": [0, 255, 127],
|
|
147
|
-
"steelblue": [70, 130, 180],
|
|
148
|
-
"tan": [210, 180, 140],
|
|
149
|
-
"teal": [0, 128, 128],
|
|
150
|
-
"thistle": [216, 191, 216],
|
|
151
|
-
"tomato": [255, 99, 71],
|
|
152
|
-
"turquoise": [64, 224, 208],
|
|
153
|
-
"violet": [238, 130, 238],
|
|
154
|
-
"wheat": [245, 222, 179],
|
|
155
|
-
"white": [255, 255, 255],
|
|
156
|
-
"whitesmoke": [245, 245, 245],
|
|
157
|
-
"yellow": [255, 255, 0],
|
|
158
|
-
"yellowgreen": [154, 205, 50]
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// ../node_modules/color-convert/conversions.js
|
|
164
|
-
var require_conversions = __commonJS({
|
|
165
|
-
"../node_modules/color-convert/conversions.js"(exports, module) {
|
|
166
|
-
var cssKeywords = require_color_name();
|
|
167
|
-
var reverseKeywords = {};
|
|
168
|
-
for (const key of Object.keys(cssKeywords)) {
|
|
169
|
-
reverseKeywords[cssKeywords[key]] = key;
|
|
170
|
-
}
|
|
171
|
-
var convert = {
|
|
172
|
-
rgb: { channels: 3, labels: "rgb" },
|
|
173
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
174
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
175
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
176
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
177
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
178
|
-
lab: { channels: 3, labels: "lab" },
|
|
179
|
-
lch: { channels: 3, labels: "lch" },
|
|
180
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
181
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
182
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
183
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
184
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
185
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
186
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
187
|
-
};
|
|
188
|
-
module.exports = convert;
|
|
189
|
-
for (const model of Object.keys(convert)) {
|
|
190
|
-
if (!("channels" in convert[model])) {
|
|
191
|
-
throw new Error("missing channels property: " + model);
|
|
192
|
-
}
|
|
193
|
-
if (!("labels" in convert[model])) {
|
|
194
|
-
throw new Error("missing channel labels property: " + model);
|
|
195
|
-
}
|
|
196
|
-
if (convert[model].labels.length !== convert[model].channels) {
|
|
197
|
-
throw new Error("channel and label counts mismatch: " + model);
|
|
198
|
-
}
|
|
199
|
-
const { channels, labels } = convert[model];
|
|
200
|
-
delete convert[model].channels;
|
|
201
|
-
delete convert[model].labels;
|
|
202
|
-
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
203
|
-
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
204
|
-
}
|
|
205
|
-
convert.rgb.hsl = function(rgb) {
|
|
206
|
-
const r = rgb[0] / 255;
|
|
207
|
-
const g = rgb[1] / 255;
|
|
208
|
-
const b = rgb[2] / 255;
|
|
209
|
-
const min = Math.min(r, g, b);
|
|
210
|
-
const max = Math.max(r, g, b);
|
|
211
|
-
const delta = max - min;
|
|
212
|
-
let h;
|
|
213
|
-
let s;
|
|
214
|
-
if (max === min) {
|
|
215
|
-
h = 0;
|
|
216
|
-
} else if (r === max) {
|
|
217
|
-
h = (g - b) / delta;
|
|
218
|
-
} else if (g === max) {
|
|
219
|
-
h = 2 + (b - r) / delta;
|
|
220
|
-
} else if (b === max) {
|
|
221
|
-
h = 4 + (r - g) / delta;
|
|
222
|
-
}
|
|
223
|
-
h = Math.min(h * 60, 360);
|
|
224
|
-
if (h < 0) {
|
|
225
|
-
h += 360;
|
|
226
|
-
}
|
|
227
|
-
const l = (min + max) / 2;
|
|
228
|
-
if (max === min) {
|
|
229
|
-
s = 0;
|
|
230
|
-
} else if (l <= 0.5) {
|
|
231
|
-
s = delta / (max + min);
|
|
232
|
-
} else {
|
|
233
|
-
s = delta / (2 - max - min);
|
|
234
|
-
}
|
|
235
|
-
return [h, s * 100, l * 100];
|
|
236
|
-
};
|
|
237
|
-
convert.rgb.hsv = function(rgb) {
|
|
238
|
-
let rdif;
|
|
239
|
-
let gdif;
|
|
240
|
-
let bdif;
|
|
241
|
-
let h;
|
|
242
|
-
let s;
|
|
243
|
-
const r = rgb[0] / 255;
|
|
244
|
-
const g = rgb[1] / 255;
|
|
245
|
-
const b = rgb[2] / 255;
|
|
246
|
-
const v = Math.max(r, g, b);
|
|
247
|
-
const diff = v - Math.min(r, g, b);
|
|
248
|
-
const diffc = /* @__PURE__ */ __name(function(c) {
|
|
249
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
250
|
-
}, "diffc");
|
|
251
|
-
if (diff === 0) {
|
|
252
|
-
h = 0;
|
|
253
|
-
s = 0;
|
|
254
|
-
} else {
|
|
255
|
-
s = diff / v;
|
|
256
|
-
rdif = diffc(r);
|
|
257
|
-
gdif = diffc(g);
|
|
258
|
-
bdif = diffc(b);
|
|
259
|
-
if (r === v) {
|
|
260
|
-
h = bdif - gdif;
|
|
261
|
-
} else if (g === v) {
|
|
262
|
-
h = 1 / 3 + rdif - bdif;
|
|
263
|
-
} else if (b === v) {
|
|
264
|
-
h = 2 / 3 + gdif - rdif;
|
|
265
|
-
}
|
|
266
|
-
if (h < 0) {
|
|
267
|
-
h += 1;
|
|
268
|
-
} else if (h > 1) {
|
|
269
|
-
h -= 1;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return [
|
|
273
|
-
h * 360,
|
|
274
|
-
s * 100,
|
|
275
|
-
v * 100
|
|
276
|
-
];
|
|
277
|
-
};
|
|
278
|
-
convert.rgb.hwb = function(rgb) {
|
|
279
|
-
const r = rgb[0];
|
|
280
|
-
const g = rgb[1];
|
|
281
|
-
let b = rgb[2];
|
|
282
|
-
const h = convert.rgb.hsl(rgb)[0];
|
|
283
|
-
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
284
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
285
|
-
return [h, w * 100, b * 100];
|
|
286
|
-
};
|
|
287
|
-
convert.rgb.cmyk = function(rgb) {
|
|
288
|
-
const r = rgb[0] / 255;
|
|
289
|
-
const g = rgb[1] / 255;
|
|
290
|
-
const b = rgb[2] / 255;
|
|
291
|
-
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
292
|
-
const c = (1 - r - k) / (1 - k) || 0;
|
|
293
|
-
const m = (1 - g - k) / (1 - k) || 0;
|
|
294
|
-
const y = (1 - b - k) / (1 - k) || 0;
|
|
295
|
-
return [c * 100, m * 100, y * 100, k * 100];
|
|
296
|
-
};
|
|
297
|
-
function comparativeDistance(x, y) {
|
|
298
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
299
|
-
}
|
|
300
|
-
__name(comparativeDistance, "comparativeDistance");
|
|
301
|
-
convert.rgb.keyword = function(rgb) {
|
|
302
|
-
const reversed = reverseKeywords[rgb];
|
|
303
|
-
if (reversed) {
|
|
304
|
-
return reversed;
|
|
305
|
-
}
|
|
306
|
-
let currentClosestDistance = Infinity;
|
|
307
|
-
let currentClosestKeyword;
|
|
308
|
-
for (const keyword of Object.keys(cssKeywords)) {
|
|
309
|
-
const value = cssKeywords[keyword];
|
|
310
|
-
const distance = comparativeDistance(rgb, value);
|
|
311
|
-
if (distance < currentClosestDistance) {
|
|
312
|
-
currentClosestDistance = distance;
|
|
313
|
-
currentClosestKeyword = keyword;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return currentClosestKeyword;
|
|
317
|
-
};
|
|
318
|
-
convert.keyword.rgb = function(keyword) {
|
|
319
|
-
return cssKeywords[keyword];
|
|
320
|
-
};
|
|
321
|
-
convert.rgb.xyz = function(rgb) {
|
|
322
|
-
let r = rgb[0] / 255;
|
|
323
|
-
let g = rgb[1] / 255;
|
|
324
|
-
let b = rgb[2] / 255;
|
|
325
|
-
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
326
|
-
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
327
|
-
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
328
|
-
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
329
|
-
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
330
|
-
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
331
|
-
return [x * 100, y * 100, z * 100];
|
|
332
|
-
};
|
|
333
|
-
convert.rgb.lab = function(rgb) {
|
|
334
|
-
const xyz = convert.rgb.xyz(rgb);
|
|
335
|
-
let x = xyz[0];
|
|
336
|
-
let y = xyz[1];
|
|
337
|
-
let z = xyz[2];
|
|
338
|
-
x /= 95.047;
|
|
339
|
-
y /= 100;
|
|
340
|
-
z /= 108.883;
|
|
341
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
342
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
343
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
344
|
-
const l = 116 * y - 16;
|
|
345
|
-
const a = 500 * (x - y);
|
|
346
|
-
const b = 200 * (y - z);
|
|
347
|
-
return [l, a, b];
|
|
348
|
-
};
|
|
349
|
-
convert.hsl.rgb = function(hsl) {
|
|
350
|
-
const h = hsl[0] / 360;
|
|
351
|
-
const s = hsl[1] / 100;
|
|
352
|
-
const l = hsl[2] / 100;
|
|
353
|
-
let t2;
|
|
354
|
-
let t3;
|
|
355
|
-
let val;
|
|
356
|
-
if (s === 0) {
|
|
357
|
-
val = l * 255;
|
|
358
|
-
return [val, val, val];
|
|
359
|
-
}
|
|
360
|
-
if (l < 0.5) {
|
|
361
|
-
t2 = l * (1 + s);
|
|
362
|
-
} else {
|
|
363
|
-
t2 = l + s - l * s;
|
|
364
|
-
}
|
|
365
|
-
const t1 = 2 * l - t2;
|
|
366
|
-
const rgb = [0, 0, 0];
|
|
367
|
-
for (let i = 0; i < 3; i++) {
|
|
368
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
369
|
-
if (t3 < 0) {
|
|
370
|
-
t3++;
|
|
371
|
-
}
|
|
372
|
-
if (t3 > 1) {
|
|
373
|
-
t3--;
|
|
374
|
-
}
|
|
375
|
-
if (6 * t3 < 1) {
|
|
376
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
377
|
-
} else if (2 * t3 < 1) {
|
|
378
|
-
val = t2;
|
|
379
|
-
} else if (3 * t3 < 2) {
|
|
380
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
381
|
-
} else {
|
|
382
|
-
val = t1;
|
|
383
|
-
}
|
|
384
|
-
rgb[i] = val * 255;
|
|
385
|
-
}
|
|
386
|
-
return rgb;
|
|
387
|
-
};
|
|
388
|
-
convert.hsl.hsv = function(hsl) {
|
|
389
|
-
const h = hsl[0];
|
|
390
|
-
let s = hsl[1] / 100;
|
|
391
|
-
let l = hsl[2] / 100;
|
|
392
|
-
let smin = s;
|
|
393
|
-
const lmin = Math.max(l, 0.01);
|
|
394
|
-
l *= 2;
|
|
395
|
-
s *= l <= 1 ? l : 2 - l;
|
|
396
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
397
|
-
const v = (l + s) / 2;
|
|
398
|
-
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
399
|
-
return [h, sv * 100, v * 100];
|
|
400
|
-
};
|
|
401
|
-
convert.hsv.rgb = function(hsv) {
|
|
402
|
-
const h = hsv[0] / 60;
|
|
403
|
-
const s = hsv[1] / 100;
|
|
404
|
-
let v = hsv[2] / 100;
|
|
405
|
-
const hi = Math.floor(h) % 6;
|
|
406
|
-
const f = h - Math.floor(h);
|
|
407
|
-
const p = 255 * v * (1 - s);
|
|
408
|
-
const q = 255 * v * (1 - s * f);
|
|
409
|
-
const t = 255 * v * (1 - s * (1 - f));
|
|
410
|
-
v *= 255;
|
|
411
|
-
switch (hi) {
|
|
412
|
-
case 0:
|
|
413
|
-
return [v, t, p];
|
|
414
|
-
case 1:
|
|
415
|
-
return [q, v, p];
|
|
416
|
-
case 2:
|
|
417
|
-
return [p, v, t];
|
|
418
|
-
case 3:
|
|
419
|
-
return [p, q, v];
|
|
420
|
-
case 4:
|
|
421
|
-
return [t, p, v];
|
|
422
|
-
case 5:
|
|
423
|
-
return [v, p, q];
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
convert.hsv.hsl = function(hsv) {
|
|
427
|
-
const h = hsv[0];
|
|
428
|
-
const s = hsv[1] / 100;
|
|
429
|
-
const v = hsv[2] / 100;
|
|
430
|
-
const vmin = Math.max(v, 0.01);
|
|
431
|
-
let sl;
|
|
432
|
-
let l;
|
|
433
|
-
l = (2 - s) * v;
|
|
434
|
-
const lmin = (2 - s) * vmin;
|
|
435
|
-
sl = s * vmin;
|
|
436
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
437
|
-
sl = sl || 0;
|
|
438
|
-
l /= 2;
|
|
439
|
-
return [h, sl * 100, l * 100];
|
|
440
|
-
};
|
|
441
|
-
convert.hwb.rgb = function(hwb) {
|
|
442
|
-
const h = hwb[0] / 360;
|
|
443
|
-
let wh = hwb[1] / 100;
|
|
444
|
-
let bl = hwb[2] / 100;
|
|
445
|
-
const ratio = wh + bl;
|
|
446
|
-
let f;
|
|
447
|
-
if (ratio > 1) {
|
|
448
|
-
wh /= ratio;
|
|
449
|
-
bl /= ratio;
|
|
450
|
-
}
|
|
451
|
-
const i = Math.floor(6 * h);
|
|
452
|
-
const v = 1 - bl;
|
|
453
|
-
f = 6 * h - i;
|
|
454
|
-
if ((i & 1) !== 0) {
|
|
455
|
-
f = 1 - f;
|
|
456
|
-
}
|
|
457
|
-
const n = wh + f * (v - wh);
|
|
458
|
-
let r;
|
|
459
|
-
let g;
|
|
460
|
-
let b;
|
|
461
|
-
switch (i) {
|
|
462
|
-
default:
|
|
463
|
-
case 6:
|
|
464
|
-
case 0:
|
|
465
|
-
r = v;
|
|
466
|
-
g = n;
|
|
467
|
-
b = wh;
|
|
468
|
-
break;
|
|
469
|
-
case 1:
|
|
470
|
-
r = n;
|
|
471
|
-
g = v;
|
|
472
|
-
b = wh;
|
|
473
|
-
break;
|
|
474
|
-
case 2:
|
|
475
|
-
r = wh;
|
|
476
|
-
g = v;
|
|
477
|
-
b = n;
|
|
478
|
-
break;
|
|
479
|
-
case 3:
|
|
480
|
-
r = wh;
|
|
481
|
-
g = n;
|
|
482
|
-
b = v;
|
|
483
|
-
break;
|
|
484
|
-
case 4:
|
|
485
|
-
r = n;
|
|
486
|
-
g = wh;
|
|
487
|
-
b = v;
|
|
488
|
-
break;
|
|
489
|
-
case 5:
|
|
490
|
-
r = v;
|
|
491
|
-
g = wh;
|
|
492
|
-
b = n;
|
|
493
|
-
break;
|
|
494
|
-
}
|
|
495
|
-
return [r * 255, g * 255, b * 255];
|
|
496
|
-
};
|
|
497
|
-
convert.cmyk.rgb = function(cmyk) {
|
|
498
|
-
const c = cmyk[0] / 100;
|
|
499
|
-
const m = cmyk[1] / 100;
|
|
500
|
-
const y = cmyk[2] / 100;
|
|
501
|
-
const k = cmyk[3] / 100;
|
|
502
|
-
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
503
|
-
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
504
|
-
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
505
|
-
return [r * 255, g * 255, b * 255];
|
|
506
|
-
};
|
|
507
|
-
convert.xyz.rgb = function(xyz) {
|
|
508
|
-
const x = xyz[0] / 100;
|
|
509
|
-
const y = xyz[1] / 100;
|
|
510
|
-
const z = xyz[2] / 100;
|
|
511
|
-
let r;
|
|
512
|
-
let g;
|
|
513
|
-
let b;
|
|
514
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
515
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
516
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
517
|
-
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
518
|
-
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
519
|
-
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
520
|
-
r = Math.min(Math.max(0, r), 1);
|
|
521
|
-
g = Math.min(Math.max(0, g), 1);
|
|
522
|
-
b = Math.min(Math.max(0, b), 1);
|
|
523
|
-
return [r * 255, g * 255, b * 255];
|
|
524
|
-
};
|
|
525
|
-
convert.xyz.lab = function(xyz) {
|
|
526
|
-
let x = xyz[0];
|
|
527
|
-
let y = xyz[1];
|
|
528
|
-
let z = xyz[2];
|
|
529
|
-
x /= 95.047;
|
|
530
|
-
y /= 100;
|
|
531
|
-
z /= 108.883;
|
|
532
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
533
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
534
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
535
|
-
const l = 116 * y - 16;
|
|
536
|
-
const a = 500 * (x - y);
|
|
537
|
-
const b = 200 * (y - z);
|
|
538
|
-
return [l, a, b];
|
|
539
|
-
};
|
|
540
|
-
convert.lab.xyz = function(lab) {
|
|
541
|
-
const l = lab[0];
|
|
542
|
-
const a = lab[1];
|
|
543
|
-
const b = lab[2];
|
|
544
|
-
let x;
|
|
545
|
-
let y;
|
|
546
|
-
let z;
|
|
547
|
-
y = (l + 16) / 116;
|
|
548
|
-
x = a / 500 + y;
|
|
549
|
-
z = y - b / 200;
|
|
550
|
-
const y2 = y ** 3;
|
|
551
|
-
const x2 = x ** 3;
|
|
552
|
-
const z2 = z ** 3;
|
|
553
|
-
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
554
|
-
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
555
|
-
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
556
|
-
x *= 95.047;
|
|
557
|
-
y *= 100;
|
|
558
|
-
z *= 108.883;
|
|
559
|
-
return [x, y, z];
|
|
560
|
-
};
|
|
561
|
-
convert.lab.lch = function(lab) {
|
|
562
|
-
const l = lab[0];
|
|
563
|
-
const a = lab[1];
|
|
564
|
-
const b = lab[2];
|
|
565
|
-
let h;
|
|
566
|
-
const hr = Math.atan2(b, a);
|
|
567
|
-
h = hr * 360 / 2 / Math.PI;
|
|
568
|
-
if (h < 0) {
|
|
569
|
-
h += 360;
|
|
570
|
-
}
|
|
571
|
-
const c = Math.sqrt(a * a + b * b);
|
|
572
|
-
return [l, c, h];
|
|
573
|
-
};
|
|
574
|
-
convert.lch.lab = function(lch) {
|
|
575
|
-
const l = lch[0];
|
|
576
|
-
const c = lch[1];
|
|
577
|
-
const h = lch[2];
|
|
578
|
-
const hr = h / 360 * 2 * Math.PI;
|
|
579
|
-
const a = c * Math.cos(hr);
|
|
580
|
-
const b = c * Math.sin(hr);
|
|
581
|
-
return [l, a, b];
|
|
582
|
-
};
|
|
583
|
-
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
584
|
-
const [r, g, b] = args;
|
|
585
|
-
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
586
|
-
value = Math.round(value / 50);
|
|
587
|
-
if (value === 0) {
|
|
588
|
-
return 30;
|
|
589
|
-
}
|
|
590
|
-
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
591
|
-
if (value === 2) {
|
|
592
|
-
ansi += 60;
|
|
593
|
-
}
|
|
594
|
-
return ansi;
|
|
595
|
-
};
|
|
596
|
-
convert.hsv.ansi16 = function(args) {
|
|
597
|
-
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
598
|
-
};
|
|
599
|
-
convert.rgb.ansi256 = function(args) {
|
|
600
|
-
const r = args[0];
|
|
601
|
-
const g = args[1];
|
|
602
|
-
const b = args[2];
|
|
603
|
-
if (r === g && g === b) {
|
|
604
|
-
if (r < 8) {
|
|
605
|
-
return 16;
|
|
606
|
-
}
|
|
607
|
-
if (r > 248) {
|
|
608
|
-
return 231;
|
|
609
|
-
}
|
|
610
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
611
|
-
}
|
|
612
|
-
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
613
|
-
return ansi;
|
|
614
|
-
};
|
|
615
|
-
convert.ansi16.rgb = function(args) {
|
|
616
|
-
let color = args % 10;
|
|
617
|
-
if (color === 0 || color === 7) {
|
|
618
|
-
if (args > 50) {
|
|
619
|
-
color += 3.5;
|
|
620
|
-
}
|
|
621
|
-
color = color / 10.5 * 255;
|
|
622
|
-
return [color, color, color];
|
|
623
|
-
}
|
|
624
|
-
const mult = (~~(args > 50) + 1) * 0.5;
|
|
625
|
-
const r = (color & 1) * mult * 255;
|
|
626
|
-
const g = (color >> 1 & 1) * mult * 255;
|
|
627
|
-
const b = (color >> 2 & 1) * mult * 255;
|
|
628
|
-
return [r, g, b];
|
|
629
|
-
};
|
|
630
|
-
convert.ansi256.rgb = function(args) {
|
|
631
|
-
if (args >= 232) {
|
|
632
|
-
const c = (args - 232) * 10 + 8;
|
|
633
|
-
return [c, c, c];
|
|
634
|
-
}
|
|
635
|
-
args -= 16;
|
|
636
|
-
let rem;
|
|
637
|
-
const r = Math.floor(args / 36) / 5 * 255;
|
|
638
|
-
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
639
|
-
const b = rem % 6 / 5 * 255;
|
|
640
|
-
return [r, g, b];
|
|
641
|
-
};
|
|
642
|
-
convert.rgb.hex = function(args) {
|
|
643
|
-
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
644
|
-
const string = integer.toString(16).toUpperCase();
|
|
645
|
-
return "000000".substring(string.length) + string;
|
|
646
|
-
};
|
|
647
|
-
convert.hex.rgb = function(args) {
|
|
648
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
649
|
-
if (!match) {
|
|
650
|
-
return [0, 0, 0];
|
|
651
|
-
}
|
|
652
|
-
let colorString = match[0];
|
|
653
|
-
if (match[0].length === 3) {
|
|
654
|
-
colorString = colorString.split("").map((char) => {
|
|
655
|
-
return char + char;
|
|
656
|
-
}).join("");
|
|
657
|
-
}
|
|
658
|
-
const integer = parseInt(colorString, 16);
|
|
659
|
-
const r = integer >> 16 & 255;
|
|
660
|
-
const g = integer >> 8 & 255;
|
|
661
|
-
const b = integer & 255;
|
|
662
|
-
return [r, g, b];
|
|
663
|
-
};
|
|
664
|
-
convert.rgb.hcg = function(rgb) {
|
|
665
|
-
const r = rgb[0] / 255;
|
|
666
|
-
const g = rgb[1] / 255;
|
|
667
|
-
const b = rgb[2] / 255;
|
|
668
|
-
const max = Math.max(Math.max(r, g), b);
|
|
669
|
-
const min = Math.min(Math.min(r, g), b);
|
|
670
|
-
const chroma = max - min;
|
|
671
|
-
let grayscale;
|
|
672
|
-
let hue;
|
|
673
|
-
if (chroma < 1) {
|
|
674
|
-
grayscale = min / (1 - chroma);
|
|
675
|
-
} else {
|
|
676
|
-
grayscale = 0;
|
|
677
|
-
}
|
|
678
|
-
if (chroma <= 0) {
|
|
679
|
-
hue = 0;
|
|
680
|
-
} else if (max === r) {
|
|
681
|
-
hue = (g - b) / chroma % 6;
|
|
682
|
-
} else if (max === g) {
|
|
683
|
-
hue = 2 + (b - r) / chroma;
|
|
684
|
-
} else {
|
|
685
|
-
hue = 4 + (r - g) / chroma;
|
|
686
|
-
}
|
|
687
|
-
hue /= 6;
|
|
688
|
-
hue %= 1;
|
|
689
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
690
|
-
};
|
|
691
|
-
convert.hsl.hcg = function(hsl) {
|
|
692
|
-
const s = hsl[1] / 100;
|
|
693
|
-
const l = hsl[2] / 100;
|
|
694
|
-
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
695
|
-
let f = 0;
|
|
696
|
-
if (c < 1) {
|
|
697
|
-
f = (l - 0.5 * c) / (1 - c);
|
|
698
|
-
}
|
|
699
|
-
return [hsl[0], c * 100, f * 100];
|
|
700
|
-
};
|
|
701
|
-
convert.hsv.hcg = function(hsv) {
|
|
702
|
-
const s = hsv[1] / 100;
|
|
703
|
-
const v = hsv[2] / 100;
|
|
704
|
-
const c = s * v;
|
|
705
|
-
let f = 0;
|
|
706
|
-
if (c < 1) {
|
|
707
|
-
f = (v - c) / (1 - c);
|
|
708
|
-
}
|
|
709
|
-
return [hsv[0], c * 100, f * 100];
|
|
710
|
-
};
|
|
711
|
-
convert.hcg.rgb = function(hcg) {
|
|
712
|
-
const h = hcg[0] / 360;
|
|
713
|
-
const c = hcg[1] / 100;
|
|
714
|
-
const g = hcg[2] / 100;
|
|
715
|
-
if (c === 0) {
|
|
716
|
-
return [g * 255, g * 255, g * 255];
|
|
717
|
-
}
|
|
718
|
-
const pure = [0, 0, 0];
|
|
719
|
-
const hi = h % 1 * 6;
|
|
720
|
-
const v = hi % 1;
|
|
721
|
-
const w = 1 - v;
|
|
722
|
-
let mg = 0;
|
|
723
|
-
switch (Math.floor(hi)) {
|
|
724
|
-
case 0:
|
|
725
|
-
pure[0] = 1;
|
|
726
|
-
pure[1] = v;
|
|
727
|
-
pure[2] = 0;
|
|
728
|
-
break;
|
|
729
|
-
case 1:
|
|
730
|
-
pure[0] = w;
|
|
731
|
-
pure[1] = 1;
|
|
732
|
-
pure[2] = 0;
|
|
733
|
-
break;
|
|
734
|
-
case 2:
|
|
735
|
-
pure[0] = 0;
|
|
736
|
-
pure[1] = 1;
|
|
737
|
-
pure[2] = v;
|
|
738
|
-
break;
|
|
739
|
-
case 3:
|
|
740
|
-
pure[0] = 0;
|
|
741
|
-
pure[1] = w;
|
|
742
|
-
pure[2] = 1;
|
|
743
|
-
break;
|
|
744
|
-
case 4:
|
|
745
|
-
pure[0] = v;
|
|
746
|
-
pure[1] = 0;
|
|
747
|
-
pure[2] = 1;
|
|
748
|
-
break;
|
|
749
|
-
default:
|
|
750
|
-
pure[0] = 1;
|
|
751
|
-
pure[1] = 0;
|
|
752
|
-
pure[2] = w;
|
|
753
|
-
}
|
|
754
|
-
mg = (1 - c) * g;
|
|
755
|
-
return [
|
|
756
|
-
(c * pure[0] + mg) * 255,
|
|
757
|
-
(c * pure[1] + mg) * 255,
|
|
758
|
-
(c * pure[2] + mg) * 255
|
|
759
|
-
];
|
|
760
|
-
};
|
|
761
|
-
convert.hcg.hsv = function(hcg) {
|
|
762
|
-
const c = hcg[1] / 100;
|
|
763
|
-
const g = hcg[2] / 100;
|
|
764
|
-
const v = c + g * (1 - c);
|
|
765
|
-
let f = 0;
|
|
766
|
-
if (v > 0) {
|
|
767
|
-
f = c / v;
|
|
768
|
-
}
|
|
769
|
-
return [hcg[0], f * 100, v * 100];
|
|
770
|
-
};
|
|
771
|
-
convert.hcg.hsl = function(hcg) {
|
|
772
|
-
const c = hcg[1] / 100;
|
|
773
|
-
const g = hcg[2] / 100;
|
|
774
|
-
const l = g * (1 - c) + 0.5 * c;
|
|
775
|
-
let s = 0;
|
|
776
|
-
if (l > 0 && l < 0.5) {
|
|
777
|
-
s = c / (2 * l);
|
|
778
|
-
} else if (l >= 0.5 && l < 1) {
|
|
779
|
-
s = c / (2 * (1 - l));
|
|
780
|
-
}
|
|
781
|
-
return [hcg[0], s * 100, l * 100];
|
|
782
|
-
};
|
|
783
|
-
convert.hcg.hwb = function(hcg) {
|
|
784
|
-
const c = hcg[1] / 100;
|
|
785
|
-
const g = hcg[2] / 100;
|
|
786
|
-
const v = c + g * (1 - c);
|
|
787
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
788
|
-
};
|
|
789
|
-
convert.hwb.hcg = function(hwb) {
|
|
790
|
-
const w = hwb[1] / 100;
|
|
791
|
-
const b = hwb[2] / 100;
|
|
792
|
-
const v = 1 - b;
|
|
793
|
-
const c = v - w;
|
|
794
|
-
let g = 0;
|
|
795
|
-
if (c < 1) {
|
|
796
|
-
g = (v - c) / (1 - c);
|
|
797
|
-
}
|
|
798
|
-
return [hwb[0], c * 100, g * 100];
|
|
799
|
-
};
|
|
800
|
-
convert.apple.rgb = function(apple) {
|
|
801
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
802
|
-
};
|
|
803
|
-
convert.rgb.apple = function(rgb) {
|
|
804
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
805
|
-
};
|
|
806
|
-
convert.gray.rgb = function(args) {
|
|
807
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
808
|
-
};
|
|
809
|
-
convert.gray.hsl = function(args) {
|
|
810
|
-
return [0, 0, args[0]];
|
|
811
|
-
};
|
|
812
|
-
convert.gray.hsv = convert.gray.hsl;
|
|
813
|
-
convert.gray.hwb = function(gray) {
|
|
814
|
-
return [0, 100, gray[0]];
|
|
815
|
-
};
|
|
816
|
-
convert.gray.cmyk = function(gray) {
|
|
817
|
-
return [0, 0, 0, gray[0]];
|
|
818
|
-
};
|
|
819
|
-
convert.gray.lab = function(gray) {
|
|
820
|
-
return [gray[0], 0, 0];
|
|
821
|
-
};
|
|
822
|
-
convert.gray.hex = function(gray) {
|
|
823
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
824
|
-
const integer = (val << 16) + (val << 8) + val;
|
|
825
|
-
const string = integer.toString(16).toUpperCase();
|
|
826
|
-
return "000000".substring(string.length) + string;
|
|
827
|
-
};
|
|
828
|
-
convert.rgb.gray = function(rgb) {
|
|
829
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
830
|
-
return [val / 255 * 100];
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
// ../node_modules/color-convert/route.js
|
|
836
|
-
var require_route = __commonJS({
|
|
837
|
-
"../node_modules/color-convert/route.js"(exports, module) {
|
|
838
|
-
var conversions = require_conversions();
|
|
839
|
-
function buildGraph() {
|
|
840
|
-
const graph = {};
|
|
841
|
-
const models = Object.keys(conversions);
|
|
842
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
843
|
-
graph[models[i]] = {
|
|
844
|
-
// http://jsperf.com/1-vs-infinity
|
|
845
|
-
// micro-opt, but this is simple.
|
|
846
|
-
distance: -1,
|
|
847
|
-
parent: null
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
return graph;
|
|
851
|
-
}
|
|
852
|
-
__name(buildGraph, "buildGraph");
|
|
853
|
-
function deriveBFS(fromModel) {
|
|
854
|
-
const graph = buildGraph();
|
|
855
|
-
const queue = [fromModel];
|
|
856
|
-
graph[fromModel].distance = 0;
|
|
857
|
-
while (queue.length) {
|
|
858
|
-
const current = queue.pop();
|
|
859
|
-
const adjacents = Object.keys(conversions[current]);
|
|
860
|
-
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
861
|
-
const adjacent = adjacents[i];
|
|
862
|
-
const node = graph[adjacent];
|
|
863
|
-
if (node.distance === -1) {
|
|
864
|
-
node.distance = graph[current].distance + 1;
|
|
865
|
-
node.parent = current;
|
|
866
|
-
queue.unshift(adjacent);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
return graph;
|
|
871
|
-
}
|
|
872
|
-
__name(deriveBFS, "deriveBFS");
|
|
873
|
-
function link(from, to) {
|
|
874
|
-
return function(args) {
|
|
875
|
-
return to(from(args));
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
__name(link, "link");
|
|
879
|
-
function wrapConversion(toModel, graph) {
|
|
880
|
-
const path = [graph[toModel].parent, toModel];
|
|
881
|
-
let fn = conversions[graph[toModel].parent][toModel];
|
|
882
|
-
let cur = graph[toModel].parent;
|
|
883
|
-
while (graph[cur].parent) {
|
|
884
|
-
path.unshift(graph[cur].parent);
|
|
885
|
-
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
886
|
-
cur = graph[cur].parent;
|
|
887
|
-
}
|
|
888
|
-
fn.conversion = path;
|
|
889
|
-
return fn;
|
|
890
|
-
}
|
|
891
|
-
__name(wrapConversion, "wrapConversion");
|
|
892
|
-
module.exports = function(fromModel) {
|
|
893
|
-
const graph = deriveBFS(fromModel);
|
|
894
|
-
const conversion = {};
|
|
895
|
-
const models = Object.keys(graph);
|
|
896
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
897
|
-
const toModel = models[i];
|
|
898
|
-
const node = graph[toModel];
|
|
899
|
-
if (node.parent === null) {
|
|
900
|
-
continue;
|
|
901
|
-
}
|
|
902
|
-
conversion[toModel] = wrapConversion(toModel, graph);
|
|
903
|
-
}
|
|
904
|
-
return conversion;
|
|
905
|
-
};
|
|
906
|
-
}
|
|
907
|
-
});
|
|
908
|
-
|
|
909
|
-
// ../node_modules/color-convert/index.js
|
|
910
|
-
var require_color_convert = __commonJS({
|
|
911
|
-
"../node_modules/color-convert/index.js"(exports, module) {
|
|
912
|
-
var conversions = require_conversions();
|
|
913
|
-
var route = require_route();
|
|
914
|
-
var convert = {};
|
|
915
|
-
var models = Object.keys(conversions);
|
|
916
|
-
function wrapRaw(fn) {
|
|
917
|
-
const wrappedFn = /* @__PURE__ */ __name(function(...args) {
|
|
918
|
-
const arg0 = args[0];
|
|
919
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
920
|
-
return arg0;
|
|
921
|
-
}
|
|
922
|
-
if (arg0.length > 1) {
|
|
923
|
-
args = arg0;
|
|
924
|
-
}
|
|
925
|
-
return fn(args);
|
|
926
|
-
}, "wrappedFn");
|
|
927
|
-
if ("conversion" in fn) {
|
|
928
|
-
wrappedFn.conversion = fn.conversion;
|
|
929
|
-
}
|
|
930
|
-
return wrappedFn;
|
|
931
|
-
}
|
|
932
|
-
__name(wrapRaw, "wrapRaw");
|
|
933
|
-
function wrapRounded(fn) {
|
|
934
|
-
const wrappedFn = /* @__PURE__ */ __name(function(...args) {
|
|
935
|
-
const arg0 = args[0];
|
|
936
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
937
|
-
return arg0;
|
|
938
|
-
}
|
|
939
|
-
if (arg0.length > 1) {
|
|
940
|
-
args = arg0;
|
|
941
|
-
}
|
|
942
|
-
const result = fn(args);
|
|
943
|
-
if (typeof result === "object") {
|
|
944
|
-
for (let len = result.length, i = 0; i < len; i++) {
|
|
945
|
-
result[i] = Math.round(result[i]);
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
return result;
|
|
949
|
-
}, "wrappedFn");
|
|
950
|
-
if ("conversion" in fn) {
|
|
951
|
-
wrappedFn.conversion = fn.conversion;
|
|
952
|
-
}
|
|
953
|
-
return wrappedFn;
|
|
954
|
-
}
|
|
955
|
-
__name(wrapRounded, "wrapRounded");
|
|
956
|
-
models.forEach((fromModel) => {
|
|
957
|
-
convert[fromModel] = {};
|
|
958
|
-
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
959
|
-
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
960
|
-
const routes = route(fromModel);
|
|
961
|
-
const routeModels = Object.keys(routes);
|
|
962
|
-
routeModels.forEach((toModel) => {
|
|
963
|
-
const fn = routes[toModel];
|
|
964
|
-
convert[fromModel][toModel] = wrapRounded(fn);
|
|
965
|
-
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
966
|
-
});
|
|
967
|
-
});
|
|
968
|
-
module.exports = convert;
|
|
969
|
-
}
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
export {
|
|
973
|
-
require_color_convert
|
|
974
|
-
};
|