Implement Commanding (#6)

Reviewed-on: #6
Co-authored-by: Sergey Savelyev <sergeysav.nn@gmail.com>
Co-committed-by: Sergey Savelyev <sergeysav.nn@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
2025-12-28 13:39:12 -08:00
committed by sergeysav
parent 8cfaf468e9
commit f658b55586
33 changed files with 1389 additions and 98 deletions

View File

@@ -1,3 +1,29 @@
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 }
@@ -6,6 +32,17 @@ export type DynamicComponentData =
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 =