1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4pub type PluginId = String;
5pub type ActionId = String;
6
7pub type ProfileId = Uuid;
8pub type FolderId = Uuid;
9pub type DeviceId = Uuid;
10pub type TileId = Uuid;
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct InspectorContext {
14 pub profile_id: ProfileId,
15 pub folder_id: FolderId,
16
17 pub plugin_id: PluginId,
18 pub action_id: ActionId,
19
20 pub tile_id: TileId,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct TileInteractionContext {
25 pub device_id: DeviceId,
26
27 pub plugin_id: PluginId,
28 pub action_id: ActionId,
29
30 pub tile_id: TileId,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct DeepLinkContext {
35 pub url: String,
36 pub host: Option<String>,
37 pub path: String,
38 pub query: Option<String>,
39 pub fragment: Option<String>,
40}
41
42#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
43#[serde(tag = "type")]
44pub enum TileIcon {
45 #[default]
47 None,
48
49 PluginIcon {
51 plugin_id: PluginId,
53 icon: String,
55 },
56
57 IconPack {
59 pack_id: String,
61 path: String,
63 },
64
65 Url {
67 src: String,
68 },
69}
70
71#[derive(Default, Debug, Clone, Serialize, Deserialize)]
72#[serde(default)]
73pub struct TileLabel {
74 pub enabled: Option<bool>,
75 pub label: Option<String>,
76 pub align: Option<LabelAlign>,
77
78 pub font: Option<String>,
79 pub font_size: Option<u32>,
80
81 pub bold: Option<bool>,
82 pub italic: Option<bool>,
83 pub underline: Option<bool>,
84 pub outline: Option<bool>,
85
86 pub color: Option<String>,
87 pub outline_color: Option<String>,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize, Default)]
91pub enum LabelAlign {
92 #[default]
93 Bottom,
94 Middle,
95 Top,
96}
97
98#[derive(Debug, Serialize)]
100#[serde(tag = "type")]
101pub(crate) enum ClientPluginMessage {
102 RegisterPlugin { plugin_id: PluginId },
104
105 GetProperties,
107
108 SetProperties {
110 properties: serde_json::Value,
111
112 partial: bool,
114 },
115
116 SendToInspector {
118 ctx: InspectorContext,
120 message: serde_json::Value,
122 },
123
124 OpenUrl { url: String },
126
127 GetTileProperties {
129 tile_id: TileId,
131 },
132
133 SetTileProperties {
135 tile_id: TileId,
137 properties: serde_json::Value,
139 partial: bool,
141 },
142
143 SetTileIcon { tile_id: TileId, icon: TileIcon },
145
146 SetTileLabel { tile_id: TileId, label: TileLabel },
148}
149
150#[derive(Debug, Clone, Deserialize)]
152#[serde(tag = "type")]
153pub(crate) enum ServerPluginMessage {
154 Registered {
156 #[allow(unused)]
157 plugin_id: PluginId,
158 },
159
160 Properties { properties: serde_json::Value },
162
163 TileClicked {
165 ctx: TileInteractionContext,
166 properties: serde_json::Value,
167 },
168
169 RecvFromInspector {
171 ctx: InspectorContext,
172 message: serde_json::Value,
173 },
174
175 InspectorOpen { ctx: InspectorContext },
177
178 InspectorClose { ctx: InspectorContext },
180
181 DeepLink { ctx: DeepLinkContext },
183
184 TileProperties {
186 tile_id: TileId,
187 properties: serde_json::Value,
188 },
189}