Initial commit

This commit is contained in:
2024-09-01 06:20:49 +03:00
parent bd61f5d591
commit 9263c396a1
81 changed files with 1494 additions and 1521 deletions

View File

@@ -6,11 +6,11 @@
<array>
<dict>
<key>CFBundleURLName</key>
<string>ModrinthApp</string>
<string>AstralRinthApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>modrinth</string>
<string>modrinthscheme</string>
<string>astralrinth</string>
<string>astralrinthscheme</string>
</array>
</dict>
</array>

View File

@@ -12,6 +12,7 @@ fn main() {
"auth",
InlinedPlugin::new()
.commands(&[
"offline_login",
"login",
"remove_user",
"get_default_user",
@@ -206,6 +207,7 @@ fn main() {
"utils",
InlinedPlugin::new()
.commands(&[
"get_artifact",
"get_os",
"should_disable_mouseover",
"highlight_in_folder",
@@ -217,19 +219,6 @@ fn main() {
.default_permission(
DefaultPermissionRule::AllowAllCommands,
),
)
.plugin(
"ads",
InlinedPlugin::new()
.commands(&[
"init_ads_window",
"hide_ads_window",
"scroll_ads_window",
"show_ads_window",
])
.default_permission(
DefaultPermissionRule::AllowAllCommands,
),
),
)
.expect("Failed to run tauri-build");

View File

@@ -1,15 +0,0 @@
{
"identifier": "ads",
"description": "",
"local": false,
"remote": {
"urls": ["https://modrinth.com/*", "http://localhost:3000/*"]
},
"webviews": [
"ads-window"
],
"permissions": [
"shell:allow-open",
"ads:default"
]
}

View File

@@ -35,7 +35,6 @@
"cache:default",
"settings:default",
"tags:default",
"utils:default",
"ads:default"
"utils:default"
]
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"ads":{"identifier":"ads","description":"","remote":{"urls":["https://modrinth.com/*","http://localhost:3000/*"]},"local":false,"webviews":["ads-window"],"permissions":["shell:allow-open","ads:default"]},"core":{"identifier":"core","description":"","local":true,"windows":["main"],"permissions":["core:default","core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-create","core:window:allow-maximize","core:window:allow-toggle-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-start-dragging","core:webview:allow-set-webview-zoom"]},"plugins":{"identifier":"plugins","description":"","local":true,"windows":["main"],"permissions":["dialog:allow-open","dialog:allow-confirm","shell:allow-open","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","deep-link:default","window-state:default","window-state:allow-restore-state","window-state:allow-save-window-state","auth:default","import:default","jre:default","logs:default","metadata:default","mr-auth:default","profile-create:default","pack:default","process:default","profile:default","cache:default","settings:default","tags:default","utils:default","ads:default"]},"updater":{"identifier":"updater","description":"","local":true,"windows":["main"],"permissions":["updater:default"]}}
{"core":{"identifier":"core","description":"","local":true,"windows":["main"],"permissions":["core:default","core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-create","core:window:allow-maximize","core:window:allow-toggle-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-start-dragging","core:webview:allow-set-webview-zoom"]},"plugins":{"identifier":"plugins","description":"","local":true,"windows":["main"],"permissions":["dialog:allow-open","dialog:allow-confirm","shell:allow-open","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","deep-link:default","window-state:default","window-state:allow-restore-state","window-state:allow-save-window-state","auth:default","import:default","jre:default","logs:default","metadata:default","mr-auth:default","profile-create:default","pack:default","process:default","profile:default","cache:default","settings:default","tags:default","utils:default"]},"updater":{"identifier":"updater","description":"","local":true,"windows":["main"],"permissions":["updater:default"]}}

View File

@@ -299,69 +299,6 @@
},
"Identifier": {
"oneOf": [
{
"description": "ads:default -> Default plugin permissions.",
"type": "string",
"enum": [
"ads:default"
]
},
{
"description": "ads:allow-hide-ads-window -> Enables the hide_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-hide-ads-window"
]
},
{
"description": "ads:allow-init-ads-window -> Enables the init_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-init-ads-window"
]
},
{
"description": "ads:allow-scroll-ads-window -> Enables the scroll_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-scroll-ads-window"
]
},
{
"description": "ads:allow-show-ads-window -> Enables the show_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-show-ads-window"
]
},
{
"description": "ads:deny-hide-ads-window -> Denies the hide_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-hide-ads-window"
]
},
{
"description": "ads:deny-init-ads-window -> Denies the init_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-init-ads-window"
]
},
{
"description": "ads:deny-scroll-ads-window -> Denies the scroll_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-scroll-ads-window"
]
},
{
"description": "ads:deny-show-ads-window -> Denies the show_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-show-ads-window"
]
},
{
"description": "auth:default -> Default plugin permissions.",
"type": "string",
@@ -390,6 +327,13 @@
"auth:allow-login"
]
},
{
"description": "auth:allow-offline-login -> Enables the offline_login command without any pre-configured scope.",
"type": "string",
"enum": [
"auth:allow-offline-login"
]
},
{
"description": "auth:allow-remove-user -> Enables the remove_user command without any pre-configured scope.",
"type": "string",
@@ -425,6 +369,13 @@
"auth:deny-login"
]
},
{
"description": "auth:deny-offline-login -> Denies the offline_login command without any pre-configured scope.",
"type": "string",
"enum": [
"auth:deny-offline-login"
]
},
{
"description": "auth:deny-remove-user -> Denies the remove_user command without any pre-configured scope.",
"type": "string",
@@ -3988,6 +3939,13 @@
"utils:default"
]
},
{
"description": "utils:allow-get-artifact -> Enables the get_artifact command without any pre-configured scope.",
"type": "string",
"enum": [
"utils:allow-get-artifact"
]
},
{
"description": "utils:allow-get-opening-command -> Enables the get_opening_command command without any pre-configured scope.",
"type": "string",
@@ -4037,6 +3995,13 @@
"utils:allow-show-launcher-logs-folder"
]
},
{
"description": "utils:deny-get-artifact -> Denies the get_artifact command without any pre-configured scope.",
"type": "string",
"enum": [
"utils:deny-get-artifact"
]
},
{
"description": "utils:deny-get-opening-command -> Denies the get_opening_command command without any pre-configured scope.",
"type": "string",

View File

@@ -299,69 +299,6 @@
},
"Identifier": {
"oneOf": [
{
"description": "ads:default -> Default plugin permissions.",
"type": "string",
"enum": [
"ads:default"
]
},
{
"description": "ads:allow-hide-ads-window -> Enables the hide_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-hide-ads-window"
]
},
{
"description": "ads:allow-init-ads-window -> Enables the init_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-init-ads-window"
]
},
{
"description": "ads:allow-scroll-ads-window -> Enables the scroll_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-scroll-ads-window"
]
},
{
"description": "ads:allow-show-ads-window -> Enables the show_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:allow-show-ads-window"
]
},
{
"description": "ads:deny-hide-ads-window -> Denies the hide_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-hide-ads-window"
]
},
{
"description": "ads:deny-init-ads-window -> Denies the init_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-init-ads-window"
]
},
{
"description": "ads:deny-scroll-ads-window -> Denies the scroll_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-scroll-ads-window"
]
},
{
"description": "ads:deny-show-ads-window -> Denies the show_ads_window command without any pre-configured scope.",
"type": "string",
"enum": [
"ads:deny-show-ads-window"
]
},
{
"description": "auth:default -> Default plugin permissions.",
"type": "string",
@@ -390,6 +327,13 @@
"auth:allow-login"
]
},
{
"description": "auth:allow-offline-login -> Enables the offline_login command without any pre-configured scope.",
"type": "string",
"enum": [
"auth:allow-offline-login"
]
},
{
"description": "auth:allow-remove-user -> Enables the remove_user command without any pre-configured scope.",
"type": "string",
@@ -425,6 +369,13 @@
"auth:deny-login"
]
},
{
"description": "auth:deny-offline-login -> Denies the offline_login command without any pre-configured scope.",
"type": "string",
"enum": [
"auth:deny-offline-login"
]
},
{
"description": "auth:deny-remove-user -> Denies the remove_user command without any pre-configured scope.",
"type": "string",
@@ -3988,6 +3939,13 @@
"utils:default"
]
},
{
"description": "utils:allow-get-artifact -> Enables the get_artifact command without any pre-configured scope.",
"type": "string",
"enum": [
"utils:allow-get-artifact"
]
},
{
"description": "utils:allow-get-opening-command -> Enables the get_opening_command command without any pre-configured scope.",
"type": "string",
@@ -4037,6 +3995,13 @@
"utils:allow-show-launcher-logs-folder"
]
},
{
"description": "utils:deny-get-artifact -> Denies the get_artifact command without any pre-configured scope.",
"type": "string",
"enum": [
"utils:deny-get-artifact"
]
},
{
"description": "utils:deny-get-opening-command -> Denies the get_opening_command command without any pre-configured scope.",
"type": "string",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 34 KiB

BIN
apps/app/icons/icon (1).png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -1,20 +0,0 @@
if (!window.modrinthClickListener) {
window.modrinthClickListener = true
document.addEventListener('click', function (e) {
let target = e.target
while (target != null) {
if (target.matches('a')) {
e.preventDefault()
if (target.href) {
window.top.postMessage({ modrinthOpenUrl: target.href }, 'https://modrinth.com')
}
break
}
target = target.parentElement
}
})
}
window.open = (url, target, features) => {
window.top.postMessage({ modrinthOpenUrl: url }, 'https://modrinth.com')
}

View File

@@ -1,143 +0,0 @@
use serde::Serialize;
use tauri::plugin::TauriPlugin;
use tauri::{Emitter, LogicalPosition, LogicalSize, Manager, Runtime};
use tokio::sync::RwLock;
pub struct AdsState {
pub shown: bool,
pub size: Option<LogicalSize<f32>>,
pub position: Option<LogicalPosition<f32>>,
}
pub fn init<R: Runtime>() -> TauriPlugin<R> {
tauri::plugin::Builder::<R>::new("ads")
.setup(|app, _api| {
app.manage(RwLock::new(AdsState {
shown: true,
size: None,
position: None,
}));
Ok(())
})
.invoke_handler(tauri::generate_handler![
init_ads_window,
hide_ads_window,
scroll_ads_window,
show_ads_window,
])
.build()
}
#[tauri::command]
#[cfg(not(target_os = "linux"))]
pub async fn init_ads_window<R: Runtime>(
app: tauri::AppHandle<R>,
x: f32,
y: f32,
width: f32,
height: f32,
override_shown: bool,
) -> crate::api::Result<()> {
use tauri::WebviewUrl;
const LINK_SCRIPT: &str = include_str!("ads-init.js");
let state = app.state::<RwLock<AdsState>>();
let mut state = state.write().await;
state.size = Some(LogicalSize::new(width, height));
state.position = Some(LogicalPosition::new(x, y));
if override_shown {
state.shown = true;
}
if let Some(webview) = app.webviews().get("ads-window") {
if state.shown {
let _ = webview.set_position(LogicalPosition::new(x, y));
let _ = webview.set_size(LogicalSize::new(width, height));
}
} else if let Some(window) = app.get_window("main") {
let _ = window.add_child(
tauri::webview::WebviewBuilder::new(
"ads-window",
WebviewUrl::External(
"https://modrinth.com/wrapper/app-ads".parse().unwrap(),
),
)
.initialization_script(LINK_SCRIPT)
.user_agent("ModrinthApp Ads Webview")
.zoom_hotkeys_enabled(false)
.transparent(true),
if state.shown {
LogicalPosition::new(x, y)
} else {
LogicalPosition::new(-1000.0, -1000.0)
},
LogicalSize::new(width, height),
);
}
Ok(())
}
// TODO: make ads work on linux
#[tauri::command]
#[cfg(target_os = "linux")]
pub async fn init_ads_window() {}
#[tauri::command]
pub async fn show_ads_window<R: Runtime>(
app: tauri::AppHandle<R>,
) -> crate::api::Result<()> {
if let Some(webview) = app.webviews().get("ads-window") {
let state = app.state::<RwLock<AdsState>>();
let mut state = state.write().await;
state.shown = true;
if let Some(size) = state.size {
let _ = webview.set_size(size);
}
if let Some(position) = state.position {
let _ = webview.set_position(position);
}
}
Ok(())
}
#[tauri::command]
pub async fn hide_ads_window<R: Runtime>(
app: tauri::AppHandle<R>,
reset: Option<bool>,
) -> crate::api::Result<()> {
if let Some(webview) = app.webviews().get("ads-window") {
let state = app.state::<RwLock<AdsState>>();
let mut state = state.write().await;
state.shown = false;
if reset.unwrap_or(false) {
state.size = None;
state.position = None;
}
let _ = webview.set_position(LogicalPosition::new(-1000, -1000));
}
Ok(())
}
#[derive(Serialize, Clone)]
struct ScrollEvent {
scroll: f32,
}
#[tauri::command]
pub async fn scroll_ads_window<R: Runtime>(
app: tauri::AppHandle<R>,
scroll: f32,
) -> crate::api::Result<()> {
let _ = app.emit("ads-scroll", ScrollEvent { scroll });
Ok(())
}

View File

@@ -7,6 +7,7 @@ use theseus::prelude::*;
pub fn init<R: Runtime>() -> TauriPlugin<R> {
tauri::plugin::Builder::<R>::new("auth")
.invoke_handler(tauri::generate_handler![
offline_login,
login,
remove_user,
get_default_user,
@@ -16,6 +17,14 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
.build()
}
/// Create new offline user
/// This is custom function from Astralium Org.
#[tauri::command]
pub async fn offline_login(name: &str) -> Result<Credentials> {
let credentials = minecraft_auth::offline_auth(name).await?;
Ok(credentials)
}
/// Authenticate a user with Hydra - part 1
/// This begins the authentication flow quasi-synchronously, returning a URL to visit (that the user will sign in at)
#[tauri::command]

View File

@@ -16,7 +16,6 @@ pub mod settings;
pub mod tags;
pub mod utils;
pub mod ads;
pub mod cache;
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;

View File

@@ -11,6 +11,7 @@ use std::path::PathBuf;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("utils")
.invoke_handler(tauri::generate_handler![
get_artifact,
get_os,
should_disable_mouseover,
highlight_in_folder,
@@ -22,6 +23,12 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
.build()
}
#[tauri::command]
pub async fn get_artifact(downloadurl: &str, filename: &str, ostype: &str, autoupdatesupported: bool) -> Result<()> {
theseus::download::init_download(downloadurl, filename, ostype, autoupdatesupported).await;
Ok(())
}
/// Gets OS
#[tauri::command]
pub fn get_os() -> OS {

View File

@@ -27,61 +27,61 @@ extern crate objc;
async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
theseus::EventState::init(app.clone()).await?;
#[cfg(feature = "updater")]
{
use tauri_plugin_updater::UpdaterExt;
// #[cfg(feature = "updater")]
// {
// use tauri_plugin_updater::UpdaterExt;
let updater = app.updater_builder().build()?;
// let updater = app.updater_builder().build()?;
let update_fut = updater.check();
// let update_fut = updater.check();
State::init().await?;
// State::init().await?;
let check_bar = theseus::init_loading(
theseus::LoadingBarType::CheckingForUpdates,
1.0,
"Checking for updates...",
)
.await?;
// let check_bar = theseus::init_loading(
// theseus::LoadingBarType::CheckingForUpdates,
// 1.0,
// "Checking for updates...",
// )
// .await?;
let update = update_fut.await;
// let update = update_fut.await;
drop(check_bar);
// drop(check_bar);
if let Some(update) = update.ok().flatten() {
tracing::info!("Update found: {:?}", update.download_url);
let loader_bar_id = theseus::init_loading(
theseus::LoadingBarType::LauncherUpdate {
version: update.version.clone(),
current_version: update.current_version.clone(),
},
1.0,
"Updating Modrinth App...",
)
.await?;
// if let Some(update) = update.ok().flatten() {
// tracing::info!("Update found: {:?}", update.download_url);
// let loader_bar_id = theseus::init_loading(
// theseus::LoadingBarType::LauncherUpdate {
// version: update.version.clone(),
// current_version: update.current_version.clone(),
// },
// 1.0,
// "Updating Modrinth App...",
// )
// .await?;
// 100 MiB
const DEFAULT_CONTENT_LENGTH: u64 = 1024 * 1024 * 100;
// // 100 MiB
// const DEFAULT_CONTENT_LENGTH: u64 = 1024 * 1024 * 100;
update
.download_and_install(
|chunk_length, content_length| {
let _ = theseus::emit_loading(
&loader_bar_id,
(chunk_length as f64)
/ (content_length
.unwrap_or(DEFAULT_CONTENT_LENGTH)
as f64),
None,
);
},
|| {},
)
.await?;
// update
// .download_and_install(
// |chunk_length, content_length| {
// let _ = theseus::emit_loading(
// &loader_bar_id,
// (chunk_length as f64)
// / (content_length
// .unwrap_or(DEFAULT_CONTENT_LENGTH)
// as f64),
// None,
// );
// },
// || {},
// )
// .await?;
app.restart();
}
}
// app.restart();
// }
// }
#[cfg(not(feature = "updater"))]
{
@@ -259,7 +259,6 @@ fn main() {
.plugin(api::tags::init())
.plugin(api::utils::init())
.plugin(api::cache::init())
.plugin(api::ads::init())
.invoke_handler(tauri::generate_handler![
initialize_state,
is_dev,

View File

@@ -7,7 +7,7 @@
},
"app": {
"security": {
"capabilities": ["ads", "core", "plugins", "updater"]
"capabilities": ["core", "plugins", "updater"]
}
},
"plugins": {

View File

@@ -47,9 +47,9 @@
}
]
},
"productName": "Modrinth App",
"productName": "AstralRinth App",
"version": "0.8.5",
"identifier": "ModrinthApp",
"identifier": "AstralRinth",
"plugins": {
"deep-link": {
"desktop": {
@@ -68,7 +68,7 @@
"fullscreen": false,
"height": 800,
"resizable": true,
"title": "Modrinth App",
"title": "AstralRinth",
"width": 1280,
"minHeight": 750,
"minWidth": 1100,
@@ -86,10 +86,10 @@
],
"enable": true
},
"capabilities": ["ads", "core", "plugins"],
"capabilities": ["core", "plugins"],
"csp": {
"default-src": "'self' customprotocol: asset:",
"connect-src": "ipc: http://ipc.localhost https://modrinth.com https://*.modrinth.com https://*.posthog.com https://*.sentry.io https://*.cloudflare.com https://api.mclo.gs https://cmp.inmobi.com",
"connect-src": "https://api.github.com ipc: http://ipc.localhost https://modrinth.com https://*.modrinth.com https://*.posthog.com https://*.sentry.io https://*.cloudflare.com https://api.mclo.gs https://cmp.inmobi.com",
"font-src": [
"https://cdn-raw.modrinth.com/fonts/inter/"
],

View File

@@ -7,7 +7,7 @@
"fullscreen": false,
"height": 800,
"resizable": true,
"title": "Modrinth App",
"title": "AstralRinth",
"width": 1280,
"minHeight": 700,
"minWidth": 1100,