Skip to content

Commit c0b0946

Browse files
committed
feat(app): skin selector backend
1 parent 134317d commit c0b0946

26 files changed

+1416
-37
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/app/build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ fn main() {
9999
DefaultPermissionRule::AllowAllCommands,
100100
),
101101
)
102+
.plugin(
103+
"minecraft-skins",
104+
InlinedPlugin::new()
105+
.commands(&[
106+
"get_available_capes",
107+
"get_available_skins",
108+
"add_and_equip_custom_skin",
109+
"set_default_cape",
110+
"equip_skin",
111+
"remove_custom_skin",
112+
"unequip_skin",
113+
])
114+
.default_permission(
115+
DefaultPermissionRule::AllowAllCommands,
116+
),
117+
)
102118
.plugin(
103119
"mr-auth",
104120
InlinedPlugin::new()

apps/app/capabilities/plugins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"jre:default",
2626
"logs:default",
2727
"metadata:default",
28+
"minecraft-skins:default",
2829
"mr-auth:default",
2930
"profile-create:default",
3031
"pack:default",

apps/app/src/api/minecraft_skins.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
use crate::api::Result;
2+
3+
use theseus::minecraft_skins::{self, Bytes, Cape, MinecraftSkinVariant, Skin};
4+
5+
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
6+
tauri::plugin::Builder::new("minecraft-skins")
7+
.invoke_handler(tauri::generate_handler![
8+
get_available_capes,
9+
get_available_skins,
10+
add_and_equip_custom_skin,
11+
set_default_cape,
12+
equip_skin,
13+
remove_custom_skin,
14+
unequip_skin,
15+
])
16+
.build()
17+
}
18+
19+
/// `invoke('plugin:minecraft-skins|get_available_capes')`
20+
///
21+
/// See also: [minecraft_skins::get_available_capes]
22+
#[tauri::command]
23+
pub async fn get_available_capes() -> Result<Vec<Cape>> {
24+
Ok(minecraft_skins::get_available_capes().await?)
25+
}
26+
27+
/// `invoke('plugin:minecraft-skins|get_available_skins')`
28+
///
29+
/// See also: [minecraft_skins::get_available_skins]
30+
#[tauri::command]
31+
pub async fn get_available_skins() -> Result<Vec<Skin>> {
32+
Ok(minecraft_skins::get_available_skins().await?)
33+
}
34+
35+
/// `invoke('plugin:minecraft-skins|add_and_equip_custom_skin', texture_blob, variant, cape_override)`
36+
///
37+
/// See also: [minecraft_skins::add_and_equip_custom_skin]
38+
#[tauri::command]
39+
pub async fn add_and_equip_custom_skin(
40+
texture_blob: Bytes,
41+
variant: MinecraftSkinVariant,
42+
cape_override: Option<Cape>,
43+
) -> Result<()> {
44+
Ok(minecraft_skins::add_and_equip_custom_skin(
45+
texture_blob,
46+
variant,
47+
cape_override,
48+
)
49+
.await?)
50+
}
51+
52+
/// `invoke('plugin:minecraft-skins|set_default_cape', cape)`
53+
///
54+
/// See also: [minecraft_skins::set_default_cape]
55+
#[tauri::command]
56+
pub async fn set_default_cape(cape: Option<Cape>) -> Result<()> {
57+
Ok(minecraft_skins::set_default_cape(cape).await?)
58+
}
59+
60+
/// `invoke('plugin:minecraft-skins|equip_skin', skin)`
61+
///
62+
/// See also: [minecraft_skins::equip_skin]
63+
#[tauri::command]
64+
pub async fn equip_skin(skin: Skin) -> Result<()> {
65+
Ok(minecraft_skins::equip_skin(skin).await?)
66+
}
67+
68+
/// `invoke('plugin:minecraft-skins|remove_custom_skin', skin)`
69+
///
70+
/// See also: [minecraft_skins::remove_custom_skin]
71+
#[tauri::command]
72+
pub async fn remove_custom_skin(skin: Skin) -> Result<()> {
73+
Ok(minecraft_skins::remove_custom_skin(skin).await?)
74+
}
75+
76+
/// `invoke('plugin:minecraft-skins|unequip_skin')`
77+
///
78+
/// See also: [minecraft_skins::unequip_skin]
79+
#[tauri::command]
80+
pub async fn unequip_skin() -> Result<()> {
81+
Ok(minecraft_skins::unequip_skin().await?)
82+
}

