@formepdf/shared 0.30.0 → 0.31.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/dist/colors.d.ts +6 -0
- package/dist/colors.js +156 -0
- package/dist/style.js +13 -0
- package/package.json +1 -1
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS named colours (CSS Color Module Level 4: 148 names plus `transparent`), as [r, g, b, alpha] in 0-255. The same table backs the Python SDK
|
|
3
|
+
* (`formepdf/_colors.py`) and the HTML path (`html/src/colors.rs`); a test
|
|
4
|
+
* in each keeps them identical.
|
|
5
|
+
*/
|
|
6
|
+
export declare const NAMED_COLORS: Readonly<Record<string, readonly [number, number, number, number]>>;
|
package/dist/colors.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS named colours (CSS Color Module Level 4: 148 names plus `transparent`), as [r, g, b, alpha] in 0-255. The same table backs the Python SDK
|
|
3
|
+
* (`formepdf/_colors.py`) and the HTML path (`html/src/colors.rs`); a test
|
|
4
|
+
* in each keeps them identical.
|
|
5
|
+
*/
|
|
6
|
+
export const NAMED_COLORS = {
|
|
7
|
+
aliceblue: [240, 248, 255, 255],
|
|
8
|
+
antiquewhite: [250, 235, 215, 255],
|
|
9
|
+
aqua: [0, 255, 255, 255],
|
|
10
|
+
aquamarine: [127, 255, 212, 255],
|
|
11
|
+
azure: [240, 255, 255, 255],
|
|
12
|
+
beige: [245, 245, 220, 255],
|
|
13
|
+
bisque: [255, 228, 196, 255],
|
|
14
|
+
black: [0, 0, 0, 255],
|
|
15
|
+
blanchedalmond: [255, 235, 205, 255],
|
|
16
|
+
blue: [0, 0, 255, 255],
|
|
17
|
+
blueviolet: [138, 43, 226, 255],
|
|
18
|
+
brown: [165, 42, 42, 255],
|
|
19
|
+
burlywood: [222, 184, 135, 255],
|
|
20
|
+
cadetblue: [95, 158, 160, 255],
|
|
21
|
+
chartreuse: [127, 255, 0, 255],
|
|
22
|
+
chocolate: [210, 105, 30, 255],
|
|
23
|
+
coral: [255, 127, 80, 255],
|
|
24
|
+
cornflowerblue: [100, 149, 237, 255],
|
|
25
|
+
cornsilk: [255, 248, 220, 255],
|
|
26
|
+
crimson: [220, 20, 60, 255],
|
|
27
|
+
cyan: [0, 255, 255, 255],
|
|
28
|
+
darkblue: [0, 0, 139, 255],
|
|
29
|
+
darkcyan: [0, 139, 139, 255],
|
|
30
|
+
darkgoldenrod: [184, 134, 11, 255],
|
|
31
|
+
darkgray: [169, 169, 169, 255],
|
|
32
|
+
darkgreen: [0, 100, 0, 255],
|
|
33
|
+
darkgrey: [169, 169, 169, 255],
|
|
34
|
+
darkkhaki: [189, 183, 107, 255],
|
|
35
|
+
darkmagenta: [139, 0, 139, 255],
|
|
36
|
+
darkolivegreen: [85, 107, 47, 255],
|
|
37
|
+
darkorange: [255, 140, 0, 255],
|
|
38
|
+
darkorchid: [153, 50, 204, 255],
|
|
39
|
+
darkred: [139, 0, 0, 255],
|
|
40
|
+
darksalmon: [233, 150, 122, 255],
|
|
41
|
+
darkseagreen: [143, 188, 143, 255],
|
|
42
|
+
darkslateblue: [72, 61, 139, 255],
|
|
43
|
+
darkslategray: [47, 79, 79, 255],
|
|
44
|
+
darkslategrey: [47, 79, 79, 255],
|
|
45
|
+
darkturquoise: [0, 206, 209, 255],
|
|
46
|
+
darkviolet: [148, 0, 211, 255],
|
|
47
|
+
deeppink: [255, 20, 147, 255],
|
|
48
|
+
deepskyblue: [0, 191, 255, 255],
|
|
49
|
+
dimgray: [105, 105, 105, 255],
|
|
50
|
+
dimgrey: [105, 105, 105, 255],
|
|
51
|
+
dodgerblue: [30, 144, 255, 255],
|
|
52
|
+
firebrick: [178, 34, 34, 255],
|
|
53
|
+
floralwhite: [255, 250, 240, 255],
|
|
54
|
+
forestgreen: [34, 139, 34, 255],
|
|
55
|
+
fuchsia: [255, 0, 255, 255],
|
|
56
|
+
gainsboro: [220, 220, 220, 255],
|
|
57
|
+
ghostwhite: [248, 248, 255, 255],
|
|
58
|
+
gold: [255, 215, 0, 255],
|
|
59
|
+
goldenrod: [218, 165, 32, 255],
|
|
60
|
+
gray: [128, 128, 128, 255],
|
|
61
|
+
green: [0, 128, 0, 255],
|
|
62
|
+
greenyellow: [173, 255, 47, 255],
|
|
63
|
+
grey: [128, 128, 128, 255],
|
|
64
|
+
honeydew: [240, 255, 240, 255],
|
|
65
|
+
hotpink: [255, 105, 180, 255],
|
|
66
|
+
indianred: [205, 92, 92, 255],
|
|
67
|
+
indigo: [75, 0, 130, 255],
|
|
68
|
+
ivory: [255, 255, 240, 255],
|
|
69
|
+
khaki: [240, 230, 140, 255],
|
|
70
|
+
lavender: [230, 230, 250, 255],
|
|
71
|
+
lavenderblush: [255, 240, 245, 255],
|
|
72
|
+
lawngreen: [124, 252, 0, 255],
|
|
73
|
+
lemonchiffon: [255, 250, 205, 255],
|
|
74
|
+
lightblue: [173, 216, 230, 255],
|
|
75
|
+
lightcoral: [240, 128, 128, 255],
|
|
76
|
+
lightcyan: [224, 255, 255, 255],
|
|
77
|
+
lightgoldenrodyellow: [250, 250, 210, 255],
|
|
78
|
+
lightgray: [211, 211, 211, 255],
|
|
79
|
+
lightgreen: [144, 238, 144, 255],
|
|
80
|
+
lightgrey: [211, 211, 211, 255],
|
|
81
|
+
lightpink: [255, 182, 193, 255],
|
|
82
|
+
lightsalmon: [255, 160, 122, 255],
|
|
83
|
+
lightseagreen: [32, 178, 170, 255],
|
|
84
|
+
lightskyblue: [135, 206, 250, 255],
|
|
85
|
+
lightslategray: [119, 136, 153, 255],
|
|
86
|
+
lightslategrey: [119, 136, 153, 255],
|
|
87
|
+
lightsteelblue: [176, 196, 222, 255],
|
|
88
|
+
lightyellow: [255, 255, 224, 255],
|
|
89
|
+
lime: [0, 255, 0, 255],
|
|
90
|
+
limegreen: [50, 205, 50, 255],
|
|
91
|
+
linen: [250, 240, 230, 255],
|
|
92
|
+
magenta: [255, 0, 255, 255],
|
|
93
|
+
maroon: [128, 0, 0, 255],
|
|
94
|
+
mediumaquamarine: [102, 205, 170, 255],
|
|
95
|
+
mediumblue: [0, 0, 205, 255],
|
|
96
|
+
mediumorchid: [186, 85, 211, 255],
|
|
97
|
+
mediumpurple: [147, 112, 219, 255],
|
|
98
|
+
mediumseagreen: [60, 179, 113, 255],
|
|
99
|
+
mediumslateblue: [123, 104, 238, 255],
|
|
100
|
+
mediumspringgreen: [0, 250, 154, 255],
|
|
101
|
+
mediumturquoise: [72, 209, 204, 255],
|
|
102
|
+
mediumvioletred: [199, 21, 133, 255],
|
|
103
|
+
midnightblue: [25, 25, 112, 255],
|
|
104
|
+
mintcream: [245, 255, 250, 255],
|
|
105
|
+
mistyrose: [255, 228, 225, 255],
|
|
106
|
+
moccasin: [255, 228, 181, 255],
|
|
107
|
+
navajowhite: [255, 222, 173, 255],
|
|
108
|
+
navy: [0, 0, 128, 255],
|
|
109
|
+
oldlace: [253, 245, 230, 255],
|
|
110
|
+
olive: [128, 128, 0, 255],
|
|
111
|
+
olivedrab: [107, 142, 35, 255],
|
|
112
|
+
orange: [255, 165, 0, 255],
|
|
113
|
+
orangered: [255, 69, 0, 255],
|
|
114
|
+
orchid: [218, 112, 214, 255],
|
|
115
|
+
palegoldenrod: [238, 232, 170, 255],
|
|
116
|
+
palegreen: [152, 251, 152, 255],
|
|
117
|
+
paleturquoise: [175, 238, 238, 255],
|
|
118
|
+
palevioletred: [219, 112, 147, 255],
|
|
119
|
+
papayawhip: [255, 239, 213, 255],
|
|
120
|
+
peachpuff: [255, 218, 185, 255],
|
|
121
|
+
peru: [205, 133, 63, 255],
|
|
122
|
+
pink: [255, 192, 203, 255],
|
|
123
|
+
plum: [221, 160, 221, 255],
|
|
124
|
+
powderblue: [176, 224, 230, 255],
|
|
125
|
+
purple: [128, 0, 128, 255],
|
|
126
|
+
rebeccapurple: [102, 51, 153, 255],
|
|
127
|
+
red: [255, 0, 0, 255],
|
|
128
|
+
rosybrown: [188, 143, 143, 255],
|
|
129
|
+
royalblue: [65, 105, 225, 255],
|
|
130
|
+
saddlebrown: [139, 69, 19, 255],
|
|
131
|
+
salmon: [250, 128, 114, 255],
|
|
132
|
+
sandybrown: [244, 164, 96, 255],
|
|
133
|
+
seagreen: [46, 139, 87, 255],
|
|
134
|
+
seashell: [255, 245, 238, 255],
|
|
135
|
+
sienna: [160, 82, 45, 255],
|
|
136
|
+
silver: [192, 192, 192, 255],
|
|
137
|
+
skyblue: [135, 206, 235, 255],
|
|
138
|
+
slateblue: [106, 90, 205, 255],
|
|
139
|
+
slategray: [112, 128, 144, 255],
|
|
140
|
+
slategrey: [112, 128, 144, 255],
|
|
141
|
+
snow: [255, 250, 250, 255],
|
|
142
|
+
springgreen: [0, 255, 127, 255],
|
|
143
|
+
steelblue: [70, 130, 180, 255],
|
|
144
|
+
tan: [210, 180, 140, 255],
|
|
145
|
+
teal: [0, 128, 128, 255],
|
|
146
|
+
thistle: [216, 191, 216, 255],
|
|
147
|
+
tomato: [255, 99, 71, 255],
|
|
148
|
+
transparent: [0, 0, 0, 0],
|
|
149
|
+
turquoise: [64, 224, 208, 255],
|
|
150
|
+
violet: [238, 130, 238, 255],
|
|
151
|
+
wheat: [245, 222, 179, 255],
|
|
152
|
+
white: [255, 255, 255, 255],
|
|
153
|
+
whitesmoke: [245, 245, 245, 255],
|
|
154
|
+
yellow: [255, 255, 0, 255],
|
|
155
|
+
yellowgreen: [154, 205, 50, 255],
|
|
156
|
+
};
|
package/dist/style.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NAMED_COLORS } from './colors.js';
|
|
1
2
|
// ─── Style mapping ──────────────────────────────────────────────────
|
|
2
3
|
const FLEX_DIRECTION_MAP = {
|
|
3
4
|
'row': 'Row',
|
|
@@ -460,7 +461,19 @@ export function parseColor(hex) {
|
|
|
460
461
|
a: 1,
|
|
461
462
|
};
|
|
462
463
|
}
|
|
464
|
+
// CSS colour names (`red`, `rebeccapurple`, `transparent`). Read as hex,
|
|
465
|
+
// "red" became r: NaN, which serializes as null and failed the whole
|
|
466
|
+
// render with a schema error that never mentioned colour.
|
|
467
|
+
const named = NAMED_COLORS[s.toLowerCase()];
|
|
468
|
+
if (named) {
|
|
469
|
+
return { r: named[0] / 255, g: named[1] / 255, b: named[2] / 255, a: named[3] / 255 };
|
|
470
|
+
}
|
|
463
471
|
const h = s.replace(/^#/, '');
|
|
472
|
+
// Anything else that is not hex falls back to black below rather than
|
|
473
|
+
// producing NaN channels.
|
|
474
|
+
if (!/^[0-9a-fA-F]+$/.test(h)) {
|
|
475
|
+
return { r: 0, g: 0, b: 0, a: 1 };
|
|
476
|
+
}
|
|
464
477
|
if (h.length === 3) {
|
|
465
478
|
const r = parseInt(h[0] + h[0], 16) / 255;
|
|
466
479
|
const g = parseInt(h[1] + h[1], 16) / 255;
|