diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 8e12dbf..b8d52cb 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + [[package]] name = "adler" version = "1.0.2" @@ -747,6 +753,15 @@ dependencies = [ "quick-error", ] +[[package]] +name = "document-features" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e493c573fce17f00dcab13b6ac057994f3ce17d1af4dc39bfd482b83c6eb6157" +dependencies = [ + "litrs", +] + [[package]] name = "dtoa" version = "1.0.6" @@ -768,6 +783,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + [[package]] name = "embed-resource" version = "2.1.1" @@ -1485,8 +1506,10 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "specta", "tauri", "tauri-build", + "tauri-specta", "thiserror", "tokio", ] @@ -1624,6 +1647,18 @@ dependencies = [ "serde", ] +[[package]] +name = "indoc" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" + +[[package]] +name = "indoc" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f2cb48b81b1dc9f39676bf99f5499babfec7cd8fe14307f7b3d747208fb5690" + [[package]] name = "infer" version = "0.12.0" @@ -1671,6 +1706,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -1795,6 +1839,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "litrs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa" + [[package]] name = "lock_api" version = "0.4.10" @@ -3027,6 +3077,37 @@ dependencies = [ "system-deps 5.0.0", ] +[[package]] +name = "specta" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7230ab99f7b726fa49e350886816dbe5b5b151a5f4158470f92850246d5cae5e" +dependencies = [ + "document-features", + "indoc 1.0.9", + "once_cell", + "paste", + "serde", + "serde_json", + "specta-macros", + "tauri", + "thiserror", +] + +[[package]] +name = "specta-macros" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6252ed50d005e1dc2b77ed140f1c230299e0566492470eba40ba34e18cbcfa10" +dependencies = [ + "Inflector", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", + "termcolor", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3354,6 +3435,21 @@ dependencies = [ "wry", ] +[[package]] +name = "tauri-specta" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa034c38b7bdfeccc606eca0b030a1e67a20b78e7642edef09816b7e1ff9a9de" +dependencies = [ + "heck 0.4.1", + "indoc 2.0.1", + "serde", + "serde_json", + "specta", + "tauri", + "thiserror", +] + [[package]] name = "tauri-utils" version = "1.4.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 95f3523..e7222ec 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -34,6 +34,8 @@ reqwest = { version = "0.11.18", features = ["json"] } paste = "1.0.12" serde_derive = "1.0.164" thiserror = "1.0.40" +specta = "1.0.4" +tauri-specta = { version = "1.0.2", features = ["javascript", "typescript"] } [features] # this feature is used for production builds or when `devPath` points to the filesystem diff --git a/src-tauri/core/macros.rs b/src-tauri/core/macros.rs index ccead47..f18c7ba 100644 --- a/src-tauri/core/macros.rs +++ b/src-tauri/core/macros.rs @@ -20,6 +20,7 @@ macro_rules! endpoint { } #[tauri::command] + #[specta::specta] pub async fn [<$method:lower _ $endpointname>]($(body: $body, )? $($($param: String),+,)? state: tauri::State<'_, crate::HueHueHueState>) -> Result<$returntype, crate::HueHueHueError> { let huehuehue = state.0.lock().await; crate::HueHueHue::[<$method:lower _ $endpointname>](&huehuehue $(,body as $body)? $(,$($param)+)?).await @@ -84,6 +85,13 @@ macro_rules! patch { macro_rules! handlers { ($($handler:ident),*) => { + #[macro_export] + macro_rules! bindings { + ($path:expr) => { + #[cfg(debug_assertions)] + tauri_specta::ts::export(specta::collect_types![$($handler,)*], $path).unwrap(); + }; + } #[macro_export] macro_rules! huehuehue_handlers { ($app:expr) => { diff --git a/src-tauri/core/transfer.rs b/src-tauri/core/transfer.rs index 73259b4..bf86737 100644 --- a/src-tauri/core/transfer.rs +++ b/src-tauri/core/transfer.rs @@ -3,15 +3,16 @@ use core::fmt::Debug; use paste::paste; use serde::{Deserialize, Serialize}; +use specta::Type; -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Error { description: String, } pub trait HueV2Res: Debug {} -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ResourceApi { errors: Vec, data: Vec, @@ -27,7 +28,7 @@ macro_rules! hue_v2_res { }; } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2ResourceType { Device, @@ -63,7 +64,7 @@ pub enum HueV2ResourceType { SmartScene, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Resource { id: String, r#type: HueV2ResourceType, @@ -71,7 +72,7 @@ pub struct HueV2Resource { } hue_v2_res!(HueV2Resource); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2ProductArchetype { BridgeV2, @@ -126,7 +127,7 @@ pub enum HueV2ProductArchetype { CeilingTube, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2DeviceProductData { model_id: String, manufacturer_name: String, @@ -137,19 +138,19 @@ pub struct HueV2DeviceProductData { hardware_platform_type: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2DeviceMetadata { name: String, archetype: HueV2ProductArchetype, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ResourceIdentifier { rid: String, rtype: HueV2ResourceType, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Device { id: String, r#type: HueV2ResourceType, @@ -160,7 +161,7 @@ pub struct HueV2Device { } hue_v2_res!(HueV2Device); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2BridgeHome { id: String, r#type: HueV2ResourceType, @@ -170,7 +171,7 @@ pub struct HueV2BridgeHome { } hue_v2_res!(HueV2BridgeHome); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub enum HueV2RoomArchetype { LivingRoom, Kitchen, @@ -214,13 +215,13 @@ pub enum HueV2RoomArchetype { Other, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2RoomMetadata { name: String, archetype: HueV2RoomArchetype, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Room { id: String, r#type: HueV2ResourceType, @@ -231,7 +232,7 @@ pub struct HueV2Room { } hue_v2_res!(HueV2Room); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Zone { id: String, r#type: HueV2ResourceType, @@ -242,7 +243,7 @@ pub struct HueV2Zone { } hue_v2_res!(HueV2Zone); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub enum HueV2LightArchetype { UnknownArchetype, ClassicBulb, @@ -294,57 +295,57 @@ pub enum HueV2LightArchetype { CeilingHorizontal, CeilingTube, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightMetadata { name: String, archetype: HueV2LightArchetype, fixed_mired: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightOn { on: bool, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightDimming { brightness: f64, min_dim_level: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightColorTemperatureMirekSchema { mirek_minimum: u32, mirek_maximum: u32, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightColorTemperature { mirek: u32, mirek_valid: bool, mirek_schema: HueV2LightColorTemperatureMirekSchema, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightColorXY { x: f64, y: f64, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightColorGamutChannel { x: f64, y: f64, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightColorGamut { red: HueV2LightColorGamutChannel, green: HueV2LightColorGamutChannel, blue: HueV2LightColorGamutChannel, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightColorGamutType { A, @@ -353,21 +354,21 @@ pub enum HueV2LightColorGamutType { Other, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightColor { xy: HueV2LightColorXY, gamut: Option, gamut_type: HueV2LightColorGamutType, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightDynamicsStatus { DynamicPalette, None, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightDynamics { status: HueV2LightDynamicsStatus, status_values: Vec, @@ -375,47 +376,47 @@ pub struct HueV2LightDynamics { speed_valid: bool, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightAlert { action_values: Vec, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightSignal { NoSignal, OnOff, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightSignalingStatus { signal: HueV2LightSignal, estimated_end: String, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightSignaling { status: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightMode { Normal, Streaming, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightGradientColor { xy: HueV2LightColorXY, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightGradientPoint { color: HueV2LightGradientColor, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightGradientMode { InterpolatedPalette, @@ -423,7 +424,7 @@ pub enum HueV2LightGradientMode { RandomPixelated, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightGradient { points: Vec, mode: HueV2LightGradientMode, @@ -432,7 +433,7 @@ pub struct HueV2LightGradient { pixel_count: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightEffect { Sparkle, @@ -441,7 +442,7 @@ pub enum HueV2LightEffect { NoEffect, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightEffects { effect: HueV2LightEffect, status_values: Vec, @@ -449,14 +450,14 @@ pub struct HueV2LightEffects { effect_values: Vec, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightTimedEffect { Sunrise, NoEffect, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightTimedEffects { effect: HueV2LightTimedEffect, duration: Option, @@ -465,7 +466,7 @@ pub struct HueV2LightTimedEffects { effect_values: Vec, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightPowerupPreset { Safety, @@ -474,7 +475,7 @@ pub enum HueV2LightPowerupPreset { Custom, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightPowerupOnMode { On, @@ -482,31 +483,31 @@ pub enum HueV2LightPowerupOnMode { Previous, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerupOn { mode: HueV2LightPowerupOnMode, on: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightPowerupDimmingMode { Dimming, Previous, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerupDimmingBrightness { brightness: f64, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerupDimming { mode: HueV2LightPowerupDimmingMode, dimming: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2LightColorTemperatureMode { ColorTemperature, @@ -514,24 +515,24 @@ pub enum HueV2LightColorTemperatureMode { Previous, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerupColorTemperature { mirek: u32, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerupColorColor { xy: HueV2LightColorXY, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerupColor { mode: HueV2LightColorTemperatureMode, color_temperature: Option, color: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightPowerup { preset: HueV2LightPowerupPreset, configured: bool, @@ -540,7 +541,7 @@ pub struct HueV2LightPowerup { color: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Light { id: String, r#type: HueV2ResourceType, @@ -562,12 +563,12 @@ pub struct HueV2Light { } hue_v2_res!(HueV2Light); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ButtonMetadata { control_id: u32, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2ButtonEvent { InitialPress, @@ -578,12 +579,12 @@ pub enum HueV2ButtonEvent { LongPress, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ButtonButton { last_event: HueV2ButtonEvent, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Button { id: String, r#type: HueV2ResourceType, @@ -594,39 +595,39 @@ pub struct HueV2Button { } hue_v2_res!(HueV2Button); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2RelativeRotaryAction { Start, Repeat, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] #[serde(rename_all = "snake_case")] pub enum HueV2RelativeRotaryDirection { ClockWise, CounterClockWise, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2RelativeRotaryRotation { direction: HueV2RelativeRotaryDirection, steps: u32, duration: u32, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2RelativeRotaryEvent { action: HueV2RelativeRotaryAction, rotation: HueV2RelativeRotaryRotation, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2RelativeRotaryInner { last_event: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2RelativeRotary { id: String, r#type: HueV2ResourceType, @@ -636,13 +637,13 @@ pub struct HueV2RelativeRotary { } hue_v2_res!(HueV2RelativeRotary); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2TemperatureInner { temperature: f64, temperature_valid: bool, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Temperature { id: String, r#type: HueV2ResourceType, @@ -653,13 +654,13 @@ pub struct HueV2Temperature { } hue_v2_res!(HueV2Temperature); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightLevelInner { light_level: u32, light_level_valid: bool, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2LightLevel { id: String, r#type: HueV2ResourceType, @@ -670,13 +671,13 @@ pub struct HueV2LightLevel { } hue_v2_res!(HueV2LightLevel); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2MotionInner { motion: bool, motion_valid: bool, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Motion { id: String, r#type: HueV2ResourceType, @@ -687,20 +688,20 @@ pub struct HueV2Motion { } hue_v2_res!(HueV2Motion); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2EntertainmentSegment { start: u32, length: u32, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2EntertainmentSegments { configurable: bool, max_segments: u32, segments: Vec, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Entertainment { id: String, r#type: HueV2ResourceType, @@ -714,22 +715,22 @@ pub struct HueV2Entertainment { } hue_v2_res!(HueV2Entertainment); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2GroupedLightOn { on: bool, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2GroupedLightDimming { dimming: f64, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2GroupedLightAlert { action_values: Vec, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2GroupedLight { id: String, r#type: HueV2ResourceType, @@ -741,20 +742,20 @@ pub struct HueV2GroupedLight { } hue_v2_res!(HueV2GroupedLight); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub enum HueV2DeviceBatteryState { Normal, Low, Critical, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2DevicePowerState { battery_state: Option, battery_level: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2DevicePower { id: String, r#type: HueV2ResourceType, @@ -764,74 +765,74 @@ pub struct HueV2DevicePower { } hue_v2_res!(HueV2DevicePower); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ZigbeeBridgeConnectivity {} hue_v2_res!(HueV2ZigbeeBridgeConnectivity); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ZigbeeConnectivity {} hue_v2_res!(HueV2ZigbeeConnectivity); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ZgpConnectivity {} hue_v2_res!(HueV2ZgpConnectivity); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Bridge {} hue_v2_res!(HueV2Bridge); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2ZigbeeDeviceDiscovery {} hue_v2_res!(HueV2ZigbeeDeviceDiscovery); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Homekit {} hue_v2_res!(HueV2Homekit); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Matter {} hue_v2_res!(HueV2Matter); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2MatterFabric {} hue_v2_res!(HueV2MatterFabric); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Scene {} hue_v2_res!(HueV2Scene); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2EntertainmentConfiguration {} hue_v2_res!(HueV2EntertainmentConfiguration); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2PublicImage {} hue_v2_res!(HueV2PublicImage); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2AuthV1 {} hue_v2_res!(HueV2AuthV1); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2BehaviorScript {} hue_v2_res!(HueV2BehaviorScript); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2BehaviorInstance {} hue_v2_res!(HueV2BehaviorInstance); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Geofence {} hue_v2_res!(HueV2Geofence); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2GeofenceClient {} hue_v2_res!(HueV2GeofenceClient); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2Geolocation {} hue_v2_res!(HueV2Geolocation); -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Type)] pub struct HueV2SmartScene {} hue_v2_res!(HueV2SmartScene); diff --git a/src-tauri/main.rs b/src-tauri/main.rs index e882de4..fc545ef 100644 --- a/src-tauri/main.rs +++ b/src-tauri/main.rs @@ -1,6 +1,7 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +use huehuehue::bindings; use huehuehue::core::endpoints::*; use huehuehue::huehuehue_handlers; use huehuehue::HueHueHue; @@ -19,6 +20,7 @@ pub async fn main() -> Result<(), HueHueHueError> { info!("starting huehuehue..."); let huehuehue: HueHueHue = HueHueHue::default(); huehuehue.discover()?; + bindings!("../src/bindings.ts"); huehuehue_handlers!(tauri::Builder::default()) .manage(HueHueHueState(Mutex::new(huehuehue))) .build(tauri::generate_context!()) diff --git a/src/App.svelte b/src/App.svelte index 853cb19..133683b 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,4 +1,14 @@