Skip to content

Commit

Permalink
fix: fixes to typescript bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
FruitieX committed Feb 20, 2025
1 parent aeefe33 commit 50905c9
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sqlx = { version = "=0.8.3", features = [
once_cell = "=1.20.3"
rumqttc = "=0.24.0"
toml = "=0.8.20"
ts-rs = { version = "=10.1.0", features = ["ordered-float-impl", "no-serde-warnings"] }
ts-rs = { version = "=10.1.0", features = ["ordered-float-impl", "no-serde-warnings", "serde-json-impl"] }
macro-attr = "=0.2.0"
newtype_derive = "=0.1.6"
log = "=0.4.25"
Expand Down
4 changes: 0 additions & 4 deletions bindings/DeviceKey.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/types/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,17 @@ impl Capabilities {
#[derive(TS, Clone, Debug, PartialEq, Deserialize, Serialize, Hash, Eq)]
#[ts(export)]
pub struct Xy {
#[ts(type = "number")]
pub x: OrderedFloat<f32>,

#[ts(type = "number")]
pub y: OrderedFloat<f32>,
}

#[derive(TS, Clone, Debug, PartialEq, Deserialize, Serialize, Hash, Eq)]
#[ts(export)]
pub struct Hs {
#[serde(deserialize_with = "as_u64")]
#[ts(type = "number")]
pub h: u64,

#[ts(type = "number")]
pub s: OrderedFloat<f32>,
}

Expand Down
3 changes: 1 addition & 2 deletions src/types/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ pub struct ControllableState {
pub power: bool,

/// Current brightness, if supported
#[ts(type = "number | null")]
pub brightness: Option<OrderedFloat<f32>>,

/// Current color, if supported
pub color: Option<DeviceColor>,

/// Transition time in seconds
#[ts(type = "number")]
pub transition: Option<OrderedFloat<f32>>,
}

Expand Down Expand Up @@ -677,6 +675,7 @@ impl From<&DeviceKey> for DeviceRef {

/// A reference to a device, always by id, serializes to `integration_id/device_id`
#[derive(TS, Hash, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)]
#[ts(type = "string")]
pub struct DeviceKey {
pub integration_id: IntegrationId,
pub device_id: DeviceId,
Expand Down
3 changes: 0 additions & 3 deletions src/types/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ impl std::str::FromStr for SceneId {
#[derive(TS, Clone, Deserialize, Debug, Serialize, Eq, PartialEq, Hash)]
#[ts(export)]
pub struct SceneDeviceLink {
#[ts(type = "number | null")]
pub brightness: Option<OrderedFloat<f32>>, // allow overriding brightness

#[serde(flatten)]
Expand Down Expand Up @@ -70,9 +69,7 @@ pub struct CycleScenesDescriptor {
pub struct SceneDeviceState {
pub power: Option<bool>,
pub color: Option<DeviceColor>,
#[ts(type = "number | null")]
pub brightness: Option<OrderedFloat<f32>>,
#[ts(type = "number | null")]
pub transition: Option<OrderedFloat<f32>>,
}

Expand Down
1 change: 0 additions & 1 deletion src/types/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use ts_rs::TS;
pub enum UiActionDescriptor {
StoreUIState {
key: String,
#[ts(type = "any")]
value: serde_json::Value,
},
}
1 change: 0 additions & 1 deletion src/types/websockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub struct StateUpdate {
pub devices: DevicesState,
pub scenes: FlattenedScenesConfig,
pub groups: FlattenedGroupsConfig,
#[ts(type = "Record<String, any>")]
pub ui_state: HashMap<String, serde_json::Value>,
}

Expand Down

0 comments on commit 50905c9

Please sign in to comment.