chromonym 1.0.0 → 1.1.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/README.md +165 -3
- package/dist/colorspaces/index.d.ts +4 -0
- package/dist/colorspaces/index.d.ts.map +1 -0
- package/dist/colorspaces/index.js +4 -0
- package/dist/colorspaces/index.js.map +1 -0
- package/dist/colorspaces/pantone.d.ts +919 -0
- package/dist/colorspaces/pantone.d.ts.map +1 -0
- package/dist/colorspaces/pantone.js +918 -0
- package/dist/colorspaces/pantone.js.map +1 -0
- package/dist/colorspaces/web.d.ts +156 -0
- package/dist/colorspaces/web.d.ts.map +1 -0
- package/dist/colorspaces/web.js +155 -0
- package/dist/colorspaces/web.js.map +1 -0
- package/dist/colorspaces/x11.d.ts +667 -0
- package/dist/colorspaces/x11.d.ts.map +1 -0
- package/dist/colorspaces/x11.js +666 -0
- package/dist/colorspaces/x11.js.map +1 -0
- package/dist/conversions/hex.d.ts +13 -0
- package/dist/conversions/hex.d.ts.map +1 -0
- package/dist/conversions/hex.js +39 -0
- package/dist/conversions/hex.js.map +1 -0
- package/dist/conversions/hsl.d.ts +12 -0
- package/dist/conversions/hsl.d.ts.map +1 -0
- package/dist/conversions/hsl.js +90 -0
- package/dist/conversions/hsl.js.map +1 -0
- package/dist/conversions/hsv.d.ts +12 -0
- package/dist/conversions/hsv.d.ts.map +1 -0
- package/dist/conversions/hsv.js +85 -0
- package/dist/conversions/hsv.js.map +1 -0
- package/dist/conversions/index.d.ts +6 -0
- package/dist/conversions/index.d.ts.map +1 -0
- package/dist/conversions/index.js +6 -0
- package/dist/conversions/index.js.map +1 -0
- package/dist/conversions/pantone.d.ts +14 -0
- package/dist/conversions/pantone.d.ts.map +1 -0
- package/dist/conversions/pantone.js +63 -0
- package/dist/conversions/pantone.js.map +1 -0
- package/dist/conversions/rgb.d.ts +13 -0
- package/dist/conversions/rgb.d.ts.map +1 -0
- package/dist/conversions/rgb.js +46 -0
- package/dist/conversions/rgb.js.map +1 -0
- package/dist/convert.d.ts +10 -0
- package/dist/convert.d.ts.map +1 -0
- package/dist/convert.js +51 -0
- package/dist/convert.js.map +1 -0
- package/dist/detectFormat.d.ts +9 -0
- package/dist/detectFormat.d.ts.map +1 -0
- package/dist/detectFormat.js +47 -0
- package/dist/detectFormat.js.map +1 -0
- package/dist/identify.d.ts +12 -0
- package/dist/identify.d.ts.map +1 -0
- package/dist/identify.js +44 -0
- package/dist/identify.js.map +1 -0
- package/dist/index.d.ts +14 -337
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -267
- package/dist/index.js.map +1 -1
- package/dist/math/euclideanDistance.d.ts +9 -0
- package/dist/math/euclideanDistance.d.ts.map +1 -0
- package/dist/math/euclideanDistance.js +13 -0
- package/dist/math/euclideanDistance.js.map +1 -0
- package/dist/math/index.d.ts +2 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math/index.js +4 -0
- package/dist/math/index.js.map +1 -0
- package/dist/resolve.d.ts +14 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +49 -0
- package/dist/resolve.js.map +1 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,268 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'rgb(255,153,51)',
|
|
17
|
-
'rgb(255,178,102)',
|
|
18
|
-
'rgb(255,204,153)',
|
|
19
|
-
],
|
|
20
|
-
yellow: [
|
|
21
|
-
'rgb(102,102,0)',
|
|
22
|
-
'rgb(153,153,0)',
|
|
23
|
-
'rgb(204,204,0)',
|
|
24
|
-
'rgb(255,255,0)',
|
|
25
|
-
'rgb(255,255,51)',
|
|
26
|
-
'rgb(255,255,102)',
|
|
27
|
-
'rgb(255,255,153)',
|
|
28
|
-
'rgb(255,255,204)',
|
|
29
|
-
],
|
|
30
|
-
green: [
|
|
31
|
-
'rgb(124,252,0)',
|
|
32
|
-
'rgb(127,255,0)',
|
|
33
|
-
'rgb(50,205,50)',
|
|
34
|
-
'rgb(0,255,0)',
|
|
35
|
-
'rgb(34,139,34)',
|
|
36
|
-
'rgb(0,128,0)',
|
|
37
|
-
'rgb(0,100,0)',
|
|
38
|
-
'rgb(173,255,47)',
|
|
39
|
-
'rgb(154,205,50)',
|
|
40
|
-
'rgb(0,255,127)',
|
|
41
|
-
'rgb(0,250,154)',
|
|
42
|
-
'rgb(144,238,144)',
|
|
43
|
-
'rgb(152,251,152)',
|
|
44
|
-
'rgb(143,188,143)',
|
|
45
|
-
'rgb(60,179,113)',
|
|
46
|
-
'rgb(46,139,87)',
|
|
47
|
-
'rgb(128,128,0)',
|
|
48
|
-
'rgb(85,107,47)',
|
|
49
|
-
'rgb(107,142,35)',
|
|
50
|
-
'rgb(2,166,165)',
|
|
51
|
-
'rgb(13,125,126)',
|
|
52
|
-
],
|
|
53
|
-
blue: [
|
|
54
|
-
'rgb(0,0,102)',
|
|
55
|
-
'rgb(0,0,153)',
|
|
56
|
-
'rgb(0,0,255)',
|
|
57
|
-
'rgb(51,51,255)',
|
|
58
|
-
'rgb(102,102,255)',
|
|
59
|
-
'rgb(0,51,102)',
|
|
60
|
-
'rgb(0,76,153)',
|
|
61
|
-
'rgb(0,102,204)',
|
|
62
|
-
'rgb(0,128,255)',
|
|
63
|
-
'rgb(51,153,255)',
|
|
64
|
-
'rgb(102,178,255)',
|
|
65
|
-
'rgb(0,204,204)',
|
|
66
|
-
'rgb(0,255,255)',
|
|
67
|
-
'rgb(51,255,255)',
|
|
68
|
-
'rgb(153,255,255)',
|
|
69
|
-
'rgb(204,229,255)',
|
|
70
|
-
'rgb(196,218,242)',
|
|
71
|
-
],
|
|
72
|
-
white: [
|
|
73
|
-
'rgb(255,255,255)',
|
|
74
|
-
'rgb(255,250,250)',
|
|
75
|
-
'rgb(240,255,240)',
|
|
76
|
-
'rgb(245,255,250)',
|
|
77
|
-
'rgb(255,255,240)',
|
|
78
|
-
'rgb(196,222,237)',
|
|
79
|
-
'rgb(254,249,191)',
|
|
80
|
-
'rgb(169,199,209)',
|
|
81
|
-
],
|
|
82
|
-
pink: [
|
|
83
|
-
'rgb(51,0,51)',
|
|
84
|
-
'rgb(102,0,102)',
|
|
85
|
-
'rgb(153,0,153)',
|
|
86
|
-
'rgb(204,0,204)',
|
|
87
|
-
'rgb(255,0,255)',
|
|
88
|
-
'rgb(255,51,255)',
|
|
89
|
-
'rgb(255,102,255)',
|
|
90
|
-
'rgb(255,153,255)',
|
|
91
|
-
'rgb(255,204,255)',
|
|
92
|
-
'rgb(251,140,173)',
|
|
93
|
-
'rgb(211,78,125)',
|
|
94
|
-
],
|
|
95
|
-
black: ['rgb(0,0,0)', 'rgb(32,32,32)'],
|
|
96
|
-
grey: [
|
|
97
|
-
'rgb(64,64,64)',
|
|
98
|
-
'rgb(96,96,96)',
|
|
99
|
-
'rgb(128,128,128)',
|
|
100
|
-
'rgb(160,160,160)',
|
|
101
|
-
'rgb(192,192,192)',
|
|
102
|
-
],
|
|
103
|
-
purple: [
|
|
104
|
-
'rgb(51,0,102)',
|
|
105
|
-
'rgb(76,0,153)',
|
|
106
|
-
'rgb(102,0,204)',
|
|
107
|
-
'rgb(127,0,255)',
|
|
108
|
-
'rgb(153,51,255)',
|
|
109
|
-
'rgb(178,102,255)',
|
|
110
|
-
'rgb(204,153,255)',
|
|
111
|
-
],
|
|
112
|
-
};
|
|
113
|
-
export const cssColorList = {
|
|
114
|
-
aliceblue: '#f0f8ff',
|
|
115
|
-
antiquewhite: '#faebd7',
|
|
116
|
-
aqua: '#00ffff',
|
|
117
|
-
aquamarine: '#7fffd4',
|
|
118
|
-
azure: '#f0ffff',
|
|
119
|
-
beige: '#f5f5dc',
|
|
120
|
-
bisque: '#ffe4c4',
|
|
121
|
-
black: '#000000',
|
|
122
|
-
blanchedalmond: '#ffebcd',
|
|
123
|
-
blue: '#0000ff',
|
|
124
|
-
blueviolet: '#8a2be2',
|
|
125
|
-
brown: '#a52a2a',
|
|
126
|
-
burlywood: '#deb887',
|
|
127
|
-
cadetblue: '#5f9ea0',
|
|
128
|
-
chartreuse: '#7fff00',
|
|
129
|
-
chocolate: '#d2691e',
|
|
130
|
-
coral: '#ff7f50',
|
|
131
|
-
cornflowerblue: '#6495ed',
|
|
132
|
-
cornsilk: '#fff8dc',
|
|
133
|
-
crimson: '#dc143c',
|
|
134
|
-
cyan: '#00ffff',
|
|
135
|
-
darkblue: '#00008b',
|
|
136
|
-
darkcyan: '#008b8b',
|
|
137
|
-
darkgoldenrod: '#b8860b',
|
|
138
|
-
darkgray: '#a9a9a9',
|
|
139
|
-
darkgreen: '#006400',
|
|
140
|
-
darkgrey: '#a9a9a9',
|
|
141
|
-
darkkhaki: '#bdb76b',
|
|
142
|
-
darkmagenta: '#8b008b',
|
|
143
|
-
darkolivegreen: '#556b2f',
|
|
144
|
-
darkorange: '#ff8c00',
|
|
145
|
-
darkorchid: '#9932cc',
|
|
146
|
-
darkred: '#8b0000',
|
|
147
|
-
darksalmon: '#e9967a',
|
|
148
|
-
darkseagreen: '#8fbc8f',
|
|
149
|
-
darkslateblue: '#483d8b',
|
|
150
|
-
darkslategray: '#2f4f4f',
|
|
151
|
-
darkslategrey: '#2f4f4f',
|
|
152
|
-
darkturquoise: '#00ced1',
|
|
153
|
-
darkviolet: '#9400d3',
|
|
154
|
-
deeppink: '#ff1493',
|
|
155
|
-
deepskyblue: '#00bfff',
|
|
156
|
-
dimgray: '#696969',
|
|
157
|
-
dimgrey: '#696969',
|
|
158
|
-
dodgerblue: '#1e90ff',
|
|
159
|
-
firebrick: '#b22222',
|
|
160
|
-
floralwhite: '#fffaf0',
|
|
161
|
-
forestgreen: '#228b22',
|
|
162
|
-
fuchsia: '#ff00ff',
|
|
163
|
-
gainsboro: '#dcdcdc',
|
|
164
|
-
ghostwhite: '#f8f8ff',
|
|
165
|
-
goldenrod: '#daa520',
|
|
166
|
-
gold: '#ffd700',
|
|
167
|
-
gray: '#808080',
|
|
168
|
-
green: '#008000',
|
|
169
|
-
greenyellow: '#adff2f',
|
|
170
|
-
grey: '#808080',
|
|
171
|
-
honeydew: '#f0fff0',
|
|
172
|
-
hotpink: '#ff69b4',
|
|
173
|
-
indianred: '#cd5c5c',
|
|
174
|
-
indigo: '#4b0082',
|
|
175
|
-
ivory: '#fffff0',
|
|
176
|
-
khaki: '#f0e68c',
|
|
177
|
-
lavenderblush: '#fff0f5',
|
|
178
|
-
lavender: '#e6e6fa',
|
|
179
|
-
lawngreen: '#7cfc00',
|
|
180
|
-
lemonchiffon: '#fffacd',
|
|
181
|
-
lightblue: '#add8e6',
|
|
182
|
-
lightcoral: '#f08080',
|
|
183
|
-
lightcyan: '#e0ffff',
|
|
184
|
-
lightgoldenrodyellow: '#fafad2',
|
|
185
|
-
lightgray: '#d3d3d3',
|
|
186
|
-
lightgreen: '#90ee90',
|
|
187
|
-
lightgrey: '#d3d3d3',
|
|
188
|
-
lightpink: '#ffb6c1',
|
|
189
|
-
lightsalmon: '#ffa07a',
|
|
190
|
-
lightseagreen: '#20b2aa',
|
|
191
|
-
lightskyblue: '#87cefa',
|
|
192
|
-
lightslategray: '#778899',
|
|
193
|
-
lightslategrey: '#778899',
|
|
194
|
-
lightsteelblue: '#b0c4de',
|
|
195
|
-
lightyellow: '#ffffe0',
|
|
196
|
-
lime: '#00ff00',
|
|
197
|
-
limegreen: '#32cd32',
|
|
198
|
-
linen: '#faf0e6',
|
|
199
|
-
magenta: '#ff00ff',
|
|
200
|
-
maroon: '#800000',
|
|
201
|
-
mediumaquamarine: '#66cdaa',
|
|
202
|
-
mediumblue: '#0000cd',
|
|
203
|
-
mediumorchid: '#ba55d3',
|
|
204
|
-
mediumpurple: '#9370db',
|
|
205
|
-
mediumseagreen: '#3cb371',
|
|
206
|
-
mediumslateblue: '#7b68ee',
|
|
207
|
-
mediumspringgreen: '#00fa9a',
|
|
208
|
-
mediumturquoise: '#48d1cc',
|
|
209
|
-
mediumvioletred: '#c71585',
|
|
210
|
-
midnightblue: '#191970',
|
|
211
|
-
mintcream: '#f5fffa',
|
|
212
|
-
mistyrose: '#ffe4e1',
|
|
213
|
-
moccasin: '#ffe4b5',
|
|
214
|
-
navajowhite: '#ffdead',
|
|
215
|
-
navy: '#000080',
|
|
216
|
-
oldlace: '#fdf5e6',
|
|
217
|
-
olive: '#808000',
|
|
218
|
-
olivedrab: '#6b8e23',
|
|
219
|
-
orange: '#ffa500',
|
|
220
|
-
orangered: '#ff4500',
|
|
221
|
-
orchid: '#da70d6',
|
|
222
|
-
palegoldenrod: '#eee8aa',
|
|
223
|
-
palegreen: '#98fb98',
|
|
224
|
-
paleturquoise: '#afeeee',
|
|
225
|
-
palevioletred: '#db7093',
|
|
226
|
-
papayawhip: '#ffefd5',
|
|
227
|
-
peachpuff: '#ffdab9',
|
|
228
|
-
peru: '#cd853f',
|
|
229
|
-
pink: '#ffc0cb',
|
|
230
|
-
plum: '#dda0dd',
|
|
231
|
-
powderblue: '#b0e0e6',
|
|
232
|
-
purple: '#800080',
|
|
233
|
-
rebeccapurple: '#663399',
|
|
234
|
-
red: '#ff0000',
|
|
235
|
-
rosybrown: '#bc8f8f',
|
|
236
|
-
royalblue: '#4169e1',
|
|
237
|
-
saddlebrown: '#8b4513',
|
|
238
|
-
salmon: '#fa8072',
|
|
239
|
-
sandybrown: '#f4a460',
|
|
240
|
-
seagreen: '#2e8b57',
|
|
241
|
-
seashell: '#fff5ee',
|
|
242
|
-
sienna: '#a0522d',
|
|
243
|
-
silver: '#c0c0c0',
|
|
244
|
-
skyblue: '#87ceeb',
|
|
245
|
-
slateblue: '#6a5acd',
|
|
246
|
-
slategray: '#708090',
|
|
247
|
-
slategrey: '#708090',
|
|
248
|
-
snow: '#fffafa',
|
|
249
|
-
springgreen: '#00ff7f',
|
|
250
|
-
steelblue: '#4682b4',
|
|
251
|
-
tan: '#d2b48c',
|
|
252
|
-
teal: '#008080',
|
|
253
|
-
thistle: '#d8bfd8',
|
|
254
|
-
tomato: '#ff6347',
|
|
255
|
-
turquoise: '#40e0d0',
|
|
256
|
-
violet: '#ee82ee',
|
|
257
|
-
wheat: '#f5deb3',
|
|
258
|
-
white: '#ffffff',
|
|
259
|
-
whitesmoke: '#f5f5f5',
|
|
260
|
-
yellow: '#ffff00',
|
|
261
|
-
yellowgreen: '#9acd32',
|
|
262
|
-
};
|
|
263
|
-
export const colors = {
|
|
264
|
-
...colorGroups,
|
|
265
|
-
cssColorList,
|
|
266
|
-
};
|
|
267
|
-
export default colors;
|
|
1
|
+
// Public API barrel — explicit named re-exports only (tree-shake friendly).
|
|
2
|
+
// No default export; no side effects at module scope.
|
|
3
|
+
export { pantone } from './colorspaces/pantone';
|
|
4
|
+
export { web } from './colorspaces/web';
|
|
5
|
+
export { x11 } from './colorspaces/x11';
|
|
6
|
+
export { hexToRgba, rgbaToHex } from './conversions/hex';
|
|
7
|
+
export { hslToRgba, rgbaToHsl } from './conversions/hsl';
|
|
8
|
+
export { hsvToRgba, rgbaToHsv } from './conversions/hsv';
|
|
9
|
+
export { pantoneToRgba, rgbaToPantone } from './conversions/pantone';
|
|
10
|
+
export { rgbaToRgb, rgbToRgba } from './conversions/rgb';
|
|
11
|
+
export { convert } from './convert';
|
|
12
|
+
export { detectFormat } from './detectFormat';
|
|
13
|
+
export { identify } from './identify';
|
|
14
|
+
export { resolve } from './resolve';
|
|
15
|
+
export { COLOR_FORMATS } from './types';
|
|
268
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,sDAAsD;AAEtD,OAAO,EAAyB,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAqB,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAqB,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAuB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rgba } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Euclidean distance between two colors in RGB space.
|
|
4
|
+
* Alpha channel is ignored (matches classic `detect-color` behavior).
|
|
5
|
+
* Not perceptually accurate — use deltaE (CIE Lab) for color matching
|
|
6
|
+
* where perceptual uniformity matters.
|
|
7
|
+
*/
|
|
8
|
+
export declare function euclideanDistance(a: Rgba, b: Rgba): number;
|
|
9
|
+
//# sourceMappingURL=euclideanDistance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"euclideanDistance.d.ts","sourceRoot":"","sources":["../../src/math/euclideanDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAK1D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Euclidean distance between two colors in RGB space.
|
|
3
|
+
* Alpha channel is ignored (matches classic `detect-color` behavior).
|
|
4
|
+
* Not perceptually accurate — use deltaE (CIE Lab) for color matching
|
|
5
|
+
* where perceptual uniformity matters.
|
|
6
|
+
*/
|
|
7
|
+
export function euclideanDistance(a, b) {
|
|
8
|
+
const dr = a.r - b.r;
|
|
9
|
+
const dg = a.g - b.g;
|
|
10
|
+
const db = a.b - b.b;
|
|
11
|
+
return Math.sqrt(dr * dr + dg * dg + db * db);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=euclideanDistance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"euclideanDistance.js","sourceRoot":"","sources":["../../src/math/euclideanDistance.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAO,EAAE,CAAO;IAChD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+DAA+D;AAC/D,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ColorFormat, ColorspaceName, ColorValue } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a human-readable name to a color. Normalizes the input
|
|
4
|
+
* (lowercases, strips non-alphanumeric characters, and for the pantone
|
|
5
|
+
* colorspace also strips a leading "Pantone" or "PMS" prefix) before
|
|
6
|
+
* looking it up in the chosen colorspace. Returns `null` if unknown.
|
|
7
|
+
*
|
|
8
|
+
* Defaults: colorspace = 'web', format = 'HEX'.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolve(name: string, opts?: {
|
|
11
|
+
colorspace?: ColorspaceName;
|
|
12
|
+
format?: ColorFormat;
|
|
13
|
+
}): ColorValue | null;
|
|
14
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAc,cAAc,EAAE,UAAU,EAAY,MAAM,SAAS,CAAC;AAiC7F;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GAC/D,UAAU,GAAG,IAAI,CAQnB"}
|
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { pantone } from './colorspaces/pantone';
|
|
2
|
+
import { web } from './colorspaces/web';
|
|
3
|
+
import { x11 } from './colorspaces/x11';
|
|
4
|
+
import { convert } from './convert';
|
|
5
|
+
const COLORSPACES = { web, x11, pantone };
|
|
6
|
+
function normalize(s) {
|
|
7
|
+
return s.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
8
|
+
}
|
|
9
|
+
// Pantone-specific: also strip leading "Pantone" / "PMS" prefix so that
|
|
10
|
+
// "Pantone 185 C" and "PMS 185C" both resolve to "185C".
|
|
11
|
+
function normalizeForPantone(s) {
|
|
12
|
+
return s
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(/^(pantone|pms)\s*/, '')
|
|
15
|
+
.replace(/[^a-z0-9]/g, '');
|
|
16
|
+
}
|
|
17
|
+
const indexes = new Map();
|
|
18
|
+
function getIndex(colorspace) {
|
|
19
|
+
let idx = indexes.get(colorspace);
|
|
20
|
+
if (idx === undefined) {
|
|
21
|
+
idx = new Map();
|
|
22
|
+
const space = COLORSPACES[colorspace];
|
|
23
|
+
const normFn = colorspace === 'pantone' ? normalizeForPantone : normalize;
|
|
24
|
+
for (const key of Object.keys(space)) {
|
|
25
|
+
idx.set(normFn(key), key);
|
|
26
|
+
}
|
|
27
|
+
indexes.set(colorspace, idx);
|
|
28
|
+
}
|
|
29
|
+
return idx;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a human-readable name to a color. Normalizes the input
|
|
33
|
+
* (lowercases, strips non-alphanumeric characters, and for the pantone
|
|
34
|
+
* colorspace also strips a leading "Pantone" or "PMS" prefix) before
|
|
35
|
+
* looking it up in the chosen colorspace. Returns `null` if unknown.
|
|
36
|
+
*
|
|
37
|
+
* Defaults: colorspace = 'web', format = 'HEX'.
|
|
38
|
+
*/
|
|
39
|
+
export function resolve(name, opts = {}) {
|
|
40
|
+
const { colorspace = 'web', format = 'HEX' } = opts;
|
|
41
|
+
const normFn = colorspace === 'pantone' ? normalizeForPantone : normalize;
|
|
42
|
+
const canonical = getIndex(colorspace).get(normFn(name));
|
|
43
|
+
if (canonical === undefined)
|
|
44
|
+
return null;
|
|
45
|
+
const space = COLORSPACES[colorspace];
|
|
46
|
+
const hex = space[canonical];
|
|
47
|
+
return convert(hex, { format });
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,WAAW,GAAuC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAE9E,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,wEAAwE;AACxE,yDAAyD;AACzD,SAAS,mBAAmB,CAAC,CAAS;IACpC,OAAO,CAAC;SACL,WAAW,EAAE;SACb,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuC,CAAC;AAE/D,SAAS,QAAQ,CAAC,UAA0B;IAC1C,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAClC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1E,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CACrB,IAAY,EACZ,IAAI,GAA0D,EAAE;IAEhE,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;IACpD,MAAM,MAAM,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAa,CAAC;IACzC,OAAO,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type HexColor = `#${string}`;
|
|
2
|
+
export type RgbString = `rgb(${number},${number},${number})` | `rgb(${number}, ${number}, ${number})`;
|
|
3
|
+
export type RgbTuple = readonly [r: number, g: number, b: number];
|
|
4
|
+
export type RgbObject = {
|
|
5
|
+
r: number;
|
|
6
|
+
g: number;
|
|
7
|
+
b: number;
|
|
8
|
+
};
|
|
9
|
+
export type RgbInput = RgbString | RgbTuple | RgbObject;
|
|
10
|
+
export type RgbaString = `rgba(${number},${number},${number},${number})` | `rgba(${number}, ${number}, ${number}, ${number})`;
|
|
11
|
+
export type RgbaTuple = readonly [r: number, g: number, b: number, a: number];
|
|
12
|
+
export type Rgba = {
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
a: number;
|
|
17
|
+
};
|
|
18
|
+
export type RgbaInput = RgbaString | RgbaTuple | Rgba;
|
|
19
|
+
export type HslString = `hsl(${number}, ${number}%, ${number}%)`;
|
|
20
|
+
export type HslObject = {
|
|
21
|
+
h: number;
|
|
22
|
+
s: number;
|
|
23
|
+
l: number;
|
|
24
|
+
};
|
|
25
|
+
export type HslInput = HslString | HslObject;
|
|
26
|
+
export type HsvString = `hsv(${number}, ${number}%, ${number}%)`;
|
|
27
|
+
export type HsvObject = {
|
|
28
|
+
h: number;
|
|
29
|
+
s: number;
|
|
30
|
+
v: number;
|
|
31
|
+
};
|
|
32
|
+
export type HsvInput = HsvString | HsvObject;
|
|
33
|
+
export type PantoneCode = string;
|
|
34
|
+
export type ColorInput = HexColor | RgbInput | RgbaInput | HslInput | HsvInput | PantoneCode;
|
|
35
|
+
declare const FORMAT_VALUES: readonly ['HEX', 'RGB', 'RGBA', 'HSL', 'HSV', 'PANTONE'];
|
|
36
|
+
export type ColorFormat = (typeof FORMAT_VALUES)[number];
|
|
37
|
+
export declare const COLOR_FORMATS: ReadonlySet<ColorFormat>;
|
|
38
|
+
export type ColorValue = HexColor | RgbString | Rgba | HslString | HsvString | PantoneCode;
|
|
39
|
+
export type Colorspace = Record<string, HexColor>;
|
|
40
|
+
export type ColorspaceName = 'web' | 'x11' | 'pantone';
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAC;AAGpC,MAAM,MAAM,SAAS,GACjB,OAAO,MAAM,IAAI,MAAM,IAAI,MAAM,GAAG,GACpC,OAAO,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"chromonym",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Color naming tool — resolve RGB or Hex color input to a human-readable name.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"color",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/simiancraft/chromonym/issues"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
24
25
|
"main": "./dist/index.js",
|
|
25
26
|
"module": "./dist/index.js",
|
|
26
27
|
"types": "./dist/index.d.ts",
|
|
@@ -48,9 +49,10 @@
|
|
|
48
49
|
"@biomejs/biome": "^2.2.0",
|
|
49
50
|
"@semantic-release/changelog": "^6.0.3",
|
|
50
51
|
"@semantic-release/git": "^10.0.1",
|
|
52
|
+
"@semantic-release/npm": "^13.1.5",
|
|
51
53
|
"@types/bun": "latest",
|
|
52
54
|
"@typescript/native-preview": "latest",
|
|
53
|
-
"semantic-release": "^
|
|
55
|
+
"semantic-release": "^25.0.3"
|
|
54
56
|
},
|
|
55
57
|
"publishConfig": {
|
|
56
58
|
"access": "public",
|