Reviewed-on: #6 Co-authored-by: Sergey Savelyev <sergeysav.nn@gmail.com> Co-committed-by: Sergey Savelyev <sergeysav.nn@gmail.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
export const NumericTypes = ['Float32', 'Float64'] as const;
|
|
export type NumericTypeId = (typeof NumericTypes)[number];
|
|
export const BooleanTypes = ['Boolean'] as const;
|
|
export type BooleanTypeId = (typeof BooleanTypes)[number];
|
|
export const AnyTypes = [...NumericTypes, ...BooleanTypes] as const;
|
|
export type AnyTypeId = (typeof AnyTypes)[number];
|
|
|
|
export function isNumericType(type: AnyTypeId): type is NumericTypeId {
|
|
return NumericTypes.some((it) => it == type);
|
|
}
|
|
export function isBooleanType(type: AnyTypeId): type is BooleanTypeId {
|
|
return BooleanTypes.some((it) => it == type);
|
|
}
|
|
|
|
export type DynamicDataType = number | boolean;
|
|
|
|
export type CommandParameterData =
|
|
| {
|
|
type: 'constant';
|
|
value: DynamicDataType;
|
|
}
|
|
| {
|
|
type: 'input';
|
|
id: string;
|
|
};
|
|
|
|
export type DynamicComponentData =
|
|
| { type: 'text'; text: string; justify_right: boolean }
|
|
| { type: 'telemetry'; data: string }
|
|
| {
|
|
type: 'grid';
|
|
columns: number;
|
|
equal_width: boolean;
|
|
cells: OptionalDynamicComponentData[][];
|
|
}
|
|
| {
|
|
type: 'input';
|
|
id: string;
|
|
data_type: AnyTypeId;
|
|
}
|
|
| {
|
|
type: 'command_button';
|
|
text: string;
|
|
command_name: string;
|
|
parameters: { [key: string]: CommandParameterData };
|
|
};
|
|
|
|
export type OptionalDynamicComponentData =
|
|
| { type: 'none' }
|
|
| DynamicComponentData;
|