OneLauncher-Cracked/apps/desktop/src/lib.rs
Pauline 28b1f9f0e3
Feature: Package API (#75) (i'm just going to merge this because the other branches are inactive)
* 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>
2024-08-31 16:23:24 -04:00

117 lines
3.3 KiB
Rust

use api::statics::get_program_info;
use tauri::{Emitter, Manager};
pub mod api;
pub mod error;
pub mod ext;
#[derive(Clone, serde::Serialize)]
pub struct SingleInstancePayload {
args: Vec<String>,
cwd: String,
}
#[tracing::instrument(skip_all)]
async fn initialize_state(handle: &tauri::AppHandle) -> api::Result<()> {
onelauncher::ProxyState::initialize(handle).await?;
let s = onelauncher::State::get().await?;
onelauncher::State::update();
s.processor.write().await.restore().await?;
Ok(())
}
/// initializes the logger and runs the app. if the logger fails to initialize
/// we panic because nothing else can be debugged once the logger fails.
/// the only thing that can fail before the logger should be our [`tokio::main`] loop.
pub async fn run() {
let _log_guard = onelauncher::start_logger();
tracing::info!("initialized logger. loading onelauncher/tauri...");
run_app(tauri::Builder::default(), |app| {
if let Err(err) = setup(app) {
tracing::error!("failed to setup app: {:?}", err);
}
})
.await;
}
pub async fn run_app<F: FnOnce(&tauri::AppHandle<tauri::Wry>) + Send + 'static>(
builder: tauri::Builder<tauri::Wry>,
setup: F,
) {
let prebuild = tauri_specta::Builder::<tauri::Wry>::new()
.commands(collect_commands!())
.events(collect_events!())
.constant("PROGRAM_INFO", get_program_info());
#[cfg(debug_assertions)]
prebuild
.export(
specta_typescript::Typescript::default()
.bigint(specta_typescript::BigIntExportBehavior::BigInt)
.formatter(crate::ext::specta::formatter),
"../../packages/client/src/bindings.ts",
)
.expect("failed to export debug bindings!");
let builder = builder
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
println!("{}, {argv:?}, {cwd}", app.package_info().name);
app.emit("single-instance", SingleInstancePayload { args: argv, cwd })
.unwrap();
}))
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(ext::updater::plugin())
.manage(ext::updater::State::default())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_deep_link::init())
// TODO: add back tauri-plugin-window-state -- it's buggy at the moment
// .plugin(tauri_plugin_window_state::Builder::default().build())
.plugin(api::init())
.menu(tauri::menu::Menu::new)
.invoke_handler(prebuild.invoke_handler())
.setup(move |app| {
prebuild.mount_events(app.handle());
setup(app.handle());
Ok(())
});
let app = builder
.build(tauri::generate_context!())
.expect("failed to build tauri application");
if let Err(err) = initialize_state(app.handle()).await {
tracing::error!("{err}");
};
app.run(|_, _| {})
}
fn setup(handle: &tauri::AppHandle) -> Result<(), Box<dyn std::error::Error>> {
let win = handle.get_webview_window("main").unwrap();
win.show().unwrap();
Ok(())
}
// TODO: Add tests
// #[cfg(test)]
// mod tests {
// use tauri::Manager;
// #[tokio::test]
// async fn run_app() {
// super::run_app(tauri::test::mock_builder(), |app| {
// super::setup(app);
// let win = app.get_webview_window("main").unwrap();
// tokio::spawn(async move {
// tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
// win.close().unwrap();
// });
// })
// .await
// }
// }