forked from the-via/pelpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
59 lines (46 loc) · 1.58 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
export type Label = {
label: string;
};
export type RawExpr = string;
// A property that when present, provides the option of not evaluating the block it represents
export type Conditional = {
showIf?: RawExpr;
};
// A structure that allows a grouping of items, generally useful for conditionally rendering a block of controls
// that share the same render condition
export type Group<A> = Conditional & Content<A[]>;
// VIA Groups
export type SubmenuSlice = Group<ControlItem>;
export type Submenu = Label & Group<VIAItem | SubmenuSlice>;
export type Menu = Label & Group<Submenu>;
// The "parameter" of the render function
export type Content<A> = {
content: A;
};
export type TextContent = Content<string>;
// Specifies the get-set command prefix
// For fetching the current value: <CustomCommand> <BindableContent>
// For setting the current value: <CustomCommand> <BindableContent> <NewValue>
export type BindableContent = Content<CommandDef>;
export type CommandDef = [string, number | number[]];
// An atomic unit that represents a renderable unit - usually a Control
export type Item<A> = Label & Conditional & A;
export type ControlItem = Item<Control & BindableContent>;
export type TextItem = Item<TextContent>;
export type VIAItem = ControlItem | TextItem;
export type Control = Keycode | Color | Toggle | Dropdown;
// VIA Controls
export type Keycode = {
type: "keycode";
};
export type Color = {
type: "color";
};
export type Toggle = {
type: "toggle";
options?: [number, number];
};
export type Dropdown = {
type: "dropdown";
options: (string | [string, number])[];
};