mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 22:58:44 +00:00
feat: fetch plugins manifests online
This commit is contained in:
parent
aa9bd09372
commit
69eba0153b
2 changed files with 56 additions and 32 deletions
|
@ -3,7 +3,11 @@ pub mod store;
|
||||||
mod store_detail;
|
mod store_detail;
|
||||||
mod store_row_factory;
|
mod store_row_factory;
|
||||||
|
|
||||||
use crate::{paths::get_plugins_dir, util::file_utils::mark_as_executable};
|
use crate::{
|
||||||
|
downloader::{cache_file_path, download_file_async},
|
||||||
|
paths::get_plugins_dir,
|
||||||
|
util::file_utils::mark_as_executable,
|
||||||
|
};
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -61,3 +65,29 @@ impl Plugin {
|
||||||
&& self.executable().as_ref().is_some_and(|p| p.is_file())
|
&& self.executable().as_ref().is_some_and(|p| p.is_file())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// urls to manifest json files representing plugins.
|
||||||
|
/// each manifest should be json and the link should always point to the latest version
|
||||||
|
const MANIFESTS: [&str;2] = [
|
||||||
|
"https://gitlab.com/gabmus/envision-plugin-manifests/-/raw/main/com.github.galiser.wlx-overlay-s.json",
|
||||||
|
"https://gitlab.com/gabmus/envision-plugin-manifests/-/raw/main/org.stardustxr.telescope.json",
|
||||||
|
];
|
||||||
|
|
||||||
|
pub async fn refresh_plugins() -> anyhow::Result<Vec<anyhow::Result<Plugin>>> {
|
||||||
|
let mut results = Vec::new();
|
||||||
|
for jh in MANIFESTS
|
||||||
|
.iter()
|
||||||
|
.map(|url| -> tokio::task::JoinHandle<anyhow::Result<Plugin>> {
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let path = cache_file_path(url, Some("json"));
|
||||||
|
download_file_async(url, &path).await?;
|
||||||
|
Ok(serde_json::from_str::<Plugin>(
|
||||||
|
&tokio::fs::read_to_string(path).await?,
|
||||||
|
)?)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
{
|
||||||
|
results.push(jh.await?);
|
||||||
|
}
|
||||||
|
Ok(results)
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ use super::{
|
||||||
add_custom_plugin_win::{
|
add_custom_plugin_win::{
|
||||||
AddCustomPluginWin, AddCustomPluginWinInit, AddCustomPluginWinMsg, AddCustomPluginWinOutMsg,
|
AddCustomPluginWin, AddCustomPluginWinInit, AddCustomPluginWinMsg, AddCustomPluginWinOutMsg,
|
||||||
},
|
},
|
||||||
|
refresh_plugins,
|
||||||
store_detail::{StoreDetail, StoreDetailMsg, StoreDetailOutMsg},
|
store_detail::{StoreDetail, StoreDetailMsg, StoreDetailOutMsg},
|
||||||
store_row_factory::{StoreRowModel, StoreRowModelInit, StoreRowModelMsg, StoreRowModelOutMsg},
|
store_row_factory::{StoreRowModel, StoreRowModelInit, StoreRowModelMsg, StoreRowModelOutMsg},
|
||||||
Plugin,
|
Plugin,
|
||||||
|
@ -44,7 +45,10 @@ pub enum PluginStoreSignalSource {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PluginStoreMsg {
|
pub enum PluginStoreMsg {
|
||||||
Present,
|
Present,
|
||||||
|
/// sets state and calls DoRefresh
|
||||||
Refresh,
|
Refresh,
|
||||||
|
/// called by Refresh
|
||||||
|
DoRefresh,
|
||||||
Install(Plugin, relm4::Sender<StoreRowModelMsg>),
|
Install(Plugin, relm4::Sender<StoreRowModelMsg>),
|
||||||
InstallFromDetails(Plugin),
|
InstallFromDetails(Plugin),
|
||||||
InstallDownload(Plugin, relm4::Sender<StoreRowModelMsg>),
|
InstallDownload(Plugin, relm4::Sender<StoreRowModelMsg>),
|
||||||
|
@ -158,6 +162,8 @@ impl AsyncComponent for PluginStore {
|
||||||
add_child = >k::Spinner {
|
add_child = >k::Spinner {
|
||||||
set_hexpand: true,
|
set_hexpand: true,
|
||||||
set_vexpand: true,
|
set_vexpand: true,
|
||||||
|
set_width_request: 32,
|
||||||
|
set_height_request: 32,
|
||||||
set_valign: gtk::Align::Center,
|
set_valign: gtk::Align::Center,
|
||||||
set_halign: gtk::Align::Center,
|
set_halign: gtk::Align::Center,
|
||||||
#[track = "model.changed(PluginStore::refreshing())"]
|
#[track = "model.changed(PluginStore::refreshing())"]
|
||||||
|
@ -248,37 +254,25 @@ impl AsyncComponent for PluginStore {
|
||||||
}
|
}
|
||||||
Self::Input::Refresh => {
|
Self::Input::Refresh => {
|
||||||
self.set_refreshing(true);
|
self.set_refreshing(true);
|
||||||
// TODO: populate from web
|
sender.input(Self::Input::DoRefresh);
|
||||||
let mut plugins = vec![
|
}
|
||||||
Plugin {
|
Self::Input::DoRefresh => {
|
||||||
appid: "com.github.galiser.wlx-overlay-s".into(),
|
let mut plugins = match refresh_plugins().await {
|
||||||
name: "WLX Overlay S".into(),
|
Err(e) => {
|
||||||
version: Some("0.6.0".into()),
|
error!("failed to refresh plugins: {e}");
|
||||||
hompage_url: Some("https://github.com/galister/wlx-overlay-s".into()),
|
Vec::new()
|
||||||
icon_url: Some("https://github.com/galister/wlx-overlay-s/raw/main/wlx-overlay-s.svg".into()),
|
}
|
||||||
screenshots: vec![
|
Ok(results) => results
|
||||||
"https://github.com/galister/wlx-overlay-s/raw/guide/wlx-s.png".into(),
|
.into_iter()
|
||||||
],
|
.filter_map(|res| match res {
|
||||||
description: Some("A lightweight OpenXR/OpenVR overlay for Wayland and X11 desktops, inspired by XSOverlay.\n\nWlxOverlay-S allows you to access your desktop screens while in VR.\n\nIn comparison to similar overlays, WlxOverlay-S aims to run alongside VR games and experiences while having as little performance impact as possible. The UI appearance and rendering techniques are kept as simple and efficient as possible, while still allowing a high degree of customizability.".into()),
|
Ok(plugin) => Some(plugin),
|
||||||
short_description: Some("Access your Wayland/X11 desktop".into()),
|
Err(e) => {
|
||||||
exec_url: Some("https://github.com/galister/wlx-overlay-s/releases/download/v0.6/WlxOverlay-S-v0.6-x86_64.AppImage".into()),
|
error!("failed to refresh single plugin manifest: {e}");
|
||||||
exec_path: None,
|
None
|
||||||
},
|
}
|
||||||
Plugin {
|
})
|
||||||
appid: "org.stardustxr.telescope".into(),
|
.collect(),
|
||||||
name: "Telescope (Stardust XR)".into(),
|
};
|
||||||
version: Some("0.45.0".into()),
|
|
||||||
hompage_url: Some("https://stardustxr.org/".into()),
|
|
||||||
icon_url: Some("https://stardustxr.org/img/icon.png".into()),
|
|
||||||
screenshots: vec![
|
|
||||||
"https://stardustxr.org/img/carousel/workflow.png".into(),
|
|
||||||
],
|
|
||||||
description: Some("A more intuitive overlay designed for spatial computing from the ground up. Part of the Stardust XR project.\n\nTelescope lets you use your favorite apps directly with your controllers or hands at any time.".into()),
|
|
||||||
short_description: Some("Use your existing apps spatially and intuitively.".into()),
|
|
||||||
exec_url: Some("https://github.com/StardustXR/telescope/releases/download/0.45.0/Telescope-x86_64.AppImage".into()),
|
|
||||||
exec_path: None,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
{
|
{
|
||||||
let appids_from_web = plugins
|
let appids_from_web = plugins
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue