Skip to content

Commit

Permalink
More KLE type improvements, more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdisThomann committed Jan 29, 2023
1 parent 2112b8c commit d91b2ca
Show file tree
Hide file tree
Showing 8 changed files with 522 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@the-via/reader",
"version": "1.5.1",
"version": "1.5.2",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/the-via/reader.git"
Expand Down
20 changes: 2 additions & 18 deletions src/types.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export type Decal = {
d: boolean;
};

export type OtherKLEProps = {[key: string]: any};

export type KeyColor = string;
export type LegendColor = string;

Expand All @@ -45,8 +43,7 @@ export type Dimensions = {
h: number;
};
export type KLEElem =
| (KLEDimensions & Formatting & Decal & OptionalDimensions)
| OtherKLEProps
| Partial<KLEDimensions & Formatting & Decal & OptionalDimensions>
| string;
export type ColorCount = {[key: string]: number};
export type ParsedKLE = {
Expand Down Expand Up @@ -90,24 +87,11 @@ export enum KeyColorType {
Accent = 'accent',
}

export type KLEFormattingObject = Partial<{
c: string;
t: string;
x: number;
y: number;
w: number;
a: number;
d: boolean;
}>;

export type KLEMeta = {
name?: string;
};

export type KLELayoutDefinition = (
| KLEMeta
| (string | KLEFormattingObject)[]
)[];
export type KLELayoutDefinition = (KLEMeta | (string | KLEElem)[])[];

export type KLELayout = (KLEMeta | KLEElem[])[];

Expand Down
192 changes: 192 additions & 0 deletions test/data/v2_invalid_label_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"name": "wilba.tech WT60-B",
"vendorId": "0x6582",
"productId": "0x60b0",
"lighting": "wt_rgb_backlight",
"matrix": {"rows": 5, "cols": 14},
"layouts": {
"labels": [
["Bottom Row", "HHKB", "Full"]
],
"keymap": [
[
{
"c": "#cccccc",
"w": 1.5,
"d": true,
"w2": 1.5,
"h2": 1,
"x2": -0.25,
"r": 0,
"rx": 1,
"ry": 2,
"x": 10,
"y": 15,
"y2": 1,
"h": 10,
"a": 1
},
"0,0",
{
"c": "#cccccc"
},
"0,1",
"0,2",
"0,3",
"0,4",
"0,5",
"0,6",
"0,7",
"0,8",
"0,9",
"0,10",
"0,11",
"0,12",
"0,13",
"2,13"
],
[
{
"c": "#aaaaaa",
"w": 1.5
},
"1,0",
{
"c": "#cccccc"
},
"1,1",
"1,2",
"1,3",
"1,4",
"1,5",
"1,6",
"1,7",
"1,8",
"1,9",
"1,10",
"1,11",
"1,12",
{
"c": "#aaaaaa",
"w": 1.5
},
"1,13"
],
[
{
"w": 1.75
},
"2,0",
{
"c": "#cccccc"
},
"2,1",
"2,2",
"2,3",
"2,4",
"2,5",
"2,6",
"2,7",
"2,8",
"2,9",
"2,10",
"2,11",
{
"c": "#888888",
"w": 2.25
},
"2,12"
],
[
{
"c": "#aaaaaa",
"w": 2.25
},
"3,0",
{
"c": "#cccccc"
},
"3,2",
"3,3",
"3,4",
"3,5",
"3,6",
"3,7",
"3,8",
"3,9",
"3,10",
"3,11",
{
"c": "#aaaaaa",
"w": 1.75
},
"3,12",
"3,13"
],
[
{
"c": "#cccccc",
"w": 1.5,
"d": true,
"w2": 1.5,
"h2": 1,
"x2": -0.25
},
"\n\n\n0,0",
{
"c": "#aaaaaa"
},
"4,1\n\n\n0,0",
{
"w": 1.5
},
"4,2\n\n\n0,0",
{
"c": "#cccccc",
"w": 7
},
"4,7\n\n\n0,0",
{
"c": "#aaaaaa",
"w": 1.5
},
"4,11\n\n\n0,0",
"4,12\n\n\n0,0",
{
"c": "#cccccc",
"w": 1.5,
"d": true
},
"\n\n\n0,0"
],
[
{
"y": 0.25,
"c": "#aaaaaa",
"w": 1.5
},
"4,0\n\n\n0,1",
"4,1\n\n\n0,1",
{
"w": 1.5
},
"4,2\n\n\n0,1",
{
"c": "#cccccc",
"w": 7
},
"4,7\n\n\n0,1",
{
"c": "#aaaaaa",
"w": 1.5
},
"4,11\n\n\n0,1",
"4,12\n\n\n0,1",
{
"w": 1.5
},
"4,13\n\n\n0,1"
]
]
}
}
20 changes: 18 additions & 2 deletions test/data/v2_valid_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@
"keymap": [
[
{
"c": "#888888"
"c": "#cccccc",
"w": 1.5,
"d": true,
"w2": 1.5,
"h2": 1,
"x2": -0.25,
"r": 0,
"rx": 1,
"ry": 2,
"x": 10,
"y": 15,
"y2": 1,
"h": 10,
"a": 0
},
"0,0",
{
Expand Down Expand Up @@ -114,7 +127,10 @@
{
"c": "#cccccc",
"w": 1.5,
"d": true
"d": true,
"w2": 1.5,
"h2": 1,
"x2": -0.25
},
"\n\n\n0,0",
{
Expand Down
Loading

0 comments on commit d91b2ca

Please sign in to comment.