Skip to content

Commit 7602722

Browse files
committed
🐛 accept signed int32 colors in validator
The rgba() function returns signed int32 when alpha >= 128 (bit 31 set). The validator's u32 type rejected these negative values. Add a color type that accepts the full signed-to-unsigned 32-bit range.
1 parent 0a70d40 commit 7602722

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

validate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { RenderOptions, RenderResult, Term } from "./term.ts";
88
const u8 = Type.Integer({ minimum: 0, maximum: 255 });
99
const u16 = Type.Integer({ minimum: 0, maximum: 65535 });
1010
const u32 = Type.Integer({ minimum: 0, maximum: 0xFFFFFFFF });
11+
const color = Type.Integer({ minimum: -0x80000000, maximum: 0xFFFFFFFF });
1112

1213
/* ── Sizing axis (discriminated union) ────────────────────────────── */
1314

@@ -64,7 +65,7 @@ const CornerRadius = Type.Object({
6465
});
6566

6667
const Border = Type.Object({
67-
color: u32,
68+
color: color,
6869
left: Type.Optional(u8),
6970
right: Type.Optional(u8),
7071
top: Type.Optional(u8),
@@ -93,7 +94,7 @@ const OpenElement = Type.Object({
9394
id: Type.Literal(0x02),
9495
name: Type.String(),
9596
layout: Type.Optional(Layout),
96-
bg: Type.Optional(u32),
97+
bg: Type.Optional(color),
9798
cornerRadius: Type.Optional(CornerRadius),
9899
border: Type.Optional(Border),
99100
clip: Type.Optional(Clip),
@@ -103,7 +104,7 @@ const OpenElement = Type.Object({
103104
const TextOp = Type.Object({
104105
id: Type.Literal(0x03),
105106
content: Type.String(),
106-
color: Type.Optional(u32),
107+
color: Type.Optional(color),
107108
fontSize: Type.Optional(u8),
108109
fontId: Type.Optional(u8),
109110
wrap: Type.Optional(u8),

0 commit comments

Comments
 (0)