* feat: Start work on package api * feat: Browser Context Controller * feat: Add packages to cluster metadata feat: Change structure of Package * 🐛 fix: format * 🔨 feat: Add more functions wrapping around Modrinth * 🔨 feat: Start working on browser frontend * feat: BrowserPackage work + markdown support * 🐛 fix: fmt Signed-off-by: Pauline <git@ethanlibs.co> * 🚧 wip: h Signed-off-by: Pauline <git@ethanlibs.co> * feat: Download button for packages for suitable clusters + tweaks * 🚧 wip: markdown and stuff Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: some patches Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: remove react bloat Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore(pkg/infer): try to reduce reused code Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: bump deps Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: markdown innerhtml Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: h Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: tweak Signed-off-by: Pauline <git@ethanlibs.co> * 🚧 wip: idk Signed-off-by: Pauline <git@ethanlibs.co> * fix: Gamemode compile error chore: Add missing and remove unused libraries feat: usePreventLeave hook feat: ClusterOverview edit mode continues with navigation (assuming there was a navigation attempt) after pressing Yes or No for save * feat: Add reload clusters button on home page * feat: More information provided to BrowserPackage * fix: Minor fixes (Navbar isActive, Markdown click prevention, Markdown list styling) * 🐛 fix: h Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: highlighting Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: forge modern Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: bump deps Signed-off-by: Pauline <git@ethanlibs.co> * fix: Markdown-it issue + Added promptOpener hook for Markdown links * feat: Made BrowserPackage sidebar sticky * refactor: Package system (not yet in a working state) * 🚧 wip: bump deps temp Signed-off-by: Pauline <git@ethanlibs.co> * feat: Added a package manager * ✨ feature: start prisma work, but it doesnt break anything so we can keep it until its done. also fix some stuff Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: pushing Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: linting Signed-off-by: Pauline <git@ethanlibs.co> * ✨ feature: start ingress integration Signed-off-by: Pauline <git@ethanlibs.co> * feat: Package Manager should work now 👍 * fix: Package manager tracing spam * feat: Added tauri commands for cluster packages format: Auto formatted frontend + backend * 🐛 fix: tmp Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: format Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: specta extension Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: github actions Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: alias Signed-off-by: Pauline <git@ethanlibs.co> * chore: Some tweaks and fixes * chore: Rebase + gitignore bindings.ts * chore: Remove bindings.ts * 🐛 fix: migrate Signed-off-by: Pauline <git@ethanlibs.co> * 🚧 wip: not sure Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: finalize prisma init schema Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: format Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: bump deps Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: system deps Signed-off-by: Pauline <git@ethanlibs.co> * fix: solid-router navigation issue * feat: Added new BrowserMain page * feat: Tweaks + new package list view * 🐛 fix: bump + format (todo: tauri2, etc) Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: devx (fixes #126) Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: migrate to consola Signed-off-by: Pauline <git@ethanlibs.co> --------- Signed-off-by: Pauline <git@ethanlibs.co> Co-authored-by: LynithDev <61880709+LynithDev@users.noreply.github.com>
102 lines
2.5 KiB
Rust
102 lines
2.5 KiB
Rust
use onelauncher::State;
|
|
use serde::{Serialize, Serializer};
|
|
use tauri::plugin::TauriPlugin;
|
|
use tauri::Manager;
|
|
use tokio::sync::Mutex;
|
|
|
|
pub mod commands;
|
|
pub mod events;
|
|
pub mod statics;
|
|
|
|
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
|
tauri::plugin::Builder::new("onelauncher")
|
|
.setup(|app, _| {
|
|
app.manage(Mutex::new(State::get()));
|
|
|
|
Ok(())
|
|
})
|
|
.build()
|
|
}
|
|
|
|
// TODO: fix the error system/rspc
|
|
pub type Result<T> = std::result::Result<T, OneLauncherSerializableError>;
|
|
|
|
#[derive(thiserror::Error, Debug, Serialize, specta::Type)]
|
|
pub enum OneLauncherSerializableError {
|
|
#[error("{0}")]
|
|
CommonError(String),
|
|
}
|
|
|
|
impl From<OneLauncherError> for OneLauncherSerializableError {
|
|
fn from(value: OneLauncherError) -> Self {
|
|
Self::CommonError(value.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<onelauncher::Error> for OneLauncherSerializableError {
|
|
fn from(value: onelauncher::Error) -> Self {
|
|
Self::CommonError(value.to_string())
|
|
}
|
|
}
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub enum OneLauncherError {
|
|
#[error("{0}")]
|
|
OneLauncher(#[from] onelauncher::Error),
|
|
|
|
#[error("failed to handle io management: {0}")]
|
|
IO(#[from] std::io::Error),
|
|
|
|
#[error("failed to handle tauri management: {0}")]
|
|
Tauri(#[from] tauri::Error),
|
|
|
|
#[cfg(target_os = "macos")]
|
|
#[error("failed to handle callback: {0}")]
|
|
Callback(String),
|
|
}
|
|
|
|
// serialization code from https://github.com/modrinth/theseus/blob/master/theseus_gui/src-tauri/src/api/mod.rs
|
|
// (yoinked under MIT license)
|
|
macro_rules! impl_serialize_err {
|
|
($($variant:ident),* $(,)?) => {
|
|
impl Serialize for OneLauncherError {
|
|
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
|
where
|
|
S: Serializer,
|
|
{
|
|
use serde::ser::SerializeStruct;
|
|
match self {
|
|
OneLauncherError::OneLauncher(onelauncher_error) => {
|
|
$crate::error::display_tracing_error(onelauncher_error);
|
|
|
|
let mut state = serializer.serialize_struct("OneLauncher", 2)?;
|
|
state.serialize_field("field_name", "OneLauncher")?;
|
|
state.serialize_field("message", &onelauncher_error.to_string())?;
|
|
state.end()
|
|
}
|
|
$(
|
|
OneLauncherError::$variant(message) => {
|
|
let mut state = serializer.serialize_struct(stringify!($variant), 2)?;
|
|
state.serialize_field("field_name", stringify!($variant))?;
|
|
state.serialize_field("message", &message.to_string())?;
|
|
state.end()
|
|
},
|
|
)*
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
impl_serialize_err! {
|
|
IO,
|
|
Tauri,
|
|
Callback
|
|
}
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
impl_serialize_err! {
|
|
IO,
|
|
Tauri,
|
|
}
|