apps/app/src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub mod import;
77
pub mod jre;
88
pub mod logs;
99
pub mod metadata;
10+
pub mod minecraft_skins;
1011
pub mod mr_auth;
1112
pub mod pack;
1213
pub mod process;

apps/app/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ fn main() {
258258
.plugin(api::logs::init())
259259
.plugin(api::jre::init())
260260
.plugin(api::metadata::init())
261+
.plugin(api::minecraft_skins::init())
261262
.plugin(api::pack::init())
262263
.plugin(api::process::init())
263264
.plugin(api::profile::init())

apps/app/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"default-src": "'self' customprotocol: asset:",
8585
"connect-src": "ipc: http://ipc.localhost https://modrinth.com https://*.modrinth.com https://*.posthog.com https://*.sentry.io https://api.mclo.gs",
8686
"font-src": ["https://cdn-raw.modrinth.com/fonts/inter/"],
87-
"img-src": "https: 'unsafe-inline' 'self' asset: http://asset.localhost blob: data:",
87+
"img-src": "https: 'unsafe-inline' 'self' asset: http://asset.localhost https://textures.minecraft.net blob: data:",
8888
"style-src": "'unsafe-inline' 'self'",
8989
"script-src": "https://*.posthog.com 'self'",
9090
"frame-src": "https://www.youtube.com https://www.youtube-nocookie.com https://discord.com 'self'"

packages/app-lib/.sqlx/query-1937e191a7815a55274bb39a035e02a39bb04b45dbd727e5db5b5308deda4e04.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-27a4ca00ab9d1647bf63287169f6dd3eed86ba421c83e74fe284609a8020bd22.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-3d15e7eb66971e70500e8718236fbdbd066d51f88cd2bcfed613f756edbd2944.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-3f3d3c2d77c1bcaf4044b612c3822546583aa19ea7088682d718c64ed5d5f1c5.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-545b01d8cc1e79ff5d4136887fbb712aba58908a66dd7bbd64c293b9ee7a1523.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-957f184e28e4921ff3922f3e74aae58e2d7a414e76906700518806e494cd0246.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-9c2522e4518067192539ad270253ae1b3d75e80e52529e491e86ff370d6424b3.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/.sqlx/query-aae88809ada53e13441352e315f68169cfd8226b57bacd8c270d7777fc6883ac.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-lib/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ sys-info = "0.9.0"
2828
sysinfo = "0.30.8"
2929
thiserror = "1.0"
3030
either = "1.13"
31+
data-url = "0.3.1"
3132

3233
tracing = "0.1.37"
3334
tracing-subscriber = { version = "0.3.18", features = ["chrono", "env-filter"] }
@@ -41,7 +42,7 @@ indicatif = { version = "0.17.3", optional = true }
4142

4243
async-tungstenite = { version = "0.27.0", features = ["tokio-runtime", "tokio-rustls-webpki-roots"] }
4344
futures = "0.3"
44-
reqwest = { version = "0.12.3", features = ["json", "stream", "deflate", "gzip", "brotli", "rustls-tls", "charset", "http2", "macos-system-configuration"], default-features = false }
45+
reqwest = { version = "0.12.3", features = ["json", "stream", "deflate", "gzip", "brotli", "rustls-tls", "charset", "http2", "macos-system-configuration", "multipart"], default-features = false }
4546
tokio = { version = "1", features = ["full"] }
4647
async-recursion = "1.0.4"
4748

@@ -60,7 +61,7 @@ rand = "0.8"
6061
byteorder = "1.5.0"
6162
base64 = "0.22.0"
6263

63-
sqlx = { version = "0.8.2", features = [ "runtime-tokio", "sqlite", "macros" ] }
64+
sqlx = { version = "0.8.2", features = [ "runtime-tokio", "sqlite", "macros", "uuid" ] }
6465

6566
ariadne = { path = "../ariadne" }
6667

0 commit comments

Comments
 (0)