feat:移除了弹窗,服务器添加sls
2
apps/app/.cargo/config.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[env]
|
||||
SQLX_OFFLINE = "true"
|
||||
3
apps/app/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Generated by tauri, metadata generated at compile time
|
||||
/gen/
|
||||
.netlify
|
||||
3
apps/app/.prettierignore
Normal file
@ -0,0 +1,3 @@
|
||||
**/*.rs
|
||||
src/api/oauth_utils/auth_code_reply/page.html
|
||||
vendor/
|
||||
14
apps/app/App.entitlements
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.camera</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
15
apps/app/COPYING.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Copying
|
||||
|
||||
Axolotl Launcher is a modified version of Modrinth App. The source code in this package is licensed under the GNU General Public License, Version 3 only, provided in [LICENSE](./LICENSE).
|
||||
|
||||
Copyright for the original work remains with Rinth, Inc. and the original contributors. Axolotl modifications are Copyright © 2026 Garbage Human Studio and were developed by Mystic Stars.
|
||||
|
||||
Axolotl Launcher is an independent, unofficial client. Modrinth is a trademark of Rinth, Inc. and is referenced only to identify API and file-format compatibility. Axolotl Launcher is not affiliated with or endorsed by Rinth, Inc.
|
||||
|
||||
## Seed map attribution
|
||||
|
||||
The local Java seed-map engine statically links [cubiomes](https://github.com/Cubitect/cubiomes), Copyright (c) 2020 Cubitect, under the MIT License. Its complete source and license are retained in `vendor/cubiomes/`. Seed-map generation runs locally through cubiomes and the Axolotl native integration; the tool does not contact an external map service at runtime.
|
||||
|
||||
Some structure and biome icons in `apps/app-frontend/public/seed-map-assets/` were sourced from [MinecraftSearch](https://minecraftsearch.com). MinecraftSearch and the respective creators retain their rights in that artwork. The remaining marker, ore, and biome preview images depict Mojang's Minecraft content and are used for identification within this unofficial tool.
|
||||
|
||||
Minecraft is a trademark of Mojang Synergies AB. Axolotl Launcher is not affiliated with or endorsed by Mojang or MinecraftSearch.
|
||||
110
apps/app/Cargo.toml
Normal file
@ -0,0 +1,110 @@
|
||||
[package]
|
||||
name = "theseus_gui"
|
||||
# The actual version is set by the theseus-build workflow on tagging
|
||||
version = "1.9.6-beta.3"
|
||||
edition.workspace = true
|
||||
description = "Axolotl Launcher is a cross-platform Minecraft launcher"
|
||||
homepage = "https://www.ghs.red"
|
||||
license = "GPL-3.0-only"
|
||||
|
||||
[dependencies]
|
||||
async_zip = { workspace = true, features = ["deflate", "tokio-fs"] }
|
||||
bytes = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
daedalus = { workspace = true }
|
||||
dashmap = { workspace = true }
|
||||
either = { workspace = true }
|
||||
enumset = { workspace = true, features = ["serde"] }
|
||||
flate2 = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
hyper = { workspace = true, features = ["server"] }
|
||||
hyper-util = { workspace = true }
|
||||
image = { workspace = true }
|
||||
keyring = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
native-dialog = { workspace = true }
|
||||
notify = { workspace = true }
|
||||
paste = { workspace = true }
|
||||
path-util = { workspace = true }
|
||||
quartz_nbt = { workspace = true, features = ["serde"] }
|
||||
regex = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
serde_with = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
tauri-plugin-deep-link = { workspace = true }
|
||||
tauri-plugin-dialog = { workspace = true }
|
||||
tauri-plugin-fs = { workspace = true }
|
||||
tauri-plugin-http = { workspace = true }
|
||||
tauri-plugin-opener = { workspace = true }
|
||||
tauri-plugin-os = { workspace = true }
|
||||
tauri-plugin-single-instance = { workspace = true }
|
||||
tauri-plugin-updater = { workspace = true }
|
||||
tauri-plugin-window-state = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
theseus = { workspace = true, features = ["tauri"] }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "time"] }
|
||||
tokio-util = { workspace = true, features = ["compat", "rt"] }
|
||||
tracing = { workspace = true }
|
||||
tracing-error = { workspace = true }
|
||||
trash = { workspace = true }
|
||||
url = { workspace = true }
|
||||
urlencoding = { workspace = true }
|
||||
uuid = { workspace = true, features = ["serde", "v4"] }
|
||||
zip = { workspace = true }
|
||||
|
||||
[dependencies.tauri]
|
||||
workspace = true
|
||||
features = [
|
||||
"devtools",
|
||||
"macos-private-api",
|
||||
"protocol-asset",
|
||||
"tray-icon",
|
||||
"unstable"
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
cc = { workspace = true }
|
||||
tauri-build = { workspace = true, features = ["codegen"] }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
ashpd = { version = "0.13.13", features = ["settings"] }
|
||||
tauri-plugin-updater = { workspace = true, optional = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
block2 = "0.6.2"
|
||||
objc2-app-kit = { version = "0.3.2", default-features = false, features = [
|
||||
"NSColor",
|
||||
"NSColorSpace",
|
||||
"objc2-core-foundation",
|
||||
] }
|
||||
objc2-foundation = { version = "0.3.2", default-features = false, features = [
|
||||
"NSNotification",
|
||||
"NSOperation",
|
||||
"NSString",
|
||||
"block2",
|
||||
] }
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
workspace = true
|
||||
features = [
|
||||
"Foundation",
|
||||
"UI_ViewManagement",
|
||||
"Win32_Graphics_Dwm",
|
||||
"Win32_System_Com",
|
||||
"Win32_UI_Shell",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
]
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||
default = ["custom-protocol"]
|
||||
# this feature is used for production builds where `devPath` points to the filesystem
|
||||
# DO NOT remove this
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
updater = []
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
42
apps/app/Info.plist
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>AxolotlLauncher</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>axolotl</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>A Minecraft mod wants to access your camera.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>A Minecraft mod wants to access your microphone.</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>asset.localhost</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true />
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true />
|
||||
</dict>
|
||||
<key>textures.minecraft.net</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true />
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true />
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
674
apps/app/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
5
apps/app/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Axolotl Launcher
|
||||
|
||||
Axolotl Launcher is the Tauri desktop shell for the Axolotl Minecraft launcher.
|
||||
|
||||
Run `pnpm install` and `pnpm app:dev` from the workspace root to start a development build.
|
||||
811
apps/app/build.rs
Normal file
@ -0,0 +1,811 @@
|
||||
use std::process::Command;
|
||||
use tauri_build::{DefaultPermissionRule, InlinedPlugin};
|
||||
|
||||
#[cfg(windows)]
|
||||
const NPM_COMMAND: &str = "npm.cmd";
|
||||
#[cfg(not(windows))]
|
||||
const NPM_COMMAND: &str = "npm";
|
||||
|
||||
fn run_command(command: &mut Command, description: &str) {
|
||||
let status = command.status().unwrap_or_else(|error| {
|
||||
panic!("Failed to start {description}: {error}")
|
||||
});
|
||||
assert!(
|
||||
status.success(),
|
||||
"{description} failed with status {status}"
|
||||
);
|
||||
}
|
||||
|
||||
fn build_blockbench_skin_editor() {
|
||||
let blockbench_dir = std::path::Path::new("../../third-party/blockbench");
|
||||
assert!(
|
||||
blockbench_dir.join("package.json").is_file(),
|
||||
"Blockbench skin editor submodule is missing. Run git submodule update --init --recursive."
|
||||
);
|
||||
if !blockbench_dir.join("node_modules").is_dir() {
|
||||
run_command(
|
||||
Command::new(NPM_COMMAND)
|
||||
.arg("ci")
|
||||
.current_dir(blockbench_dir),
|
||||
"Blockbench skin editor dependency install",
|
||||
);
|
||||
}
|
||||
|
||||
run_command(
|
||||
Command::new(NPM_COMMAND)
|
||||
.arg("run")
|
||||
.arg("build-skin")
|
||||
.current_dir(blockbench_dir),
|
||||
"Blockbench skin editor build",
|
||||
);
|
||||
run_command(
|
||||
Command::new("node")
|
||||
.arg("scripts/axolotl/sync-blockbench-skin-editor.mjs")
|
||||
.current_dir("../.."),
|
||||
"Blockbench skin editor resource sync",
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=tauri.conf.json");
|
||||
println!("cargo:rerun-if-changed=tauri.windows.conf.json");
|
||||
println!("cargo:rerun-if-changed=tauri.macos.conf.json");
|
||||
println!("cargo:rerun-if-changed=tauri.linux.conf.json");
|
||||
println!("cargo:rerun-if-changed=tauri-modern.conf.json");
|
||||
println!("cargo:rerun-if-changed=tauri-release.conf.json");
|
||||
println!("cargo:rerun-if-changed=../../third-party/blockbench");
|
||||
// Tauri validates frontendDist during Cargo metadata/check builds. The
|
||||
// frontend build runs in parallel in CI, so create the directory before
|
||||
// tauri-build reads the configuration. A real frontend build overwrites
|
||||
// this directory with the actual assets before packaging.
|
||||
std::fs::create_dir_all("../app-frontend/dist")
|
||||
.expect("Failed to create the frontend distribution directory");
|
||||
build_blockbench_skin_editor();
|
||||
|
||||
let cubiomes_dir = std::path::Path::new("vendor/cubiomes");
|
||||
cc::Build::new()
|
||||
.include(cubiomes_dir)
|
||||
.include(cubiomes_dir.join("tables"))
|
||||
.file("src/seed_map/cubiomes_bridge.c")
|
||||
.files([
|
||||
"vendor/cubiomes/biomenoise.c",
|
||||
"vendor/cubiomes/biomes.c",
|
||||
"vendor/cubiomes/finders.c",
|
||||
"vendor/cubiomes/generator.c",
|
||||
"vendor/cubiomes/layers.c",
|
||||
"vendor/cubiomes/noise.c",
|
||||
"vendor/cubiomes/quadbase.c",
|
||||
"vendor/cubiomes/util.c",
|
||||
])
|
||||
.opt_level(3)
|
||||
.flag_if_supported("-fwrapv")
|
||||
.warnings(false)
|
||||
.compile("axolotl-cubiomes");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/seed_map/cubiomes_bridge.c");
|
||||
println!("cargo:rerun-if-changed=src/seed_map/cubiomes_bridge.h");
|
||||
println!("cargo:rerun-if-changed=vendor/cubiomes");
|
||||
// Build scripts run for the host, so use Cargo's target metadata rather
|
||||
// than `cfg(target_os = ...)` when deciding whether libm is needed.
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
|
||||
println!("cargo:rustc-link-lib=m");
|
||||
}
|
||||
|
||||
// Sadly, there is no better way to do it right now
|
||||
// You could try parsing source code here and detecting #[tauri::command]
|
||||
// But I think it's not worth it
|
||||
// https://github.com/tauri-apps/tauri/issues/10075
|
||||
tauri_build::try_build(
|
||||
tauri_build::Attributes::new()
|
||||
.codegen(tauri_build::CodegenContext::new())
|
||||
.plugin(
|
||||
"auth",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"check_reachable",
|
||||
"check_mojang_services",
|
||||
"set_mojang_auth_use_mirror",
|
||||
"login",
|
||||
"browser_login",
|
||||
"begin_device_login",
|
||||
"poll_device_login",
|
||||
"begin_yggdrasil_login",
|
||||
"finish_yggdrasil_login",
|
||||
"list_yggdrasil_saved_logins",
|
||||
"get_yggdrasil_password",
|
||||
"set_yggdrasil_password",
|
||||
"delete_yggdrasil_password",
|
||||
"add_offline_user",
|
||||
"remove_user",
|
||||
"get_default_user",
|
||||
"set_default_user",
|
||||
"get_users",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"cache",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"get_project",
|
||||
"get_project_many",
|
||||
"get_project_v3",
|
||||
"get_project_v3_many",
|
||||
"get_version",
|
||||
"get_version_many",
|
||||
"get_user",
|
||||
"get_user_many",
|
||||
"get_team",
|
||||
"get_team_many",
|
||||
"get_organization",
|
||||
"get_organization_many",
|
||||
"get_search_results",
|
||||
"get_search_results_many",
|
||||
"get_search_results_v3",
|
||||
"get_search_results_v3_many",
|
||||
"cancel_search_request",
|
||||
"purge_cache_types",
|
||||
"get_project_versions",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"content-search",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"resolve_chinese_content_search",
|
||||
"expand_content_search_query",
|
||||
"lookup_chinese_content_names",
|
||||
"lookup_content_wiki_ids",
|
||||
"lookup_content_identities",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"content-favorites",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"content_favorites_list",
|
||||
"content_favorites_add",
|
||||
"content_favorites_remove",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"datapacks",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"list_datapacks",
|
||||
"delete_datapack",
|
||||
"set_datapack_enabled",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"curseforge",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"curseforge_capability",
|
||||
"curseforge_validate_credentials",
|
||||
"curseforge_search_projects",
|
||||
"curseforge_get_project",
|
||||
"curseforge_get_projects",
|
||||
"curseforge_get_description",
|
||||
"curseforge_get_files",
|
||||
"curseforge_get_file",
|
||||
"curseforge_get_files_many",
|
||||
"curseforge_get_changelog",
|
||||
"curseforge_get_download_url",
|
||||
"curseforge_get_categories",
|
||||
"curseforge_match_fingerprints",
|
||||
"curseforge_install_file",
|
||||
"curseforge_preview_install_file",
|
||||
"curseforge_update_installed_file",
|
||||
"curseforge_switch_installed_file_version",
|
||||
"curseforge_recognize_instance_files",
|
||||
"curseforge_import_manual_downloads",
|
||||
"curseforge_list_pending_manual_downloads",
|
||||
"curseforge_import_pending_manual_download_file",
|
||||
"curseforge_configure_manual_download_watcher",
|
||||
"curseforge_install_modpack",
|
||||
"curseforge_update_managed_modpack",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"mcarchive",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"mcarchive_get_game_versions",
|
||||
"mcarchive_search_mods",
|
||||
"mcarchive_get_mod_by_slug",
|
||||
"mcarchive_get_file_by_filename",
|
||||
"mcarchive_get_file_by_sha256",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"import",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"get_importable_instances",
|
||||
"import_instance",
|
||||
"is_valid_importable_instance",
|
||||
"get_default_launcher_path",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"jre",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"get_java_versions",
|
||||
"get_java_default_versions",
|
||||
"set_java_version",
|
||||
"set_java_default_version",
|
||||
"remove_java_default_version",
|
||||
"remove_java_version",
|
||||
"jre_find_filtered_jres",
|
||||
"jre_get_jre",
|
||||
"jre_test_jre",
|
||||
"jre_auto_install_java",
|
||||
"jre_respond_to_download_confirmation",
|
||||
"jre_get_max_memory",
|
||||
"jre_get_memory_status",
|
||||
"jre_optimize_memory",
|
||||
"list_java_distribution_versions",
|
||||
"list_java_feed_vendors",
|
||||
"list_java_feed_versions",
|
||||
"download_java_from_feed",
|
||||
"download_java",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"logs",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"logs_get_logs",
|
||||
"logs_get_logs_by_filename",
|
||||
"logs_get_output_by_filename",
|
||||
"logs_delete_logs",
|
||||
"logs_delete_logs_by_filename",
|
||||
"logs_get_latest_log_cursor",
|
||||
"logs_get_minecraft_latest_log_cursor",
|
||||
"logs_get_live_log_buffer",
|
||||
"logs_clear_live_log_buffer",
|
||||
"logs_analyze_crash",
|
||||
"logs_get_crash_analysis_ai_settings",
|
||||
"logs_update_crash_analysis_ai_settings",
|
||||
"logs_explain_crash_with_ai",
|
||||
"logs_undo_added_mod",
|
||||
"logs_export_crash_context",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"metadata",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"metadata_get_game_versions",
|
||||
"metadata_get_loader_versions",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"minecraft-skins",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"get_available_capes",
|
||||
"get_available_skins",
|
||||
"add_and_equip_custom_skin",
|
||||
"equip_skin",
|
||||
"remove_custom_skin",
|
||||
"save_custom_skin",
|
||||
"set_custom_skin_order",
|
||||
"unequip_skin",
|
||||
"flush_pending_skin_change",
|
||||
"flush_pending_skin_change_for_profile",
|
||||
"normalize_skin_texture",
|
||||
"get_dragged_skin_data",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"mr-auth",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"modrinth_login",
|
||||
"logout",
|
||||
"get",
|
||||
"cancel_modrinth_login",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"install",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"install_get_modpack_preview",
|
||||
"install_create_instance",
|
||||
"install_create_modpack_instance",
|
||||
"install_import_instance",
|
||||
"install_start_import_plan",
|
||||
"install_cancel_import_plan",
|
||||
"install_duplicate_instance",
|
||||
"install_existing_instance",
|
||||
"install_pack_to_existing_instance",
|
||||
"install_job_list",
|
||||
"install_job_get",
|
||||
"install_job_retry",
|
||||
"install_job_repair_cache_and_retry",
|
||||
"install_job_resume",
|
||||
"install_job_skip_missing_content",
|
||||
"install_job_missing_files",
|
||||
"install_job_scan_missing_files",
|
||||
"install_job_retry_missing_file",
|
||||
"install_job_import_missing_file",
|
||||
"install_job_cancel",
|
||||
"install_job_dismiss",
|
||||
"install_job_support_details",
|
||||
"download_job_list",
|
||||
"download_job_get",
|
||||
"download_job_retry",
|
||||
"download_job_resume",
|
||||
"download_job_cancel",
|
||||
"download_job_delete",
|
||||
"download_history_clear",
|
||||
"download_job_support_details",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"process",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"process_get_all",
|
||||
"process_get_by_instance_id",
|
||||
"process_kill",
|
||||
"process_wait_for",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"planet-minecraft",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"planet_minecraft_connector_available",
|
||||
"planet_minecraft_search_projects",
|
||||
"planet_minecraft_get_project",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"instance",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"instance_remove",
|
||||
"instance_create_direct_link",
|
||||
"instance_sync_direct_links",
|
||||
"instance_get",
|
||||
"instance_get_many",
|
||||
"instance_get_projects",
|
||||
"instance_get_installed_project_ids",
|
||||
"instance_get_install_candidates",
|
||||
"instance_content",
|
||||
"instance_get_content_items_by_paths",
|
||||
"instance_get_content_items",
|
||||
"instance_get_content_snapshot",
|
||||
"instance_refresh_content",
|
||||
"instance_plan_content_updates",
|
||||
"instance_apply_content_update_plan",
|
||||
"instance_plan_upgrade",
|
||||
"instance_get_upgrade_plan",
|
||||
"instance_update_upgrade_resolution",
|
||||
"instance_update_upgrade_resolutions",
|
||||
"instance_reset_upgrade_resolution",
|
||||
"instance_select_upgrade_solution",
|
||||
"instance_resolve_custom_upgrade_solution",
|
||||
"instance_execute_upgrade",
|
||||
"instance_get_post_upgrade_notice",
|
||||
"instance_dismiss_post_upgrade_notice",
|
||||
"instance_get_dependencies_as_content_items",
|
||||
"instance_get_linked_modpack_info",
|
||||
"instance_get_linked_modpack_content",
|
||||
"instance_get_optimal_jre_key",
|
||||
"instance_list_core_components",
|
||||
"instance_add_core_jar_mod",
|
||||
"instance_replace_core_jar",
|
||||
"instance_move_core_component",
|
||||
"instance_set_core_component_enabled",
|
||||
"instance_remove_core_component",
|
||||
"instance_restore_core_component",
|
||||
"instance_preview_core_jar",
|
||||
"instance_install_mcarchive_modloader",
|
||||
"instance_import_mcarchive_modloader",
|
||||
"instance_install_mcarchive_content",
|
||||
"instance_import_mcarchive_content",
|
||||
"instance_install_planet_minecraft_content",
|
||||
"instance_import_planet_minecraft_content",
|
||||
"instance_get_full_path",
|
||||
"instance_get_mod_full_path",
|
||||
"instance_list",
|
||||
"instance_set_pinned",
|
||||
"instance_get_daily_playtime",
|
||||
"instance_get_daily_playtime_details",
|
||||
"instance_check_installed",
|
||||
"instance_update_all",
|
||||
"instance_update_project",
|
||||
"instance_add_project_from_version",
|
||||
"instance_install_project_with_dependencies",
|
||||
"instance_preview_project_with_dependencies",
|
||||
"instance_preview_project_with_dependencies_for_target",
|
||||
"instance_queue_project_with_dependencies",
|
||||
"instance_queue_curseforge_content",
|
||||
"instance_queue_curseforge_world",
|
||||
"instance_switch_project_version_with_dependencies",
|
||||
"instance_add_project_from_path",
|
||||
"instance_import_world_save",
|
||||
"instance_install_datapack_to_world",
|
||||
"instance_install_datapack_to_world_bytes",
|
||||
"instance_toggle_disable_project",
|
||||
"instance_toggle_content_entry",
|
||||
"instance_toggle_content_entries",
|
||||
"instance_rollback_project",
|
||||
"instance_remove_project",
|
||||
"instance_remove_content_entry",
|
||||
"instance_update_content_entry",
|
||||
"instance_switch_content_entry_version",
|
||||
"instance_restore_pack_member_default",
|
||||
"instance_update_managed_modrinth_version",
|
||||
"instance_repair_managed_modrinth",
|
||||
"instance_run",
|
||||
"instance_kill",
|
||||
"instance_edit",
|
||||
"instance_cache_icon",
|
||||
"instance_edit_icon",
|
||||
"instance_export_mrpack",
|
||||
"instance_get_pack_export_candidates",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"settings",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"settings_get",
|
||||
"settings_set",
|
||||
"privacy_get",
|
||||
"privacy_set",
|
||||
"telemetry_set",
|
||||
"discord_rpc_set",
|
||||
"download_engine_set",
|
||||
"cancel_directory_change",
|
||||
"proxy_get",
|
||||
"proxy_set",
|
||||
"proxy_test",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"seed-map",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"seed_map_profiles",
|
||||
"seed_map_render_tile",
|
||||
"seed_map_find_features",
|
||||
"seed_map_spawn",
|
||||
"seed_map_biome_at",
|
||||
"seed_map_scan_ores",
|
||||
"seed_map_read_level_dat",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"schematic-preview",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"schematic_preview_open",
|
||||
"schematic_preview_list_instance_files",
|
||||
"schematic_preview_list_instance_resource_packs",
|
||||
"schematic_preview_read_chunk",
|
||||
"schematic_preview_prepare_resources",
|
||||
"schematic_preview_block_info",
|
||||
"schematic_preview_apply_edits",
|
||||
"schematic_preview_transform",
|
||||
"schematic_preview_export_sponge",
|
||||
"schematic_preview_export_litematic",
|
||||
"schematic_preview_cancel",
|
||||
"schematic_preview_close",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"tags",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"tags_get_categories",
|
||||
"tags_get_report_types",
|
||||
"tags_get_loaders",
|
||||
"tags_get_game_versions",
|
||||
"tags_get_donation_platforms",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"ai",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"ai_get_catalog",
|
||||
"ai_get_state",
|
||||
"ai_update_settings",
|
||||
"ai_update_provider",
|
||||
"ai_set_api_key",
|
||||
"ai_set_credential",
|
||||
"ai_update_model",
|
||||
"ai_remove_model",
|
||||
"ai_fetch_models",
|
||||
"ai_test_provider",
|
||||
"ai_begin_oauth",
|
||||
"ai_poll_oauth",
|
||||
"ai_disconnect_oauth",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"translation",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"translation_get_settings",
|
||||
"translation_update_settings",
|
||||
"translation_test_provider",
|
||||
"translation_translate",
|
||||
"translation_clear_cache",
|
||||
"translation_google_ip_pool_size",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"shortcuts",
|
||||
InlinedPlugin::new()
|
||||
.commands(&["create_instance_shortcut"])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"utils",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"get_os",
|
||||
"is_network_metered",
|
||||
"should_disable_mouseover",
|
||||
"highlight_in_folder",
|
||||
"open_path",
|
||||
"show_launcher_logs_folder",
|
||||
"export_error_logs",
|
||||
"show_app_db_backups_folder",
|
||||
"progress_bars_list",
|
||||
"get_opening_command",
|
||||
"get_minecraft_news",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"storage",
|
||||
InlinedPlugin::new()
|
||||
.commands(&["storage_scan_start", "storage_open_paths"])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"system-accent",
|
||||
InlinedPlugin::new()
|
||||
.commands(&["system_accent_color"])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"files",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"file_extract_zip",
|
||||
"file_save_as",
|
||||
"file_read_dragged_file",
|
||||
"screenshot_thumbnail",
|
||||
"studio_read_text",
|
||||
"studio_read_binary",
|
||||
"studio_write_binary",
|
||||
"studio_trash",
|
||||
"studio_watch_register",
|
||||
"studio_watch_unregister",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"drop",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"drop_classify",
|
||||
"drop_classify_extract",
|
||||
"drop_extract_zip_to_temp",
|
||||
"drop_scan_launcher_instances",
|
||||
"drop_remove_temp_dir",
|
||||
"drop_detect_file_lock",
|
||||
"drop_extract_mod_metadata",
|
||||
"drop_lookup_mod_hash",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"worlds",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"get_recent_worlds",
|
||||
"get_favorite_worlds",
|
||||
"get_instance_worlds",
|
||||
"get_singleplayer_world",
|
||||
"set_world_display_status",
|
||||
"get_world_level_data",
|
||||
"update_world_settings",
|
||||
"rename_world",
|
||||
"reset_world_icon",
|
||||
"backup_world",
|
||||
"delete_world",
|
||||
"add_server_to_instance",
|
||||
"edit_server_in_instance",
|
||||
"remove_server_from_instance",
|
||||
"get_instance_protocol_version",
|
||||
"get_server_status",
|
||||
"start_join_singleplayer_world",
|
||||
"start_join_server",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"terracotta",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"terracotta_get_state",
|
||||
"terracotta_get_meta",
|
||||
"terracotta_start",
|
||||
"terracotta_stop",
|
||||
"terracotta_host",
|
||||
"terracotta_join",
|
||||
"terracotta_reset",
|
||||
"terracotta_get_platform_key",
|
||||
"terracotta_check_for_update",
|
||||
"terracotta_download",
|
||||
"terracotta_update",
|
||||
"terracotta_get_player_name",
|
||||
"terracotta_get_diagnostic_report",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"multiplayer",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"multiplayer_get_state",
|
||||
"multiplayer_get_nodes",
|
||||
"multiplayer_get_detected_ports",
|
||||
"multiplayer_download_hongshi",
|
||||
"multiplayer_switch_provider",
|
||||
"multiplayer_prepare_terracotta",
|
||||
"multiplayer_host",
|
||||
"multiplayer_join",
|
||||
"multiplayer_stop",
|
||||
"multiplayer_reset",
|
||||
"multiplayer_get_player_name",
|
||||
"multiplayer_open_hongshi_logs",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"servers",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"servers_list",
|
||||
"servers_get",
|
||||
"servers_create",
|
||||
"servers_update_settings",
|
||||
"servers_set_icon",
|
||||
"servers_delete",
|
||||
"servers_read_file",
|
||||
"servers_write_file",
|
||||
"servers_download_file",
|
||||
"servers_install_forge",
|
||||
"servers_install_modpack",
|
||||
"servers_start",
|
||||
"servers_send_command",
|
||||
"servers_send_console_input",
|
||||
"servers_resize_console",
|
||||
"servers_stop",
|
||||
"servers_kill",
|
||||
"servers_kill_port_process",
|
||||
"servers_port_process",
|
||||
"servers_get_log_buffer",
|
||||
"servers_clear_log",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
)
|
||||
.plugin(
|
||||
"mod-translation",
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"mod_translation_analyze",
|
||||
"mod_translation_translate",
|
||||
"mod_translation_cancel",
|
||||
"mod_translation_list_tasks",
|
||||
"mod_translation_get_task",
|
||||
"mod_translation_dismiss_task",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
),
|
||||
),
|
||||
)
|
||||
.expect("Failed to run tauri-build");
|
||||
}
|
||||
32
apps/app/capabilities/core.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"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-set-shadow",
|
||||
"core:window:allow-set-effects",
|
||||
"core:window:allow-set-cursor-grab",
|
||||
"core:window:allow-set-cursor-visible",
|
||||
"core:window:allow-start-dragging",
|
||||
"core:webview:allow-set-webview-zoom"
|
||||
]
|
||||
}
|
||||
179
apps/app/capabilities/plugins.json
Normal file
@ -0,0 +1,179 @@
|
||||
{
|
||||
"identifier": "plugins",
|
||||
"description": "",
|
||||
"local": true,
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"dialog:allow-open",
|
||||
"dialog:allow-confirm",
|
||||
"opener:default",
|
||||
"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",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [
|
||||
{
|
||||
"url": "https://modrinth.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://*.modrinth.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://*.nodes.modrinth.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://api.mclo.gs/*"
|
||||
},
|
||||
{
|
||||
"url": "https://fill.papermc.io/*"
|
||||
},
|
||||
{
|
||||
"url": "https://api.papermc.io/*"
|
||||
},
|
||||
{
|
||||
"url": "https://piston-meta.mojang.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://launchermeta.mojang.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://meta.fabricmc.net/*"
|
||||
},
|
||||
{
|
||||
"url": "https://files.minecraftforge.net/*"
|
||||
},
|
||||
{
|
||||
"url": "https://maven.minecraftforge.net/*"
|
||||
},
|
||||
{
|
||||
"url": "https://api.purpurmc.org/*"
|
||||
},
|
||||
{
|
||||
"url": "https://update.axlmc.org/*"
|
||||
},
|
||||
{
|
||||
"url": "http://localhost:8000/*"
|
||||
},
|
||||
{
|
||||
"url": "http://127.0.0.1:8000/*"
|
||||
},
|
||||
{
|
||||
"url": "http://*.taila228c5.ts.net/*"
|
||||
},
|
||||
{
|
||||
"url": "https://*.taila228c5.ts.net/*"
|
||||
},
|
||||
{
|
||||
"url": "https://mod.mcimirror.top/*"
|
||||
},
|
||||
{
|
||||
"url": "https://mod.tianpao.top/*"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dialog:allow-save",
|
||||
"fs:allow-read-dir",
|
||||
"fs:allow-read-file",
|
||||
"fs:allow-read-text-file",
|
||||
"fs:allow-write-file",
|
||||
"fs:allow-write-text-file",
|
||||
"fs:allow-create",
|
||||
"fs:allow-remove",
|
||||
"fs:allow-rename",
|
||||
"fs:allow-copy-file",
|
||||
"fs:allow-stat",
|
||||
"fs:allow-exists",
|
||||
"fs:allow-mkdir",
|
||||
"fs:allow-watch",
|
||||
{
|
||||
"identifier": "fs:scope",
|
||||
"allow": [
|
||||
{
|
||||
"path": "$APPDATA/backgrounds"
|
||||
},
|
||||
{
|
||||
"path": "$APPDATA/backgrounds/**"
|
||||
},
|
||||
{
|
||||
"path": "$APPDATA/profiles"
|
||||
},
|
||||
{
|
||||
"path": "$APPDATA/profiles/**"
|
||||
},
|
||||
{
|
||||
"path": "$APPCONFIG/profiles"
|
||||
},
|
||||
{
|
||||
"path": "$APPCONFIG/profiles/**"
|
||||
},
|
||||
{
|
||||
"path": "$CONFIG/profiles"
|
||||
},
|
||||
{
|
||||
"path": "$CONFIG/profiles/**"
|
||||
},
|
||||
{
|
||||
"path": "$APPDATA/servers"
|
||||
},
|
||||
{
|
||||
"path": "$APPDATA/servers/**"
|
||||
},
|
||||
{
|
||||
"path": "$APPCONFIG/servers"
|
||||
},
|
||||
{
|
||||
"path": "$APPCONFIG/servers/**"
|
||||
},
|
||||
{
|
||||
"path": "$CONFIG/servers"
|
||||
},
|
||||
{
|
||||
"path": "$CONFIG/servers/**"
|
||||
}
|
||||
]
|
||||
},
|
||||
"auth:default",
|
||||
"import:default",
|
||||
"jre:default",
|
||||
"logs:default",
|
||||
"metadata:default",
|
||||
"minecraft-skins:default",
|
||||
"mod-translation:default",
|
||||
"instance:default",
|
||||
"install:default",
|
||||
"process:default",
|
||||
"cache:default",
|
||||
"content-search:default",
|
||||
"content-favorites:default",
|
||||
"curseforge:default",
|
||||
"mcarchive:default",
|
||||
"datapacks:default",
|
||||
"files:default",
|
||||
"settings:default",
|
||||
"seed-map:default",
|
||||
"schematic-preview:default",
|
||||
"shortcuts:default",
|
||||
"tags:default",
|
||||
"ai:default",
|
||||
"translation:default",
|
||||
"storage:default",
|
||||
"system-accent:default",
|
||||
"utils:default",
|
||||
"worlds:default",
|
||||
"drop:default",
|
||||
"terracotta:default",
|
||||
"multiplayer:default",
|
||||
"servers:default",
|
||||
"planet-minecraft:default"
|
||||
]
|
||||
}
|
||||
7
apps/app/capabilities/updater.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"identifier": "updater",
|
||||
"description": "",
|
||||
"local": true,
|
||||
"windows": ["main"],
|
||||
"permissions": ["updater:default"]
|
||||
}
|
||||
BIN
apps/app/icons/128x128.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
apps/app/icons/128x128@2x.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
apps/app/icons/32x32.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
apps/app/icons/64x64.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
236
apps/app/icons/Axolotl.icon/Assets/AXL(fixed).svg
Normal file
@ -0,0 +1,236 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Generator: Adobe Illustrator 26.4.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg
|
||||
version="1.1"
|
||||
id="图层_1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 566.9 566.9"
|
||||
style="enable-background:new 0 0 566.9 566.9;"
|
||||
xml:space="preserve"
|
||||
>
|
||||
<style type="text/css">
|
||||
.st0 {
|
||||
fill: #e59cc3;
|
||||
}
|
||||
.st1 {
|
||||
fill: #f0579a;
|
||||
}
|
||||
.st2 {
|
||||
fill: #d982ad;
|
||||
}
|
||||
.st3 {
|
||||
fill: #fed5eb;
|
||||
}
|
||||
.st4 {
|
||||
fill: #febad8;
|
||||
}
|
||||
.st5 {
|
||||
fill: #df3177;
|
||||
}
|
||||
.st6 {
|
||||
fill: #d772a4;
|
||||
}
|
||||
.st7 {
|
||||
fill: #fcc1e0;
|
||||
}
|
||||
.st8 {
|
||||
fill: #fe4592;
|
||||
}
|
||||
.st9 {
|
||||
fill: #a12d72;
|
||||
}
|
||||
.st10 {
|
||||
fill: #d6518c;
|
||||
}
|
||||
.st11 {
|
||||
fill: #fe3d8c;
|
||||
}
|
||||
.st12 {
|
||||
fill: #fe71b1;
|
||||
}
|
||||
.st13 {
|
||||
fill: #e03178;
|
||||
}
|
||||
.st14 {
|
||||
fill: #fd71b2;
|
||||
}
|
||||
.st15 {
|
||||
fill: #feb8da;
|
||||
}
|
||||
.st16 {
|
||||
fill: #fed6eb;
|
||||
}
|
||||
.st17 {
|
||||
fill: #e79ec5;
|
||||
}
|
||||
.st18 {
|
||||
fill: #e7a1c6;
|
||||
}
|
||||
.st19 {
|
||||
fill: #43147c;
|
||||
}
|
||||
.st20 {
|
||||
fill: #fe60a4;
|
||||
}
|
||||
.st21 {
|
||||
fill: #e589bd;
|
||||
}
|
||||
.st22 {
|
||||
fill: #e65895;
|
||||
}
|
||||
.st23 {
|
||||
fill: #dc73a6;
|
||||
}
|
||||
.st24 {
|
||||
fill: none;
|
||||
stroke: #231815;
|
||||
stroke-miterlimit: 10;
|
||||
}
|
||||
.st25 {
|
||||
fill: #fe6daf;
|
||||
}
|
||||
.st26 {
|
||||
fill: #c64f8d;
|
||||
}
|
||||
</style>
|
||||
<polygon
|
||||
class="st0"
|
||||
points="497.8,176.1 415.1,168 413.9,182.5 389.9,182.5 389.9,195.2 359.8,195.2 359.8,220.5 389.9,220.5
|
||||
389.9,223.8 431,223.8 431,233.3 462,233.3 462,223.8 483.5,223.8 483.5,213.6 497.8,213.6 "
|
||||
/>
|
||||
<polygon class="st1" points="466.4,219.1 450.8,228.4 450.8,207.7 466.4,199.4 " />
|
||||
<polygon class="st2" points="417.6,203.4 399.9,213.3 399.9,192.1 417.6,183.1 " />
|
||||
<polygon class="st3" points="444.7,222.1 297.7,193.4 210.8,235.7 341.6,282.2 " />
|
||||
<polygon class="st4" points="296.6,260.4 279.7,251.7 369.4,207.4 387.6,211 " />
|
||||
<polygon class="st5" points="306.7,312.7 508,194.7 508,213.5 322.7,328.5 " />
|
||||
<polygon class="st5" points="247.4,245.2 453.4,140.6 453.4,165 263.4,260.9 " />
|
||||
<g>
|
||||
<polygon class="st6" points="333.5,431.4 308.5,429.6 325.2,374.9 341.9,374.9 " />
|
||||
<polygon class="st7" points="330.9,452.6 302,450.5 308.5,429.6 333.5,431.4 " />
|
||||
<polygon class="st8" points="352.3,454.1 330.9,452.6 333.5,431.4 353,432.6 " />
|
||||
<polygon class="st8" points="328.7,473.1 296.5,470.5 302.1,450.5 330.9,452.6 " />
|
||||
<polygon class="st8" points="302.1,450.5 280.8,449 289,428.4 308.5,429.6 " />
|
||||
<polygon class="st9" points="336.5,411.1 314.7,409.2 320,391.2 339.1,393.8 " />
|
||||
</g>
|
||||
<g>
|
||||
<polygon class="st6" points="108.1,399.8 86.3,388.3 141.8,344.1 155.8,353.3 " />
|
||||
<polygon class="st7" points="92.1,415.5 67.7,402.7 86.3,388.3 108.1,399.8 " />
|
||||
<polygon class="st8" points="110.4,424.4 92.1,415.5 108.1,399.8 123.8,408.3 " />
|
||||
<polygon class="st8" points="76.4,430.8 49.6,416.8 67.7,402.7 92.1,415.5 " />
|
||||
<polygon class="st8" points="67.6,402.7 52.1,394.2 72.1,380 86.3,388.3 " />
|
||||
</g>
|
||||
<polygon class="st10" points="314.4,382.5 341.9,382.5 341.9,395.5 313.1,391.1 " />
|
||||
<g>
|
||||
<polygon class="st11" points="83,311.8 64,308.9 63.2,287.1 82.3,290 " />
|
||||
<polygon class="st11" points="102.8,336.4 83.7,333.5 83,311.8 102,314.7 " />
|
||||
<polygon class="st11" points="122.5,361 103.5,358.1 102.8,336.4 121.8,339.3 " />
|
||||
<polygon class="st12" points="83.7,333.5 64.6,330.7 64,308.9 83,311.8 " />
|
||||
<polygon class="st12" points="103.5,358.2 84.5,355.4 83.7,333.5 102.8,336.4 " />
|
||||
<polygon class="st13" points="90.3,309.3 83,311.8 82.3,290 89.6,287.1 " />
|
||||
<polygon class="st14" points="82.3,290 63.2,287.1 70.5,284.7 89.6,287.1 " />
|
||||
<polygon class="st13" points="110,333.9 102.8,336.4 102,314.7 109.3,311.8 " />
|
||||
<polygon class="st14" points="102,314.7 83,311.8 90.3,309.3 109.3,311.8 " />
|
||||
<polygon class="st13" points="129.8,357.5 122.5,361 121.8,339.3 129.2,336.5 " />
|
||||
<polygon class="st14" points="121.8,339.3 102.8,336.4 110,333.9 129.2,336.5 " />
|
||||
</g>
|
||||
<g>
|
||||
<polygon class="st11" points="111.2,220.8 88.7,216.7 88.7,190.7 111.2,195 " />
|
||||
<polygon class="st11" points="133.8,250.9 111.2,246.8 111.2,220.8 133.8,225.1 " />
|
||||
<polygon class="st11" points="156.3,281 133.8,276.9 133.8,250.9 156.3,255.2 " />
|
||||
<polygon class="st12" points="111.2,246.8 88.7,242.7 88.7,216.7 111.2,220.8 " />
|
||||
<polygon class="st12" points="133.8,276.9 111.2,272.8 111.2,246.8 133.8,250.9 " />
|
||||
<polygon class="st13" points="120,218.3 111.2,220.8 111.2,195 120.1,191.9 " />
|
||||
<polygon class="st14" points="111.2,195 88.7,190.7 97.4,188.2 120.1,191.9 " />
|
||||
<polygon class="st13" points="142.5,248.3 133.8,250.9 133.8,225.1 142.6,222 " />
|
||||
<polygon class="st14" points="133.8,225.1 111.2,220.9 120,218.3 142.6,222 " />
|
||||
<polygon class="st13" points="165.1,277.1 156.3,281 156.3,255.2 165.1,252 " />
|
||||
<polygon class="st14" points="156.3,255.2 133.8,250.9 142.5,248.3 165.1,252 " />
|
||||
</g>
|
||||
<polyline class="st15" points="286,293.4 285.1,424 104.4,390.8 101.6,265.3 286,293.4 " />
|
||||
<polyline class="st16" points="286,293.4 101.6,265.3 171.2,230.7 341.4,252.2 286,293.4 " />
|
||||
<polygon class="st17" points="341.4,252.2 342.3,379.3 285.1,424 286,293.4 " />
|
||||
<polygon class="st18" points="341.9,395.5 446.8,323.6 444.7,222.1 341.6,282.2 " />
|
||||
<polygon class="st19" points="131,353.2 103.4,348.2 102.7,316.9 130.4,320.9 " />
|
||||
<polygon class="st20" points="215.1,365.5 162.6,357.8 162.6,327 214.8,335.3 " />
|
||||
<polygon class="st19" points="285.4,376.8 254.9,371.3 254.1,339.9 285.6,344.5 " />
|
||||
<rect x="341.6" y="282.2" class="st21" width="19.5" height="89.8" />
|
||||
<polygon class="st6" points="338.6,308.3 326.1,319.7 325.8,301 338.6,301 " />
|
||||
<g>
|
||||
<polygon class="st11" points="349.4,310.1 325.8,307.2 325.8,280 349.4,282.8 " />
|
||||
<polygon class="st11" points="373,285.9 349.4,282.9 349.4,255.7 373,258.6 " />
|
||||
<polygon class="st11" points="396.6,261.6 373,258.6 373,231.5 396.6,234.3 " />
|
||||
<polygon class="st12" points="373,312.7 349.4,310 349.4,282.8 373,285.9 " />
|
||||
<polygon class="st14" points="349.4,282.8 325.8,280 334,276.6 349.4,278.3 " />
|
||||
<polygon class="st14" points="373,258.6 349.4,255.7 357.6,252.4 373,254 " />
|
||||
<polygon class="st14" points="396.6,234.6 373,231.7 381.2,228.3 405,230.8 " />
|
||||
<polygon class="st13" points="405.1,258.8 396.6,261.4 396.6,234.6 405,230.8 " />
|
||||
<polygon class="st22" points="405.1,285.6 396.6,288.2 396.6,261.4 405.1,258.8 " />
|
||||
<polygon class="st22" points="381.5,310.1 373,312.8 373,285.9 381.5,283.3 " />
|
||||
<polygon class="st12" points="396.6,288.2 373,285.9 373,258.4 396.6,261.4 " />
|
||||
</g>
|
||||
<polygon class="st23" points="342,380.6 285.1,424 285.1,397.8 341.4,356.7 " />
|
||||
<polygon class="st12" points="255.1,418.5 285.1,424 285.1,397.8 254.7,393 " />
|
||||
<polygon class="st12" points="104.4,390.8 131.8,395.8 131.1,368.8 103.8,364.7 " />
|
||||
<g>
|
||||
<polygon class="st9" points="453.9,333.4 439.6,348.1 412.4,338.7 428,325.4 " />
|
||||
<polygon class="st6" points="472.9,339.1 459.4,355 439.6,348.1 453.9,333.4 " />
|
||||
<polygon class="st7" points="480,361.6 459.4,355 472.9,339.1 491.4,344.2 " />
|
||||
<polygon class="st8" points="469,378 447.3,369.9 459.4,355 480,361.6 " />
|
||||
<polygon class="st8" points="491.4,344.2 472.9,339.1 481.8,328.6 498.9,333.1 " />
|
||||
<polygon class="st8" points="496.5,367.3 480,361.6 491.4,344.2 507.1,348.8 " />
|
||||
</g>
|
||||
<path class="st24" d="M517.3,292.3" />
|
||||
<path class="st24" d="M421.9,383.6" />
|
||||
<polygon class="st15" points="323.2,265.6 149.6,241.4 171.2,230.6 341.5,252.3 " />
|
||||
<g>
|
||||
<polygon class="st11" points="169.2,182.5 146.7,178.4 146.7,152.4 169.2,156.7 " />
|
||||
<polygon class="st11" points="191.7,212.6 169.2,208.5 169.2,182.5 191.7,186.8 " />
|
||||
<polygon class="st11" points="214.3,242.7 191.7,238.6 191.7,212.6 214.3,216.8 " />
|
||||
<polygon class="st12" points="169.2,208.5 146.7,204.4 146.7,178.4 169.2,182.5 " />
|
||||
<polygon class="st12" points="191.7,238.6 169.2,234.5 169.2,208.5 191.7,212.6 " />
|
||||
<polygon class="st13" points="178,180 169.2,182.5 169.2,156.7 178,153.6 " />
|
||||
<polygon class="st14" points="169.2,156.7 146.7,152.4 155.4,149.9 178,153.6 " />
|
||||
<polygon class="st13" points="200.5,210 191.7,212.6 191.7,186.8 200.6,183.7 " />
|
||||
<polygon class="st14" points="191.7,186.8 169.2,182.5 178,180 200.6,183.7 " />
|
||||
<polygon class="st13" points="223.1,238.8 214.3,242.7 214.3,216.8 223.1,213.7 " />
|
||||
<polygon class="st14" points="214.3,216.8 191.7,212.6 200.5,210 223.1,213.7 " />
|
||||
</g>
|
||||
<polygon class="st15" points="161.2,252.9 134.3,249 150,241.2 174.6,244.8 " />
|
||||
<polygon class="st15" points="312.1,274 282.2,270.2 295.4,261.2 325.2,264.4 " />
|
||||
<polygon class="st23" points="446.8,323.6 389.9,367 389.9,340.8 446.2,299.7 " />
|
||||
<g>
|
||||
<polygon class="st11" points="344.3,397.7 323.1,395 323.1,370.7 344.3,373.2 " />
|
||||
<polygon class="st11" points="365.5,376 344.3,373.3 344.3,349 365.5,351.5 " />
|
||||
<polygon class="st11" points="386.6,354.2 365.5,351.6 365.5,327.2 386.6,329.8 " />
|
||||
<polygon class="st12" points="365.5,400 344.3,397.6 344.3,373.2 365.5,376 " />
|
||||
<polygon class="st14" points="344.3,373.2 323.1,370.7 330.5,367.7 344.3,369.1 " />
|
||||
<polygon class="st14" points="365.5,351.6 344.3,349 351.7,346 365.5,347.4 " />
|
||||
<polygon class="st14" points="386.6,330 365.5,327.4 372.8,324.4 394.1,326.7 " />
|
||||
<polygon class="st13" points="394.2,351.7 386.6,354.1 386.6,330 394.1,326.7 " />
|
||||
<polygon class="st22" points="394.2,375.7 386.6,378.1 386.6,354 394.2,351.7 " />
|
||||
<polygon class="st22" points="373.1,397.7 365.5,400.1 365.5,376 373.1,373.7 " />
|
||||
<polygon class="st12" points="386.6,378.1 365.5,376 365.5,351.3 386.6,354.1 " />
|
||||
</g>
|
||||
<polygon class="st25" points="453.4,140.9 255.5,241.2 246.9,240.3 448.1,140.3 " />
|
||||
<g>
|
||||
<polygon class="st11" points="293.3,254 269.7,251 269.7,223.8 293.3,226.7 " />
|
||||
<polygon class="st11" points="316.9,229.7 293.3,226.8 293.3,199.6 316.9,202.4 " />
|
||||
<polygon class="st11" points="340.5,205.4 316.9,202.5 316.9,175.3 340.5,178.2 " />
|
||||
<polygon class="st12" points="316.9,256.5 293.3,253.9 293.3,226.7 316.9,229.7 " />
|
||||
<polygon class="st14" points="293.3,226.7 269.7,223.8 277.9,220.5 293.3,222.1 " />
|
||||
<polygon class="st14" points="316.9,202.5 293.3,199.6 301.5,196.3 316.9,197.9 " />
|
||||
<polygon class="st14" points="340.5,178.4 316.9,175.5 325.1,172.2 348.9,174.7 " />
|
||||
<polygon class="st13" points="349,202.6 340.5,205.3 340.5,178.4 348.9,174.7 " />
|
||||
<polygon class="st22" points="349,229.4 340.5,232.1 340.5,205.2 349,202.6 " />
|
||||
<polygon class="st22" points="325.4,254 316.9,256.6 316.9,229.8 325.4,227.2 " />
|
||||
<polygon class="st12" points="340.5,232.1 316.9,229.7 316.9,202.2 340.5,205.3 " />
|
||||
</g>
|
||||
<polygon class="st5" points="479.8,171.7 438.3,193.2 438.3,172.2 479.8,151.2 " />
|
||||
<polygon class="st5" points="508,178 466.4,199.4 466.4,178.4 508,157.4 " />
|
||||
<polygon class="st5" points="508,196.5 494.3,204.6 494.3,185 508,178 " />
|
||||
<polygon class="st21" points="433.9,308.7 415.8,321.9 415.6,297.4 433.9,284.9 " />
|
||||
<polygon class="st26" points="433.9,333.5 415.8,347.3 415.8,321.9 433.9,308.7 " />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
44
apps/app/icons/Axolotl.icon/icon.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"fill": {
|
||||
"linear-gradient": [
|
||||
"display-p3:1.00000,1.00000,1.00000,1.00000",
|
||||
"display-p3:0.99608,0.83922,0.92157,1.00000"
|
||||
],
|
||||
"orientation": {
|
||||
"start": {
|
||||
"x": 0.5,
|
||||
"y": 1
|
||||
},
|
||||
"stop": {
|
||||
"x": 0.5,
|
||||
"y": 0.3
|
||||
}
|
||||
}
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"layers": [
|
||||
{
|
||||
"glass": false,
|
||||
"image-name": "AXL(fixed).svg",
|
||||
"name": "AXL(fixed)",
|
||||
"position": {
|
||||
"scale": 1.6,
|
||||
"translation-in-points": [0, -21]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow": {
|
||||
"kind": "neutral",
|
||||
"opacity": 0.5
|
||||
},
|
||||
"translucency": {
|
||||
"enabled": true,
|
||||
"value": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms": {
|
||||
"squares": ["macOS"]
|
||||
}
|
||||
}
|
||||
BIN
apps/app/icons/AxolotlAssets.car
Normal file
BIN
apps/app/icons/Square107x107Logo.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
apps/app/icons/Square142x142Logo.png
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
apps/app/icons/Square150x150Logo.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
apps/app/icons/Square284x284Logo.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
apps/app/icons/Square30x30Logo.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
apps/app/icons/Square310x310Logo.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
apps/app/icons/Square44x44Logo.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
apps/app/icons/Square71x71Logo.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
apps/app/icons/Square89x89Logo.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
apps/app/icons/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
apps/app/icons/android/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
apps/app/icons/android/mipmap-hdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
apps/app/icons/android/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
apps/app/icons/android/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
apps/app/icons/android/mipmap-mdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
apps/app/icons/android/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
apps/app/icons/android/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
apps/app/icons/android/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
apps/app/icons/android/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
apps/app/icons/android/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
apps/app/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
apps/app/icons/android/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
apps/app/icons/android/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
apps/app/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
apps/app/icons/android/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
230
apps/app/icons/axolotl-macos.svg
Normal file
@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
||||
<rect x="100" y="100" width="824" height="824" rx="185" fill="#FFFFFF" />
|
||||
<g transform="translate(100 100) scale(1.45351914)">
|
||||
<style type="text/css">
|
||||
.st0 {
|
||||
fill: #e59cc3;
|
||||
}
|
||||
.st1 {
|
||||
fill: #f0579a;
|
||||
}
|
||||
.st2 {
|
||||
fill: #d982ad;
|
||||
}
|
||||
.st3 {
|
||||
fill: #fed5eb;
|
||||
}
|
||||
.st4 {
|
||||
fill: #febad8;
|
||||
}
|
||||
.st5 {
|
||||
fill: #df3177;
|
||||
}
|
||||
.st6 {
|
||||
fill: #d772a4;
|
||||
}
|
||||
.st7 {
|
||||
fill: #fcc1e0;
|
||||
}
|
||||
.st8 {
|
||||
fill: #fe4592;
|
||||
}
|
||||
.st9 {
|
||||
fill: #a12d72;
|
||||
}
|
||||
.st10 {
|
||||
fill: #d6518c;
|
||||
}
|
||||
.st11 {
|
||||
fill: #fe3d8c;
|
||||
}
|
||||
.st12 {
|
||||
fill: #fe71b1;
|
||||
}
|
||||
.st13 {
|
||||
fill: #e03178;
|
||||
}
|
||||
.st14 {
|
||||
fill: #fd71b2;
|
||||
}
|
||||
.st15 {
|
||||
fill: #feb8da;
|
||||
}
|
||||
.st16 {
|
||||
fill: #fed6eb;
|
||||
}
|
||||
.st17 {
|
||||
fill: #e79ec5;
|
||||
}
|
||||
.st18 {
|
||||
fill: #e7a1c6;
|
||||
}
|
||||
.st19 {
|
||||
fill: #43147c;
|
||||
}
|
||||
.st20 {
|
||||
fill: #fe60a4;
|
||||
}
|
||||
.st21 {
|
||||
fill: #e589bd;
|
||||
}
|
||||
.st22 {
|
||||
fill: #e65895;
|
||||
}
|
||||
.st23 {
|
||||
fill: #dc73a6;
|
||||
}
|
||||
.st24 {
|
||||
fill: none;
|
||||
stroke: #231815;
|
||||
stroke-miterlimit: 10;
|
||||
}
|
||||
.st25 {
|
||||
fill: #fe6daf;
|
||||
}
|
||||
.st26 {
|
||||
fill: #c64f8d;
|
||||
}
|
||||
</style>
|
||||
<g>
|
||||
<polygon
|
||||
class="st0"
|
||||
points="497.8,176.1 415.1,168 413.9,182.5 389.9,182.5 389.9,195.2 359.8,195.2 359.8,220.5 389.9,220.5
|
||||
389.9,223.8 431,223.8 431,233.3 462,233.3 462,223.8 483.5,223.8 483.5,213.6 497.8,213.6 "
|
||||
/>
|
||||
<polygon class="st1" points="466.4,219.1 450.8,228.4 450.8,207.7 466.4,199.4 " />
|
||||
<polygon class="st2" points="417.6,203.4 399.9,213.3 399.9,192.1 417.6,183.1 " />
|
||||
<polygon class="st3" points="444.7,222.1 297.7,193.4 210.8,235.7 341.6,282.2 " />
|
||||
<polygon class="st4" points="296.6,260.4 279.7,251.7 369.4,207.4 387.6,211 " />
|
||||
<polygon class="st5" points="306.7,312.7 508,194.7 508,213.5 322.7,328.5 " />
|
||||
<polygon class="st5" points="247.4,245.2 453.4,140.6 453.4,165 263.4,260.9 " />
|
||||
<g>
|
||||
<polygon class="st6" points="333.5,431.4 308.5,429.6 325.2,374.9 341.9,374.9 " />
|
||||
<polygon class="st7" points="330.9,452.6 302,450.5 308.5,429.6 333.5,431.4 " />
|
||||
<polygon class="st8" points="352.3,454.1 330.9,452.6 333.5,431.4 353,432.6 " />
|
||||
<polygon class="st8" points="328.7,473.1 296.5,470.5 302.1,450.5 330.9,452.6 " />
|
||||
<polygon class="st8" points="302.1,450.5 280.8,449 289,428.4 308.5,429.6 " />
|
||||
<polygon class="st9" points="336.5,411.1 314.7,409.2 320,391.2 339.1,393.8 " />
|
||||
</g>
|
||||
<g>
|
||||
<polygon class="st6" points="108.1,399.8 86.3,388.3 141.8,344.1 155.8,353.3 " />
|
||||
<polygon class="st7" points="92.1,415.5 67.7,402.7 86.3,388.3 108.1,399.8 " />
|
||||
<polygon class="st8" points="110.4,424.4 92.1,415.5 108.1,399.8 123.8,408.3 " />
|
||||
<polygon class="st8" points="76.4,430.8 49.6,416.8 67.7,402.7 92.1,415.5 " />
|
||||
<polygon class="st8" points="67.6,402.7 52.1,394.2 72.1,380 86.3,388.3 " />
|
||||
</g>
|
||||
<polygon class="st10" points="314.4,382.5 341.9,382.5 341.9,395.5 313.1,391.1 " />
|
||||
<g>
|
||||
<polygon class="st11" points="89.5,308.4 66.9,305 66,279 88.7,282.5 " />
|
||||
<polygon class="st11" points="113.1,337.7 90.4,334.3 89.5,308.4 112.2,311.9 " />
|
||||
<polygon class="st11" points="136.6,367 113.9,363.6 113.1,337.7 135.7,341.2 " />
|
||||
<polygon class="st12" points="90.4,334.3 67.7,331 66.9,305 89.5,308.4 " />
|
||||
<polygon class="st12" points="113.9,363.7 91.3,360.3 90.4,334.3 113.1,337.7 " />
|
||||
<polygon class="st13" points="98.2,305.5 89.5,308.4 88.7,282.5 97.4,279.1 " />
|
||||
<polygon class="st14" points="88.7,282.5 66,279 74.7,276.2 97.4,279.1 " />
|
||||
<polygon class="st13" points="121.7,334.8 113.1,337.7 112.2,311.9 120.9,308.5 " />
|
||||
<polygon class="st14" points="112.2,311.9 89.5,308.4 98.2,305.5 120.9,308.5 " />
|
||||
<polygon class="st13" points="145.2,362.8 136.6,367 135.7,341.2 144.5,337.8 " />
|
||||
<polygon class="st14" points="135.7,341.2 113.1,337.7 121.7,334.8 144.5,337.8 " />
|
||||
</g>
|
||||
<g>
|
||||
<polygon class="st11" points="111.2,220.8 88.7,216.7 88.7,190.7 111.2,195 " />
|
||||
<polygon class="st11" points="133.8,250.9 111.2,246.8 111.2,220.8 133.8,225.1 " />
|
||||
<polygon class="st11" points="156.3,281 133.8,276.9 133.8,250.9 156.3,255.2 " />
|
||||
<polygon class="st12" points="111.2,246.8 88.7,242.7 88.7,216.7 111.2,220.8 " />
|
||||
<polygon class="st12" points="133.8,276.9 111.2,272.8 111.2,246.8 133.8,250.9 " />
|
||||
<polygon class="st13" points="120,218.3 111.2,220.8 111.2,195 120.1,191.9 " />
|
||||
<polygon class="st14" points="111.2,195 88.7,190.7 97.4,188.2 120.1,191.9 " />
|
||||
<polygon class="st13" points="142.5,248.3 133.8,250.9 133.8,225.1 142.6,222 " />
|
||||
<polygon class="st14" points="133.8,225.1 111.2,220.9 120,218.3 142.6,222 " />
|
||||
<polygon class="st13" points="165.1,277.1 156.3,281 156.3,255.2 165.1,252 " />
|
||||
<polygon class="st14" points="156.3,255.2 133.8,250.9 142.5,248.3 165.1,252 " />
|
||||
</g>
|
||||
<polyline class="st15" points="286,293.4 285.1,424 104.4,390.8 101.6,265.3 286,293.4 " />
|
||||
<polyline class="st16" points="286,293.4 101.6,265.3 171.2,230.7 341.4,252.2 286,293.4 " />
|
||||
<polygon class="st17" points="341.4,252.2 342.3,379.3 285.1,424 286,293.4 " />
|
||||
<polygon class="st18" points="341.9,395.5 446.8,323.6 444.7,222.1 341.6,282.2 " />
|
||||
<polygon class="st19" points="131,353.2 103.4,348.2 102.7,316.9 130.4,320.9 " />
|
||||
<polygon class="st20" points="215.1,365.5 162.6,357.8 162.6,327 214.8,335.3 " />
|
||||
<polygon class="st19" points="285.4,376.8 254.9,371.3 254.1,339.9 285.6,344.5 " />
|
||||
<rect x="341.6" y="282.2" class="st21" width="19.5" height="89.8" />
|
||||
<polygon class="st6" points="338.6,308.3 326.1,319.7 325.8,301 338.6,301 " />
|
||||
<g>
|
||||
<polygon class="st11" points="349.4,310.1 325.8,307.2 325.8,280 349.4,282.8 " />
|
||||
<polygon class="st11" points="373,285.9 349.4,282.9 349.4,255.7 373,258.6 " />
|
||||
<polygon class="st11" points="396.6,261.6 373,258.6 373,231.5 396.6,234.3 " />
|
||||
<polygon class="st12" points="373,312.7 349.4,310 349.4,282.8 373,285.9 " />
|
||||
<polygon class="st14" points="349.4,282.8 325.8,280 334,276.6 349.4,278.3 " />
|
||||
<polygon class="st14" points="373,258.6 349.4,255.7 357.6,252.4 373,254 " />
|
||||
<polygon class="st14" points="396.6,234.6 373,231.7 381.2,228.3 405,230.8 " />
|
||||
<polygon class="st13" points="405.1,258.8 396.6,261.4 396.6,234.6 405,230.8 " />
|
||||
<polygon class="st22" points="405.1,285.6 396.6,288.2 396.6,261.4 405.1,258.8 " />
|
||||
<polygon class="st22" points="381.5,310.1 373,312.8 373,285.9 381.5,283.3 " />
|
||||
<polygon class="st12" points="396.6,288.2 373,285.9 373,258.4 396.6,261.4 " />
|
||||
</g>
|
||||
<polygon class="st23" points="342,380.6 285.1,424 285.1,397.8 341.4,356.7 " />
|
||||
<polygon class="st12" points="255.1,418.5 285.1,424 285.1,397.8 254.7,393 " />
|
||||
<polygon class="st12" points="104.4,390.8 131.8,395.8 131.1,368.8 103.8,364.7 " />
|
||||
<g>
|
||||
<polygon class="st9" points="453.9,333.4 439.6,348.1 412.4,338.7 428,325.4 " />
|
||||
<polygon class="st6" points="472.9,339.1 459.4,355 439.6,348.1 453.9,333.4 " />
|
||||
<polygon class="st7" points="480,361.6 459.4,355 472.9,339.1 491.4,344.2 " />
|
||||
<polygon class="st8" points="469,378 447.3,369.9 459.4,355 480,361.6 " />
|
||||
<polygon class="st8" points="491.4,344.2 472.9,339.1 481.8,328.6 498.9,333.1 " />
|
||||
<polygon class="st8" points="496.5,367.3 480,361.6 491.4,344.2 507.1,348.8 " />
|
||||
</g>
|
||||
<path class="st24" d="M517.3,292.3" />
|
||||
<path class="st24" d="M421.9,383.6" />
|
||||
<polygon class="st15" points="323.2,265.6 149.6,241.4 171.2,230.6 341.5,252.3 " />
|
||||
<g>
|
||||
<polygon class="st11" points="169.2,182.5 146.7,178.4 146.7,152.4 169.2,156.7 " />
|
||||
<polygon class="st11" points="191.7,212.6 169.2,208.5 169.2,182.5 191.7,186.8 " />
|
||||
<polygon class="st11" points="214.3,242.7 191.7,238.6 191.7,212.6 214.3,216.8 " />
|
||||
<polygon class="st12" points="169.2,208.5 146.7,204.4 146.7,178.4 169.2,182.5 " />
|
||||
<polygon class="st12" points="191.7,238.6 169.2,234.5 169.2,208.5 191.7,212.6 " />
|
||||
<polygon class="st13" points="178,180 169.2,182.5 169.2,156.7 178,153.6 " />
|
||||
<polygon class="st14" points="169.2,156.7 146.7,152.4 155.4,149.9 178,153.6 " />
|
||||
<polygon class="st13" points="200.5,210 191.7,212.6 191.7,186.8 200.6,183.7 " />
|
||||
<polygon class="st14" points="191.7,186.8 169.2,182.5 178,180 200.6,183.7 " />
|
||||
<polygon class="st13" points="223.1,238.8 214.3,242.7 214.3,216.8 223.1,213.7 " />
|
||||
<polygon class="st14" points="214.3,216.8 191.7,212.6 200.5,210 223.1,213.7 " />
|
||||
</g>
|
||||
<polygon class="st15" points="161.2,252.9 134.3,249 150,241.2 174.6,244.8 " />
|
||||
<polygon class="st15" points="312.1,274 282.2,270.2 295.4,261.2 325.2,264.4 " />
|
||||
<polygon class="st23" points="446.8,323.6 389.9,367 389.9,340.8 446.2,299.7 " />
|
||||
<g>
|
||||
<polygon class="st11" points="344.3,397.7 323.1,395 323.1,370.7 344.3,373.2 " />
|
||||
<polygon class="st11" points="365.5,376 344.3,373.3 344.3,349 365.5,351.5 " />
|
||||
<polygon class="st11" points="386.6,354.2 365.5,351.6 365.5,327.2 386.6,329.8 " />
|
||||
<polygon class="st12" points="365.5,400 344.3,397.6 344.3,373.2 365.5,376 " />
|
||||
<polygon class="st14" points="344.3,373.2 323.1,370.7 330.5,367.7 344.3,369.1 " />
|
||||
<polygon class="st14" points="365.5,351.6 344.3,349 351.7,346 365.5,347.4 " />
|
||||
<polygon class="st14" points="386.6,330 365.5,327.4 372.8,324.4 394.1,326.7 " />
|
||||
<polygon class="st13" points="394.2,351.7 386.6,354.1 386.6,330 394.1,326.7 " />
|
||||
<polygon class="st22" points="394.2,375.7 386.6,378.1 386.6,354 394.2,351.7 " />
|
||||
<polygon class="st22" points="373.1,397.7 365.5,400.1 365.5,376 373.1,373.7 " />
|
||||
<polygon class="st12" points="386.6,378.1 365.5,376 365.5,351.3 386.6,354.1 " />
|
||||
</g>
|
||||
<polygon class="st25" points="453.4,140.9 255.5,241.2 246.9,240.3 448.1,140.3 " />
|
||||
<g>
|
||||
<polygon class="st11" points="293.3,254 269.7,251 269.7,223.8 293.3,226.7 " />
|
||||
<polygon class="st11" points="316.9,229.7 293.3,226.8 293.3,199.6 316.9,202.4 " />
|
||||
<polygon class="st11" points="340.5,205.4 316.9,202.5 316.9,175.3 340.5,178.2 " />
|
||||
<polygon class="st12" points="316.9,256.5 293.3,253.9 293.3,226.7 316.9,229.7 " />
|
||||
<polygon class="st14" points="293.3,226.7 269.7,223.8 277.9,220.5 293.3,222.1 " />
|
||||
<polygon class="st14" points="316.9,202.5 293.3,199.6 301.5,196.3 316.9,197.9 " />
|
||||
<polygon class="st14" points="340.5,178.4 316.9,175.5 325.1,172.2 348.9,174.7 " />
|
||||
<polygon class="st13" points="349,202.6 340.5,205.3 340.5,178.4 348.9,174.7 " />
|
||||
<polygon class="st22" points="349,229.4 340.5,232.1 340.5,205.2 349,202.6 " />
|
||||
<polygon class="st22" points="325.4,254 316.9,256.6 316.9,229.8 325.4,227.2 " />
|
||||
<polygon class="st12" points="340.5,232.1 316.9,229.7 316.9,202.2 340.5,205.3 " />
|
||||
</g>
|
||||
<polygon class="st5" points="479.8,171.7 438.3,193.2 438.3,172.2 479.8,151.2 " />
|
||||
<polygon class="st5" points="508,178 466.4,199.4 466.4,178.4 508,157.4 " />
|
||||
<polygon class="st5" points="508,196.5 494.3,204.6 494.3,185 508,178 " />
|
||||
<polygon class="st21" points="433.9,308.7 415.8,321.9 415.6,297.4 433.9,284.9 " />
|
||||
<polygon class="st26" points="433.9,333.5 415.8,347.3 415.8,321.9 433.9,308.7 " />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 11 KiB |
BIN
apps/app/icons/favicon.ico
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
apps/app/icons/icon.icns
Normal file
BIN
apps/app/icons/icon.ico
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
apps/app/icons/icon.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
apps/app/icons/ios/AppIcon-20x20@1x.png
Normal file
|
After Width: | Height: | Size: 665 B |
BIN
apps/app/icons/ios/AppIcon-20x20@2x-1.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
apps/app/icons/ios/AppIcon-20x20@2x.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
apps/app/icons/ios/AppIcon-20x20@3x.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
apps/app/icons/ios/AppIcon-29x29@1x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
apps/app/icons/ios/AppIcon-29x29@2x-1.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
apps/app/icons/ios/AppIcon-29x29@2x.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
apps/app/icons/ios/AppIcon-29x29@3x.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
apps/app/icons/ios/AppIcon-40x40@1x.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
apps/app/icons/ios/AppIcon-40x40@2x-1.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
apps/app/icons/ios/AppIcon-40x40@2x.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
apps/app/icons/ios/AppIcon-40x40@3x.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
apps/app/icons/ios/AppIcon-512@2x.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
apps/app/icons/ios/AppIcon-60x60@2x.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
apps/app/icons/ios/AppIcon-60x60@3x.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
apps/app/icons/ios/AppIcon-76x76@1x.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
apps/app/icons/ios/AppIcon-76x76@2x.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
apps/app/icons/ios/AppIcon-83.5x83.5@2x.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
apps/app/nsis/assets/header.bmp
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
apps/app/nsis/assets/sidebar.bmp
Normal file
|
After Width: | Height: | Size: 151 KiB |
165
apps/app/nsis/hooks.nsi
Normal file
@ -0,0 +1,165 @@
|
||||
; https://nsis.sourceforge.io/ShellExecWait
|
||||
!define AXL_INSTALLER_UI_PATH "${__FILEDIR__}\..\..\..\target\release\axolotl-installer-ui.exe"
|
||||
|
||||
!macro ShellExecWait verb app param workdir show exitoutvar ;only app and show must be != "", every thing else is optional
|
||||
#define SEE_MASK_NOCLOSEPROCESS 0x40
|
||||
System::Store S
|
||||
!if "${NSIS_PTR_SIZE}" > 4
|
||||
!define /ReDef /math SYSSIZEOF_SHELLEXECUTEINFO 14 * ${NSIS_PTR_SIZE}
|
||||
!else ifndef SYSSIZEOF_SHELLEXECUTEINFO
|
||||
!define SYSSIZEOF_SHELLEXECUTEINFO 60
|
||||
!endif
|
||||
System::Call '*(&i${SYSSIZEOF_SHELLEXECUTEINFO})i.r0'
|
||||
System::Call '*$0(i ${SYSSIZEOF_SHELLEXECUTEINFO},i 0x40,p $hwndparent,t "${verb}",t $\'${app}$\',t $\'${param}$\',t "${workdir}",i ${show})p.r0'
|
||||
System::Call 'shell32::ShellExecuteEx(t)(pr0)i.r1 ?e' ; (t) to trigger A/W selection
|
||||
${If} $1 <> 0
|
||||
System::Call '*$0(is,i,p,p,p,p,p,p,p,p,p,p,p,p,p.r1)' ;stack value not really used, just a fancy pop ;)
|
||||
System::Call 'kernel32::WaitForSingleObject(pr1,i-1)'
|
||||
System::Call 'kernel32::GetExitCodeProcess(pr1,*i.s)'
|
||||
System::Call 'kernel32::CloseHandle(pr1)'
|
||||
${EndIf}
|
||||
System::Free $0
|
||||
!if "${exitoutvar}" == ""
|
||||
pop $0
|
||||
!endif
|
||||
System::Store L
|
||||
!if "${exitoutvar}" != ""
|
||||
pop ${exitoutvar}
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
; --------------------------------------------------------------------------------
|
||||
|
||||
Var /GLOBAL OldInstallDir
|
||||
|
||||
!macro NSIS_HOOK_PREINSTALL
|
||||
; The updater is normally launched silently by the Tauri updater plugin.
|
||||
; A current-user install can still target a protected directory, so elevate
|
||||
; only the in-place update process instead of requiring UAC for first-time
|
||||
; current-user installs.
|
||||
${If} $UpdateMode == 1
|
||||
${GetOptions} $CMDLINE "/ELEVATED" $0
|
||||
${If} ${Errors}
|
||||
UserInfo::GetAccountType
|
||||
Pop $0
|
||||
${If} $0 != "Admin"
|
||||
ExecShell "runas" "$EXEPATH" '$CMDLINE /ELEVATED'
|
||||
Abort
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
; The updater already stops the running process and passes /UPDATE. Do not
|
||||
; run the legacy uninstall/migration path during an in-place update, since
|
||||
; it can resolve a different installation from the registry and relaunch
|
||||
; the old executable after the new files are installed.
|
||||
${If} $UpdateMode <> 1
|
||||
SetShellVarContext all
|
||||
${If} ${FileExists} "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||
UserInfo::GetAccountType
|
||||
Pop $0
|
||||
${If} $0 != "Admin"
|
||||
MessageBox MB_ICONINFORMATION|MB_OK "An old installation of the Axolotl Launcher was detected that requires administrator permission to update from. You will be prompted with an admin prompt shortly."
|
||||
${EndIf}
|
||||
|
||||
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
|
||||
|
||||
ReadRegStr $OldInstallDir SHCTX "${UNINSTKEY}" "InstallLocation"
|
||||
StrCpy $OldInstallDir $OldInstallDir "" 1
|
||||
StrCpy $OldInstallDir $OldInstallDir -1 ""
|
||||
|
||||
DetailPrint "Executing $R1"
|
||||
!insertmacro ShellExecWait "runas" '$R1' '/P _?=$4' "" ${SW_SHOW} $3
|
||||
${If} $3 <> 0
|
||||
SetErrorLevel $3
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK "Failed to uninstall old global installation"
|
||||
Abort
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
SetShellVarContext current
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro NSIS_HOOK_POSTINSTALL
|
||||
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$OldInstallDir\${MAINBINARYNAME}.exe"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
Return
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
|
||||
!macro NSIS_HOOK_PREUNINSTALL
|
||||
${If} $DeleteAppDataCheckboxState = 1
|
||||
${AndIf} $UpdateMode <> 1
|
||||
${If} ${FileExists} "$APPDATA\${BUNDLEID}"
|
||||
Push "$APPDATA\${BUNDLEID}"
|
||||
Call un.RemoveReparsePoints
|
||||
${EndIf}
|
||||
${If} ${FileExists} "$LOCALAPPDATA\${BUNDLEID}"
|
||||
Push "$LOCALAPPDATA\${BUNDLEID}"
|
||||
Call un.RemoveReparsePoints
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
Function un.RemoveReparsePoints
|
||||
Exch $0 ; root directory to scan
|
||||
Push $1 ; FindFirst handle
|
||||
Push $2 ; current entry name
|
||||
Push $3 ; current entry path
|
||||
Push $4 ; entry attributes
|
||||
Push $5 ; spare
|
||||
|
||||
FindFirst $1 $2 "$0\*"
|
||||
${If} ${Errors}
|
||||
Goto done
|
||||
${EndIf}
|
||||
|
||||
loop:
|
||||
StrCmp $2 "." next
|
||||
StrCmp $2 ".." next
|
||||
|
||||
StrCpy $3 "$0\$2"
|
||||
System::Call 'kernel32::GetFileAttributes(t r3) i.r4'
|
||||
|
||||
IntOp $4 $4 & 0x400 ; FILE_ATTRIBUTE_REPARSE_POINT
|
||||
IntCmp $4 0 notReparse isReparse isReparse
|
||||
|
||||
isReparse:
|
||||
System::Call 'kernel32::GetFileAttributes(t r3) i.r4'
|
||||
IntOp $4 $4 & 0x10 ; FILE_ATTRIBUTE_DIRECTORY
|
||||
IntCmp $4 0 removeFileLink removeDirLink removeDirLink
|
||||
|
||||
removeDirLink:
|
||||
RmDir "$3" ; removes the junction / directory symlink itself
|
||||
Goto next
|
||||
removeFileLink:
|
||||
Delete "$3" ; removes the file symlink itself
|
||||
Goto next
|
||||
|
||||
notReparse:
|
||||
System::Call 'kernel32::GetFileAttributes(t r3) i.r4'
|
||||
IntOp $4 $4 & 0x10
|
||||
IntCmp $4 0 next recurse recurse
|
||||
|
||||
recurse:
|
||||
Push $3
|
||||
Call un.RemoveReparsePoints
|
||||
|
||||
next:
|
||||
FindNext $1 $2
|
||||
IfErrors done
|
||||
Goto loop
|
||||
|
||||
done:
|
||||
FindClose $1
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
1485
apps/app/nsis/installer.nsi
Normal file
21
apps/app/package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@modrinth/app",
|
||||
"scripts": {
|
||||
"tauri": "tauri",
|
||||
"build": "tauri build --config tauri-release.conf.json",
|
||||
"dev": "tauri dev",
|
||||
"test": "cargo nextest run --all-targets --no-fail-fast",
|
||||
"lint": "cargo fmt --check && cargo clippy --all-targets && cargo clippy --all-targets --features updater",
|
||||
"lint:ancillary": "prettier --check .",
|
||||
"fix": "cargo clippy --all-targets --fix --allow-dirty && cargo clippy --all-targets --features updater --fix --allow-dirty && cargo fmt",
|
||||
"fix:ancillary": "prettier --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tauri-apps/cli": "2.11.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modrinth/app-frontend": "workspace:*",
|
||||
"@modrinth/app-lib": "workspace:*",
|
||||
"@modrinth/daedalus": "workspace:*"
|
||||
}
|
||||
}
|
||||
105
apps/app/src/api/ai.rs
Normal file
@ -0,0 +1,105 @@
|
||||
use crate::api::Result;
|
||||
use theseus::ai::{
|
||||
self, AiModelUpdate, AiProviderConfigUpdate, AiProviderDefinition,
|
||||
AiProviderModel, AiSettings, AiState, OAuthDeviceCode, OAuthPollStatus,
|
||||
};
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("ai")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
ai_get_catalog,
|
||||
ai_get_state,
|
||||
ai_update_settings,
|
||||
ai_update_provider,
|
||||
ai_set_api_key,
|
||||
ai_set_credential,
|
||||
ai_update_model,
|
||||
ai_remove_model,
|
||||
ai_fetch_models,
|
||||
ai_test_provider,
|
||||
ai_begin_oauth,
|
||||
ai_poll_oauth,
|
||||
ai_disconnect_oauth,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn ai_get_catalog() -> Vec<AiProviderDefinition> {
|
||||
ai::catalog()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_get_state() -> Result<AiState> {
|
||||
Ok(ai::get_state().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_update_settings(settings: AiSettings) -> Result<()> {
|
||||
Ok(ai::update_settings(settings).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_update_provider(update: AiProviderConfigUpdate) -> Result<()> {
|
||||
Ok(ai::update_provider(update).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn ai_set_api_key(
|
||||
provider_id: String,
|
||||
secret: Option<String>,
|
||||
) -> Result<()> {
|
||||
Ok(ai::set_api_key(provider_id, secret)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn ai_set_credential(
|
||||
provider_id: String,
|
||||
credential: String,
|
||||
secret: Option<String>,
|
||||
) -> Result<()> {
|
||||
Ok(ai::set_credential(provider_id, credential, secret)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_update_model(update: AiModelUpdate) -> Result<()> {
|
||||
Ok(ai::update_model(update).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_remove_model(
|
||||
provider_id: String,
|
||||
model_id: String,
|
||||
) -> Result<()> {
|
||||
Ok(ai::remove_model(provider_id, model_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_fetch_models(
|
||||
provider_id: String,
|
||||
) -> Result<Vec<AiProviderModel>> {
|
||||
Ok(ai::fetch_models(provider_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_test_provider(
|
||||
provider_id: String,
|
||||
model_id: String,
|
||||
) -> Result<String> {
|
||||
Ok(ai::test_provider(provider_id, model_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_begin_oauth(provider_id: String) -> Result<OAuthDeviceCode> {
|
||||
Ok(ai::begin_oauth(provider_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn ai_poll_oauth(flow_id: uuid::Uuid) -> Result<OAuthPollStatus> {
|
||||
Ok(ai::poll_oauth(flow_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn ai_disconnect_oauth(provider_id: String) -> Result<()> {
|
||||
Ok(ai::disconnect_oauth(provider_id)?)
|
||||
}
|
||||
623
apps/app/src/api/auth.rs
Normal file
@ -0,0 +1,623 @@
|
||||
use crate::api::Result;
|
||||
use crate::api::oauth_utils;
|
||||
use chrono::{Duration, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::time::Duration as StdDuration;
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use tauri::{Emitter, Manager, Runtime, UserAttentionType};
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
use theseus::prelude::*;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::<R>::new("auth")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
check_reachable,
|
||||
check_mojang_services,
|
||||
set_mojang_auth_use_mirror,
|
||||
login,
|
||||
browser_login,
|
||||
begin_device_login,
|
||||
poll_device_login,
|
||||
begin_yggdrasil_login,
|
||||
finish_yggdrasil_login,
|
||||
list_yggdrasil_saved_logins,
|
||||
get_yggdrasil_password,
|
||||
set_yggdrasil_password,
|
||||
delete_yggdrasil_password,
|
||||
add_offline_user,
|
||||
remove_user,
|
||||
get_default_user,
|
||||
set_default_user,
|
||||
get_users,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
/// Checks if the authentication servers are reachable.
|
||||
#[tauri::command]
|
||||
pub async fn check_reachable() -> Result<()> {
|
||||
minecraft_auth::check_reachable().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Checks all Mojang services that the Fallen proxy mirrors.
|
||||
#[tauri::command]
|
||||
pub async fn check_mojang_services()
|
||||
-> Result<Vec<minecraft_auth::MojangServiceStatus>> {
|
||||
Ok(minecraft_auth::check_mojang_services().await)
|
||||
}
|
||||
|
||||
/// Stores whether the launcher should route Mojang service requests through
|
||||
/// the Fallen proxy.
|
||||
#[tauri::command]
|
||||
pub async fn set_mojang_auth_use_mirror(
|
||||
use_mirror: bool,
|
||||
automatic: bool,
|
||||
) -> Result<()> {
|
||||
Ok(
|
||||
minecraft_auth::set_mojang_auth_use_mirror(use_mirror, automatic)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MinecraftLoginTroubleLinks {
|
||||
trouble: String,
|
||||
browser_login: String,
|
||||
device_code: String,
|
||||
}
|
||||
|
||||
enum MinecraftLoginAlternative {
|
||||
Browser,
|
||||
DeviceCode,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn login<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
trouble_links: MinecraftLoginTroubleLinks,
|
||||
) -> Result<Option<Credentials>> {
|
||||
let flow = minecraft_auth::begin_login().await?;
|
||||
|
||||
let start = Utc::now();
|
||||
|
||||
if let Some(window) = app.get_webview_window("signin") {
|
||||
window.close()?;
|
||||
}
|
||||
|
||||
let (alternative_tx, mut alternative_rx) = mpsc::unbounded_channel();
|
||||
let trouble_links =
|
||||
serde_json::to_string(&trouble_links).map_err(|error| {
|
||||
theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to serialize Minecraft sign-in help links: {error}"
|
||||
))
|
||||
.as_error()
|
||||
})?;
|
||||
let help_bar_script = format!(
|
||||
r#"
|
||||
(() => {{
|
||||
const labels = {trouble_links};
|
||||
const addHelpBar = () => {{
|
||||
if (document.getElementById('axolotl-minecraft-login-help')) return;
|
||||
|
||||
const bar = document.createElement('div');
|
||||
bar.id = 'axolotl-minecraft-login-help';
|
||||
bar.style.cssText = 'box-sizing:border-box;position:sticky;top:0;z-index:2147483647;display:flex;align-items:center;gap:8px;width:100%;min-height:36px;padding:8px 16px;background:#fff;color:#1f1f1f;border-bottom:1px solid #d1d1d1;font:13px/20px system-ui,sans-serif;';
|
||||
const trouble = document.createElement('span');
|
||||
trouble.textContent = labels.trouble;
|
||||
bar.append(trouble);
|
||||
|
||||
const createLink = (label, destination) => {{
|
||||
const link = document.createElement('a');
|
||||
link.href = destination;
|
||||
link.textContent = label;
|
||||
link.style.cssText = 'color:#0067b8;text-decoration:underline;cursor:pointer;';
|
||||
return link;
|
||||
}};
|
||||
|
||||
bar.append(createLink(labels.browserLogin, 'axolotl-auth://browser'));
|
||||
const separator = document.createElement('span');
|
||||
separator.textContent = '|';
|
||||
bar.append(separator);
|
||||
bar.append(createLink(labels.deviceCode, 'axolotl-auth://device-code'));
|
||||
document.body.prepend(bar);
|
||||
}};
|
||||
|
||||
if (document.readyState === 'loading') {{
|
||||
document.addEventListener('DOMContentLoaded', addHelpBar, {{ once: true }});
|
||||
}} else {{
|
||||
addHelpBar();
|
||||
}}
|
||||
}})();
|
||||
"#,
|
||||
);
|
||||
let window = tauri::WebviewWindowBuilder::new(
|
||||
&app,
|
||||
"signin",
|
||||
tauri::WebviewUrl::External(flow.auth_request_uri.parse().map_err(
|
||||
|_| {
|
||||
theseus::ErrorKind::OtherError(
|
||||
"Error parsing auth redirect URL".to_string(),
|
||||
)
|
||||
.as_error()
|
||||
},
|
||||
)?),
|
||||
)
|
||||
.title("Sign into Axolotl Launcher")
|
||||
.always_on_top(true)
|
||||
.center()
|
||||
.initialization_script(help_bar_script)
|
||||
.on_navigation(move |url| {
|
||||
let alternative = match url.host_str() {
|
||||
Some("browser") if url.scheme() == "axolotl-auth" => {
|
||||
Some(MinecraftLoginAlternative::Browser)
|
||||
}
|
||||
Some("device-code") if url.scheme() == "axolotl-auth" => {
|
||||
Some(MinecraftLoginAlternative::DeviceCode)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(alternative) = alternative {
|
||||
let _ = alternative_tx.send(alternative);
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
})
|
||||
.build()?;
|
||||
|
||||
window.request_user_attention(Some(UserAttentionType::Critical))?;
|
||||
|
||||
while (Utc::now() - start) < Duration::minutes(10) {
|
||||
tokio::select! {
|
||||
Some(alternative) = alternative_rx.recv() => {
|
||||
window.close()?;
|
||||
return match alternative {
|
||||
MinecraftLoginAlternative::Browser => browser_login(app).await,
|
||||
MinecraftLoginAlternative::DeviceCode => {
|
||||
app.emit("minecraft-device-login-requested", ())?;
|
||||
Ok(None)
|
||||
}
|
||||
};
|
||||
}
|
||||
_ = tokio::time::sleep(std::time::Duration::from_millis(50)) => {}
|
||||
}
|
||||
|
||||
if window.title().is_err() {
|
||||
// user closed window, cancelling flow
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let callback_url = window.url()?;
|
||||
if callback_url
|
||||
.as_str()
|
||||
.starts_with("https://login.live.com/oauth20_desktop.srf")
|
||||
&& let Some((_, code)) =
|
||||
callback_url.query_pairs().find(|x| x.0 == "code")
|
||||
{
|
||||
let state = callback_url
|
||||
.query_pairs()
|
||||
.find(|x| x.0 == "state")
|
||||
.map(|(_, state)| state.into_owned())
|
||||
.ok_or_else(|| {
|
||||
theseus::ErrorKind::InputError(
|
||||
"Microsoft sign-in response did not include state"
|
||||
.into(),
|
||||
)
|
||||
.as_error()
|
||||
})?;
|
||||
window.close()?;
|
||||
let val = minecraft_auth::finish_login(&code, &state, flow).await?;
|
||||
|
||||
return Ok(Some(val));
|
||||
}
|
||||
}
|
||||
|
||||
window.close()?;
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn browser_login<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
) -> Result<Option<Credentials>> {
|
||||
let (listen_socket_tx, listen_socket) = oneshot::channel();
|
||||
let callback_address =
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 53682);
|
||||
let auth_code = tokio::spawn(oauth_utils::auth_code_reply::listen_fixed(
|
||||
callback_address,
|
||||
listen_socket_tx,
|
||||
));
|
||||
listen_socket.await.unwrap()?;
|
||||
|
||||
let flow = minecraft_auth::begin_browser_login().await?;
|
||||
if let Err(error) =
|
||||
app.opener().open_url(&flow.auth_request_uri, None::<&str>)
|
||||
{
|
||||
oauth_utils::auth_code_reply::stop_listeners();
|
||||
return Err(crate::api::TheseusSerializableError::Theseus(
|
||||
theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to open browser sign-in: {error}"
|
||||
))
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
|
||||
let auth_code =
|
||||
tokio::time::timeout(StdDuration::from_secs(10 * 60), auth_code)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
oauth_utils::auth_code_reply::stop_listeners();
|
||||
theseus::ErrorKind::OtherError(
|
||||
"Browser sign-in timed out".into(),
|
||||
)
|
||||
.as_error()
|
||||
})?;
|
||||
let auth_code = auth_code.map_err(|error| {
|
||||
theseus::ErrorKind::OtherError(format!(
|
||||
"Browser sign-in listener stopped unexpectedly: {error}"
|
||||
))
|
||||
.as_error()
|
||||
})?;
|
||||
let Some(reply) = auth_code? else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let state = reply.state.ok_or_else(|| {
|
||||
theseus::ErrorKind::InputError(
|
||||
"Microsoft sign-in response did not include state".into(),
|
||||
)
|
||||
.as_error()
|
||||
})?;
|
||||
let credentials =
|
||||
minecraft_auth::finish_login(&reply.code, &state, flow).await?;
|
||||
if let Some(main_window) = app.get_webview_window("main") {
|
||||
main_window.set_focus().ok();
|
||||
}
|
||||
|
||||
Ok(Some(credentials))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn begin_device_login()
|
||||
-> Result<minecraft_auth::MinecraftDeviceLoginFlow> {
|
||||
Ok(minecraft_auth::begin_device_login().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn poll_device_login(
|
||||
device_code: String,
|
||||
) -> Result<minecraft_auth::MinecraftDeviceLoginPoll> {
|
||||
Ok(minecraft_auth::poll_device_login(&device_code).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn begin_yggdrasil_login(
|
||||
api_root: String,
|
||||
login: String,
|
||||
password: String,
|
||||
) -> Result<minecraft_auth::YggdrasilLoginResult> {
|
||||
Ok(
|
||||
minecraft_auth::begin_yggdrasil_login(&api_root, &login, &password)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn finish_yggdrasil_login(
|
||||
flow_id: uuid::Uuid,
|
||||
profile_id: uuid::Uuid,
|
||||
) -> Result<Credentials> {
|
||||
Ok(minecraft_auth::finish_yggdrasil_login(flow_id, profile_id).await?)
|
||||
}
|
||||
|
||||
const YGGDRASIL_SAVED_LOGINS_KEY: &str = "yggdrasil-saved-logins";
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct SavedYggdrasilLogin {
|
||||
pub api_root: String,
|
||||
pub login: String,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_yggdrasil_saved_logins() -> Result<Vec<SavedYggdrasilLogin>> {
|
||||
read_yggdrasil_saved_logins()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_yggdrasil_password(
|
||||
api_root: String,
|
||||
login: String,
|
||||
) -> Result<Option<String>> {
|
||||
let entry = yggdrasil_password_entry(&api_root, &login)?;
|
||||
match entry.get_password() {
|
||||
Ok(password) => Ok(Some(password)),
|
||||
Err(keyring::Error::NoEntry) => Ok(None),
|
||||
Err(error) => Err(keyring_error(error)),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_yggdrasil_password(
|
||||
api_root: String,
|
||||
login: String,
|
||||
password: String,
|
||||
) -> Result<()> {
|
||||
if password.is_empty() {
|
||||
return delete_yggdrasil_password(api_root, login);
|
||||
}
|
||||
let saved_login = normalize_saved_yggdrasil_login(&api_root, &login)?;
|
||||
yggdrasil_password_entry(&saved_login.api_root, &saved_login.login)?
|
||||
.set_password(&password)
|
||||
.map_err(keyring_error)?;
|
||||
|
||||
let mut saved_logins = read_yggdrasil_saved_logins()?;
|
||||
upsert_saved_yggdrasil_login(&mut saved_logins, saved_login);
|
||||
write_yggdrasil_saved_logins(&saved_logins)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn delete_yggdrasil_password(
|
||||
api_root: String,
|
||||
login: String,
|
||||
) -> Result<()> {
|
||||
let saved_login = normalize_saved_yggdrasil_login(&api_root, &login)?;
|
||||
match yggdrasil_password_entry(&saved_login.api_root, &saved_login.login)?
|
||||
.delete_credential()
|
||||
{
|
||||
Ok(()) | Err(keyring::Error::NoEntry) => {}
|
||||
Err(error) => return Err(keyring_error(error)),
|
||||
}
|
||||
|
||||
let mut saved_logins = read_yggdrasil_saved_logins()?;
|
||||
remove_saved_yggdrasil_login(&mut saved_logins, &saved_login);
|
||||
write_yggdrasil_saved_logins(&saved_logins)
|
||||
}
|
||||
|
||||
fn yggdrasil_password_entry(
|
||||
api_root: &str,
|
||||
login: &str,
|
||||
) -> Result<keyring::Entry> {
|
||||
let login = login.trim();
|
||||
if login.is_empty() {
|
||||
return Err(theseus::ErrorKind::InputError(
|
||||
"The Yggdrasil account name cannot be empty".to_string(),
|
||||
)
|
||||
.as_error()
|
||||
.into());
|
||||
}
|
||||
let api_root = minecraft_auth::normalize_yggdrasil_api_root(api_root)?;
|
||||
keyring::Entry::new(
|
||||
theseus::brand::BUNDLE_IDENTIFIER,
|
||||
&format!("{api_root}\n{login}"),
|
||||
)
|
||||
.map_err(keyring_error)
|
||||
}
|
||||
|
||||
fn normalize_saved_yggdrasil_login(
|
||||
api_root: &str,
|
||||
login: &str,
|
||||
) -> Result<SavedYggdrasilLogin> {
|
||||
let login = login.trim();
|
||||
if login.is_empty() {
|
||||
return Err(theseus::ErrorKind::InputError(
|
||||
"The Yggdrasil account name cannot be empty".to_string(),
|
||||
)
|
||||
.as_error()
|
||||
.into());
|
||||
}
|
||||
Ok(SavedYggdrasilLogin {
|
||||
api_root: minecraft_auth::normalize_yggdrasil_api_root(api_root)?,
|
||||
login: login.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
fn yggdrasil_saved_logins_entry() -> Result<keyring::Entry> {
|
||||
keyring::Entry::new(
|
||||
theseus::brand::BUNDLE_IDENTIFIER,
|
||||
YGGDRASIL_SAVED_LOGINS_KEY,
|
||||
)
|
||||
.map_err(keyring_error)
|
||||
}
|
||||
|
||||
fn read_yggdrasil_saved_logins() -> Result<Vec<SavedYggdrasilLogin>> {
|
||||
match yggdrasil_saved_logins_entry()?.get_password() {
|
||||
Ok(saved_logins) => match serde_json::from_str(&saved_logins) {
|
||||
Ok(saved_logins) => Ok(saved_logins),
|
||||
Err(error) => {
|
||||
tracing::warn!(
|
||||
"Ignoring an invalid saved Yggdrasil login index: {error}"
|
||||
);
|
||||
Ok(Vec::new())
|
||||
}
|
||||
},
|
||||
Err(keyring::Error::NoEntry) => Ok(Vec::new()),
|
||||
Err(error) => Err(keyring_error(error)),
|
||||
}
|
||||
}
|
||||
|
||||
fn write_yggdrasil_saved_logins(
|
||||
saved_logins: &[SavedYggdrasilLogin],
|
||||
) -> Result<()> {
|
||||
let entry = yggdrasil_saved_logins_entry()?;
|
||||
if saved_logins.is_empty() {
|
||||
return match entry.delete_credential() {
|
||||
Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),
|
||||
Err(error) => Err(keyring_error(error)),
|
||||
};
|
||||
}
|
||||
|
||||
let saved_logins =
|
||||
serde_json::to_string(saved_logins).map_err(|error| {
|
||||
theseus::ErrorKind::OtherError(format!(
|
||||
"Unable to serialize saved Yggdrasil logins: {error}"
|
||||
))
|
||||
.as_error()
|
||||
})?;
|
||||
entry.set_password(&saved_logins).map_err(keyring_error)
|
||||
}
|
||||
|
||||
fn upsert_saved_yggdrasil_login(
|
||||
saved_logins: &mut Vec<SavedYggdrasilLogin>,
|
||||
saved_login: SavedYggdrasilLogin,
|
||||
) {
|
||||
saved_logins.retain(|entry| entry != &saved_login);
|
||||
saved_logins.push(saved_login);
|
||||
saved_logins.sort_by(|left, right| {
|
||||
left.login
|
||||
.cmp(&right.login)
|
||||
.then_with(|| left.api_root.cmp(&right.api_root))
|
||||
});
|
||||
}
|
||||
|
||||
fn remove_saved_yggdrasil_login(
|
||||
saved_logins: &mut Vec<SavedYggdrasilLogin>,
|
||||
saved_login: &SavedYggdrasilLogin,
|
||||
) {
|
||||
saved_logins.retain(|entry| entry != saved_login);
|
||||
}
|
||||
|
||||
fn keyring_error(
|
||||
error: keyring::Error,
|
||||
) -> crate::api::TheseusSerializableError {
|
||||
theseus::ErrorKind::OtherError(format!(
|
||||
"Unable to access the system credential store: {error}"
|
||||
))
|
||||
.as_error()
|
||||
.into()
|
||||
}
|
||||
|
||||
fn parse_custom_uuid(uuid: Option<String>) -> Result<Option<uuid::Uuid>> {
|
||||
let Some(uuid) = uuid else {
|
||||
return Ok(None);
|
||||
};
|
||||
let uuid = uuid.trim().replace('-', "");
|
||||
if uuid.len() != 32
|
||||
|| !uuid.chars().all(|character| character.is_ascii_hexdigit())
|
||||
{
|
||||
return Err(theseus::ErrorKind::InputError(
|
||||
"Custom UUID must be 32 hexadecimal characters; hyphens are optional"
|
||||
.to_string(),
|
||||
)
|
||||
.as_error()
|
||||
.into());
|
||||
}
|
||||
|
||||
Ok(Some(uuid::Uuid::parse_str(&uuid).map_err(|_| {
|
||||
theseus::ErrorKind::InputError("Invalid custom UUID".to_string())
|
||||
.as_error()
|
||||
})?))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn add_offline_user(
|
||||
username: String,
|
||||
uuid: Option<String>,
|
||||
) -> Result<Credentials> {
|
||||
Ok(
|
||||
minecraft_auth::add_offline_user(&username, parse_custom_uuid(uuid)?)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn remove_user(user: uuid::Uuid) -> Result<()> {
|
||||
Ok(minecraft_auth::remove_user(user).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_default_user(
|
||||
offline_mode: bool,
|
||||
) -> Result<Option<uuid::Uuid>> {
|
||||
Ok(minecraft_auth::get_default_user(offline_mode).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_default_user(user: uuid::Uuid) -> Result<()> {
|
||||
Ok(minecraft_auth::set_default_user(user).await?)
|
||||
}
|
||||
|
||||
/// Get a copy of the list of all user credentials
|
||||
#[tauri::command]
|
||||
pub async fn get_users(
|
||||
offline_mode: bool,
|
||||
) -> Result<Vec<minecraft_auth::MinecraftUser>> {
|
||||
Ok(minecraft_auth::users(offline_mode).await?)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn saved_login(api_root: &str, login: &str) -> SavedYggdrasilLogin {
|
||||
SavedYggdrasilLogin {
|
||||
api_root: api_root.to_string(),
|
||||
login: login.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saved_login_index_upserts_and_sorts_entries() {
|
||||
let mut saved_logins =
|
||||
vec![saved_login("https://example.com", "second")];
|
||||
upsert_saved_yggdrasil_login(
|
||||
&mut saved_logins,
|
||||
saved_login("https://example.com", "first"),
|
||||
);
|
||||
upsert_saved_yggdrasil_login(
|
||||
&mut saved_logins,
|
||||
saved_login("https://example.com", "second"),
|
||||
);
|
||||
|
||||
assert_eq!(saved_logins.len(), 2);
|
||||
assert_eq!(saved_logins[0].login, "first");
|
||||
assert_eq!(saved_logins[1].login, "second");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saved_login_index_removes_only_matching_entry() {
|
||||
let removed =
|
||||
saved_login("https://first.example", "player@example.com");
|
||||
let retained =
|
||||
saved_login("https://second.example", "player@example.com");
|
||||
let mut saved_logins = vec![removed.clone(), retained.clone()];
|
||||
|
||||
remove_saved_yggdrasil_login(&mut saved_logins, &removed);
|
||||
|
||||
assert_eq!(saved_logins, vec![retained]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_custom_offline_uuid() {
|
||||
let expected =
|
||||
uuid::Uuid::parse_str("b50ad385-829d-3141-a216-7e7d7539ca7f")
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
parse_custom_uuid(Some(
|
||||
"b50ad385829d3141a2167e7d7539ca7f".to_string()
|
||||
))
|
||||
.unwrap(),
|
||||
Some(expected)
|
||||
);
|
||||
assert_eq!(
|
||||
parse_custom_uuid(Some(
|
||||
"B50AD385-829D-3141-A216-7E7D7539CA7F".to_string()
|
||||
))
|
||||
.unwrap(),
|
||||
Some(expected)
|
||||
);
|
||||
assert_eq!(parse_custom_uuid(None).unwrap(), None);
|
||||
assert!(parse_custom_uuid(Some("not-a-uuid".to_string())).is_err());
|
||||
assert!(
|
||||
parse_custom_uuid(Some(
|
||||
"b50ad385829d3141a2167e7d7539ca7".to_string()
|
||||
))
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
161
apps/app/src/api/cache.rs
Normal file
@ -0,0 +1,161 @@
|
||||
use crate::api::search_cancellation::{self, SearchCancellation};
|
||||
use crate::api::{Result, TheseusSerializableError};
|
||||
use theseus::prelude::*;
|
||||
|
||||
macro_rules! impl_cache_methods {
|
||||
($(($variant:ident, $type:ty)),*) => {
|
||||
$(
|
||||
paste::paste! {
|
||||
#[tauri::command]
|
||||
pub async fn [<get_ $variant:snake>](id: &str, cache_behaviour: Option<CacheBehaviour>) -> Result<Option<$type>>
|
||||
{
|
||||
Ok(theseus::cache::[<get_ $variant:snake>](id, cache_behaviour).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn [<get_ $variant:snake _many>](
|
||||
ids: Vec<String>,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
) -> Result<Vec<$type>>
|
||||
{
|
||||
let ids = ids.iter().map(|x| &**x).collect::<Vec<&str>>();
|
||||
let entries =
|
||||
theseus::cache::[<get_ $variant:snake _many>](&*ids, cache_behaviour).await?;
|
||||
|
||||
Ok(entries)
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
impl_cache_methods!(
|
||||
(Project, Project),
|
||||
(ProjectV3, ProjectV3),
|
||||
(Version, Version),
|
||||
(User, User),
|
||||
(Team, Vec<TeamMember>),
|
||||
(Organization, Organization),
|
||||
(SearchResults, SearchResults)
|
||||
);
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_search_results_v3(
|
||||
id: &str,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
request_id: Option<String>,
|
||||
) -> Result<Option<SearchResultsV3>> {
|
||||
let Some(request_id) = request_id else {
|
||||
return Ok(
|
||||
theseus::cache::get_search_results_v3(id, cache_behaviour).await?
|
||||
);
|
||||
};
|
||||
let cancellation = SearchCancellation::register(request_id);
|
||||
|
||||
tokio::select! {
|
||||
result = theseus::cache::get_search_results_v3(id, cache_behaviour) => Ok(result?),
|
||||
_ = cancellation.cancelled() => Err(TheseusSerializableError::SearchCancelled(
|
||||
"Modrinth browse search".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_search_results_v3_many(
|
||||
ids: Vec<String>,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
) -> Result<Vec<SearchResultsV3>> {
|
||||
let ids = ids.iter().map(|x| &**x).collect::<Vec<&str>>();
|
||||
Ok(
|
||||
theseus::cache::get_search_results_v3_many(&ids, cache_behaviour)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn cancel_search_request(request_id: String) {
|
||||
if let Some(pending) = search_cancellation::cancel(&request_id) {
|
||||
tauri::async_runtime::spawn(async move {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
|
||||
pending.expire();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("cache")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_project,
|
||||
get_project_many,
|
||||
get_project_v3,
|
||||
get_project_v3_many,
|
||||
get_version,
|
||||
get_version_many,
|
||||
get_user,
|
||||
get_user_many,
|
||||
get_team,
|
||||
get_team_many,
|
||||
get_organization,
|
||||
get_organization_many,
|
||||
get_search_results,
|
||||
get_search_results_many,
|
||||
get_search_results_v3,
|
||||
get_search_results_v3_many,
|
||||
cancel_search_request,
|
||||
purge_cache_types,
|
||||
get_project_versions,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn purge_cache_types(cache_types: Vec<String>) -> Result<()> {
|
||||
let cache_types = supported_cache_types(&cache_types);
|
||||
Ok(theseus::cache::purge_cache_types(&cache_types).await?)
|
||||
}
|
||||
|
||||
fn supported_cache_types(cache_types: &[String]) -> Vec<CacheValueType> {
|
||||
cache_types
|
||||
.iter()
|
||||
.filter_map(|cache_type| {
|
||||
let parsed = CacheValueType::from_string(cache_type);
|
||||
if parsed.as_str() == cache_type {
|
||||
Some(parsed)
|
||||
} else {
|
||||
tracing::warn!(cache_type, "Ignoring unsupported cache type");
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_project_versions(
|
||||
project_id: &str,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
) -> Result<Option<Vec<Version>>> {
|
||||
Ok(
|
||||
theseus::cache::get_project_versions(project_id, cache_behaviour)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::supported_cache_types;
|
||||
use theseus::prelude::CacheValueType;
|
||||
|
||||
#[test]
|
||||
fn cache_purge_keeps_supported_types_and_ignores_unknown_types() {
|
||||
let cache_types = vec![
|
||||
"project".to_string(),
|
||||
"curseforge_project".to_string(),
|
||||
"future_cache_type".to_string(),
|
||||
];
|
||||
|
||||
assert_eq!(
|
||||
supported_cache_types(&cache_types),
|
||||
vec![CacheValueType::Project, CacheValueType::CurseForgeProject,]
|
||||
);
|
||||
}
|
||||
}
|
||||
35
apps/app/src/api/content_favorites.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use crate::api::Result;
|
||||
use theseus::content_favorites::{
|
||||
self, ContentFavorite, ContentFavoriteInput, ContentFavoriteProvider,
|
||||
};
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("content-favorites")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
content_favorites_list,
|
||||
content_favorites_add,
|
||||
content_favorites_remove,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn content_favorites_list() -> Result<Vec<ContentFavorite>> {
|
||||
Ok(content_favorites::list().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn content_favorites_add(
|
||||
favorite: ContentFavoriteInput,
|
||||
) -> Result<ContentFavorite> {
|
||||
Ok(content_favorites::add(favorite).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn content_favorites_remove(
|
||||
provider: ContentFavoriteProvider,
|
||||
project_id: String,
|
||||
) -> Result<()> {
|
||||
content_favorites::remove(provider, &project_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
61
apps/app/src/api/content_search.rs
Normal file
@ -0,0 +1,61 @@
|
||||
use theseus::content_search::{
|
||||
ChineseNameLookup, ChineseSearchResolution, ContentIdentityLookup,
|
||||
ContentSearchExpansion, WikiIdLookup,
|
||||
};
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("content-search")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
resolve_chinese_content_search,
|
||||
expand_content_search_query,
|
||||
lookup_chinese_content_names,
|
||||
lookup_content_wiki_ids,
|
||||
lookup_content_identities,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn resolve_chinese_content_search(
|
||||
query: String,
|
||||
) -> ChineseSearchResolution {
|
||||
theseus::content_search::resolve_chinese_content_search(&query)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn expand_content_search_query(query: String) -> ContentSearchExpansion {
|
||||
theseus::content_search::expand_content_search_query(&query)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn lookup_chinese_content_names(
|
||||
modrinth_slugs: Vec<String>,
|
||||
curseforge_slugs: Vec<String>,
|
||||
) -> ChineseNameLookup {
|
||||
theseus::content_search::lookup_chinese_content_names(
|
||||
&modrinth_slugs,
|
||||
&curseforge_slugs,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn lookup_content_wiki_ids(
|
||||
modrinth_slugs: Vec<String>,
|
||||
curseforge_slugs: Vec<String>,
|
||||
) -> WikiIdLookup {
|
||||
theseus::content_search::lookup_content_wiki_ids(
|
||||
&modrinth_slugs,
|
||||
&curseforge_slugs,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn lookup_content_identities(
|
||||
modrinth_slugs: Vec<String>,
|
||||
curseforge_slugs: Vec<String>,
|
||||
) -> ContentIdentityLookup {
|
||||
theseus::content_search::lookup_content_identities(
|
||||
&modrinth_slugs,
|
||||
&curseforge_slugs,
|
||||
)
|
||||
}
|
||||
267
apps/app/src/api/curseforge.rs
Normal file
@ -0,0 +1,267 @@
|
||||
use crate::api::search_cancellation::SearchCancellation;
|
||||
use crate::api::{Result, TheseusSerializableError};
|
||||
use theseus::curseforge::{
|
||||
CurseForgeCapability, CurseForgeCategory, CurseForgeFile,
|
||||
CurseForgeFilesRequest, CurseForgeFilesResponse,
|
||||
CurseForgeFingerprintResult, CurseForgeInstallRequest,
|
||||
CurseForgeInstallResult, CurseForgeManualDownload,
|
||||
CurseForgeManualDownloadImport, CurseForgeManualDownloadScanResult,
|
||||
CurseForgeModpackInstallRequest, CurseForgeModpackInstallResult,
|
||||
CurseForgeProject, CurseForgeRecognitionResult, CurseForgeSearchRequest,
|
||||
UnifiedSearchResponse,
|
||||
};
|
||||
use theseus::prelude::CacheBehaviour;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("curseforge")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
curseforge_capability,
|
||||
curseforge_validate_credentials,
|
||||
curseforge_search_projects,
|
||||
curseforge_get_project,
|
||||
curseforge_get_projects,
|
||||
curseforge_get_description,
|
||||
curseforge_get_files,
|
||||
curseforge_get_file,
|
||||
curseforge_get_files_many,
|
||||
curseforge_get_changelog,
|
||||
curseforge_get_download_url,
|
||||
curseforge_get_categories,
|
||||
curseforge_match_fingerprints,
|
||||
curseforge_install_file,
|
||||
curseforge_preview_install_file,
|
||||
curseforge_update_installed_file,
|
||||
curseforge_switch_installed_file_version,
|
||||
curseforge_recognize_instance_files,
|
||||
curseforge_import_manual_downloads,
|
||||
curseforge_list_pending_manual_downloads,
|
||||
curseforge_import_pending_manual_download_file,
|
||||
curseforge_configure_manual_download_watcher,
|
||||
curseforge_install_modpack,
|
||||
curseforge_update_managed_modpack,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn curseforge_capability() -> CurseForgeCapability {
|
||||
theseus::curseforge::capability()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_validate_credentials() -> Result<CurseForgeCapability> {
|
||||
Ok(theseus::curseforge::validate_credentials().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_search_projects(
|
||||
request: CurseForgeSearchRequest,
|
||||
request_id: Option<String>,
|
||||
) -> Result<UnifiedSearchResponse> {
|
||||
let Some(request_id) = request_id else {
|
||||
return Ok(theseus::curseforge::search_projects(request).await?);
|
||||
};
|
||||
let cancellation = SearchCancellation::register(request_id);
|
||||
|
||||
tokio::select! {
|
||||
result = theseus::curseforge::search_projects(request) => Ok(result?),
|
||||
_ = cancellation.cancelled() => Err(TheseusSerializableError::SearchCancelled(
|
||||
"CurseForge browse search".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_project(
|
||||
project_id: u32,
|
||||
) -> Result<CurseForgeProject> {
|
||||
Ok(theseus::curseforge::get_project(project_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_projects(
|
||||
project_ids: Vec<u32>,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
) -> Result<Vec<CurseForgeProject>> {
|
||||
Ok(theseus::curseforge::get_projects_with_cache_behaviour(
|
||||
project_ids,
|
||||
cache_behaviour,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_description(project_id: u32) -> Result<String> {
|
||||
Ok(theseus::curseforge::get_description(project_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_files(
|
||||
project_id: u32,
|
||||
request: CurseForgeFilesRequest,
|
||||
) -> Result<CurseForgeFilesResponse> {
|
||||
Ok(theseus::curseforge::get_files(project_id, request).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_file(
|
||||
project_id: u32,
|
||||
file_id: u32,
|
||||
) -> Result<CurseForgeFile> {
|
||||
Ok(theseus::curseforge::get_file(project_id, file_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_files_many(
|
||||
file_ids: Vec<u32>,
|
||||
) -> Result<Vec<CurseForgeFile>> {
|
||||
Ok(theseus::curseforge::get_files_many(file_ids).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_changelog(
|
||||
project_id: u32,
|
||||
file_id: u32,
|
||||
) -> Result<String> {
|
||||
Ok(theseus::curseforge::get_changelog(project_id, file_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_download_url(
|
||||
project_id: u32,
|
||||
file_id: u32,
|
||||
) -> Result<Option<String>> {
|
||||
Ok(theseus::curseforge::get_download_url(project_id, file_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_get_categories(
|
||||
class_id: Option<u32>,
|
||||
) -> Result<Vec<CurseForgeCategory>> {
|
||||
Ok(theseus::curseforge::get_categories(class_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_match_fingerprints(
|
||||
fingerprints: Vec<u64>,
|
||||
) -> Result<CurseForgeFingerprintResult> {
|
||||
Ok(theseus::curseforge::match_fingerprints(fingerprints).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_install_file(
|
||||
request: CurseForgeInstallRequest,
|
||||
) -> Result<CurseForgeInstallResult> {
|
||||
Ok(theseus::curseforge::install_file(request).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_preview_install_file(
|
||||
request: CurseForgeInstallRequest,
|
||||
) -> Result<theseus::curseforge::CurseForgeInstallPreview> {
|
||||
Ok(theseus::curseforge::preview_install_file(request).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_update_installed_file(
|
||||
instance_id: String,
|
||||
relative_path: String,
|
||||
) -> Result<CurseForgeInstallResult> {
|
||||
Ok(
|
||||
theseus::curseforge::update_installed_file(
|
||||
&instance_id,
|
||||
&relative_path,
|
||||
)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_switch_installed_file_version(
|
||||
instance_id: String,
|
||||
relative_path: String,
|
||||
file_id: u32,
|
||||
) -> Result<CurseForgeInstallResult> {
|
||||
Ok(theseus::curseforge::switch_installed_file_version(
|
||||
&instance_id,
|
||||
&relative_path,
|
||||
file_id,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_recognize_instance_files(
|
||||
instance_id: String,
|
||||
) -> Result<CurseForgeRecognitionResult> {
|
||||
Ok(theseus::curseforge::recognize_instance_files(&instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_import_manual_downloads(
|
||||
instance_id: String,
|
||||
scan_directory: Option<std::path::PathBuf>,
|
||||
) -> Result<CurseForgeManualDownloadScanResult> {
|
||||
Ok(theseus::curseforge::import_manual_downloads(
|
||||
&instance_id,
|
||||
scan_directory,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_list_pending_manual_downloads(
|
||||
instance_id: String,
|
||||
) -> Result<Vec<CurseForgeManualDownload>> {
|
||||
Ok(
|
||||
theseus::curseforge::list_pending_manual_downloads(&instance_id)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_import_pending_manual_download_file(
|
||||
instance_id: String,
|
||||
project_id: u32,
|
||||
file_id: u32,
|
||||
source_path: std::path::PathBuf,
|
||||
) -> Result<CurseForgeManualDownloadImport> {
|
||||
Ok(theseus::curseforge::import_pending_manual_download_file(
|
||||
&instance_id,
|
||||
project_id,
|
||||
file_id,
|
||||
source_path,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_configure_manual_download_watcher(
|
||||
enabled: bool,
|
||||
scan_directory: Option<std::path::PathBuf>,
|
||||
) -> Result<Option<String>> {
|
||||
Ok(theseus::curseforge::configure_manual_download_watcher(
|
||||
enabled,
|
||||
scan_directory,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_install_modpack(
|
||||
request: CurseForgeModpackInstallRequest,
|
||||
) -> Result<CurseForgeModpackInstallResult> {
|
||||
Ok(theseus::curseforge::install_modpack(request).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn curseforge_update_managed_modpack(
|
||||
instance_id: String,
|
||||
file_id: u32,
|
||||
) -> Result<theseus::install::InstallJobSnapshot> {
|
||||
Ok(theseus::install::runner::update_managed_curseforge_modpack(
|
||||
instance_id,
|
||||
file_id,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
102
apps/app/src/api/datapacks.rs
Normal file
@ -0,0 +1,102 @@
|
||||
use crate::api::Result;
|
||||
use either::Either;
|
||||
use std::path::PathBuf;
|
||||
use tauri::{AppHandle, Manager, Runtime};
|
||||
use theseus::worlds::{World, WorldDatapack, WorldWithDatapacks};
|
||||
|
||||
pub fn init<R: Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("datapacks")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
list_datapacks,
|
||||
delete_datapack,
|
||||
set_datapack_enabled
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_datapacks<R: Runtime>(
|
||||
app_handle: AppHandle<R>,
|
||||
instance_id: &str,
|
||||
) -> Result<Vec<WorldWithDatapacks>> {
|
||||
let mut result = theseus::worlds::list_world_datapacks(instance_id).await?;
|
||||
for world in &mut result {
|
||||
adapt_world_icon(&app_handle, &mut world.world);
|
||||
for datapack in &mut world.datapacks {
|
||||
adapt_datapack_icon(&app_handle, datapack);
|
||||
}
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_datapack(
|
||||
instance_id: String,
|
||||
world_path: String,
|
||||
file_name: String,
|
||||
) -> Result<()> {
|
||||
theseus::worlds::delete_world_datapack(
|
||||
&instance_id,
|
||||
&world_path,
|
||||
&file_name,
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_datapack_enabled(
|
||||
instance_id: String,
|
||||
world_path: String,
|
||||
file_name: String,
|
||||
enabled: bool,
|
||||
) -> Result<()> {
|
||||
theseus::worlds::set_world_datapack_enabled(
|
||||
&instance_id,
|
||||
&world_path,
|
||||
&file_name,
|
||||
enabled,
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn adapt_world_icon<R: Runtime>(app_handle: &AppHandle<R>, world: &mut World) {
|
||||
adapt_icon_field(app_handle, &mut world.icon, &world.name);
|
||||
}
|
||||
|
||||
fn adapt_datapack_icon<R: Runtime>(
|
||||
app_handle: &AppHandle<R>,
|
||||
datapack: &mut WorldDatapack,
|
||||
) {
|
||||
adapt_icon_field(app_handle, &mut datapack.icon, &datapack.display_name);
|
||||
}
|
||||
|
||||
fn adapt_icon_field<R: Runtime>(
|
||||
app_handle: &AppHandle<R>,
|
||||
icon: &mut Option<Either<PathBuf, url::Url>>,
|
||||
label: &str,
|
||||
) {
|
||||
if let Some(Either::Left(icon_path)) = icon {
|
||||
let icon_path = icon_path.clone();
|
||||
if let Ok(new_url) = super::utils::tauri_convert_file_src(&icon_path) {
|
||||
*icon = Some(Either::Right(new_url));
|
||||
if let Err(error) =
|
||||
app_handle.asset_protocol_scope().allow_file(&icon_path)
|
||||
{
|
||||
tracing::warn!(
|
||||
"Failed to allow file access for icon {}: {}",
|
||||
icon_path.display(),
|
||||
error
|
||||
);
|
||||
}
|
||||
} else {
|
||||
tracing::warn!(
|
||||
"Encountered invalid icon path for {}: {}",
|
||||
label,
|
||||
icon_path.display()
|
||||
);
|
||||
*icon = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
552
apps/app/src/api/drop.rs
Normal file
@ -0,0 +1,552 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::Emitter;
|
||||
use theseus::drop_classifier::{
|
||||
DroppedCandidate, DroppedItemType, ModrinthLookupResult,
|
||||
classify_dropped_item_with_candidates, classify_zip_with_extraction,
|
||||
lookup_mod_hash,
|
||||
};
|
||||
use theseus::pack::import::{ImportLauncherType, get_importable_instances};
|
||||
use theseus::{LockingProcess, get_locking_processes};
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
/// A scanned importable instance: name plus the resolved filesystem path.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ScannedInstance {
|
||||
pub name: String,
|
||||
pub path: String,
|
||||
#[serde(default)]
|
||||
pub compatible_mode: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub version_path: Option<String>,
|
||||
}
|
||||
|
||||
/// One candidate inside a multi-candidate classification result.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CandidateResult {
|
||||
pub item_type: String,
|
||||
pub file_path: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub inner_base: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub candidates: Vec<String>,
|
||||
}
|
||||
|
||||
/// Serializable classification result mapped from `DroppedItemType`.
|
||||
///
|
||||
/// All `PathBuf` fields are converted to `String` via `to_string_lossy()`.
|
||||
/// The JSON representation uses an `item_type` tag (via `#[serde(tag = "item_type")]`)
|
||||
/// so the frontend can discriminate variants with a string switch.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(tag = "item_type")]
|
||||
pub enum ClassificationResult {
|
||||
#[serde(rename = "launcher")]
|
||||
Launcher {
|
||||
launcher_type: String,
|
||||
base_path: String,
|
||||
#[serde(
|
||||
rename = "innerBase",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
inner_base: Option<String>,
|
||||
},
|
||||
#[serde(rename = "hmcl_launcher")]
|
||||
HmclLauncher {
|
||||
launcher_dir: String,
|
||||
data_dir: String,
|
||||
},
|
||||
#[serde(rename = "mod")]
|
||||
Mod { file_path: String },
|
||||
#[serde(rename = "litematic")]
|
||||
Litematic { file_path: String },
|
||||
#[serde(rename = "resource_pack")]
|
||||
ResourcePack {
|
||||
file_path: String,
|
||||
candidates: Vec<String>,
|
||||
#[serde(
|
||||
rename = "innerBase",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
inner_base: Option<String>,
|
||||
},
|
||||
#[serde(rename = "shader_pack")]
|
||||
ShaderPack {
|
||||
file_path: String,
|
||||
#[serde(
|
||||
rename = "innerBase",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
inner_base: Option<String>,
|
||||
},
|
||||
#[serde(rename = "world_save")]
|
||||
WorldSave {
|
||||
file_path: String,
|
||||
#[serde(
|
||||
rename = "innerBase",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
inner_base: Option<String>,
|
||||
},
|
||||
#[serde(rename = "modpack")]
|
||||
Modpack { file_path: String },
|
||||
#[serde(rename = "multiple")]
|
||||
Multiple {
|
||||
file_path: String,
|
||||
candidates: Vec<CandidateResult>,
|
||||
},
|
||||
#[serde(rename = "shortcut_resolved")]
|
||||
ShortcutResolved {
|
||||
original: String,
|
||||
resolved_to: Box<ClassificationResult>,
|
||||
},
|
||||
#[serde(rename = "unknown")]
|
||||
Unknown { reason: String },
|
||||
}
|
||||
|
||||
impl From<DroppedCandidate> for CandidateResult {
|
||||
fn from(candidate: DroppedCandidate) -> Self {
|
||||
CandidateResult {
|
||||
item_type: candidate.item_type,
|
||||
file_path: candidate.file_path.to_string_lossy().to_string(),
|
||||
inner_base: candidate.inner_base,
|
||||
candidates: candidate.candidates,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DroppedItemType> for ClassificationResult {
|
||||
fn from(item: DroppedItemType) -> Self {
|
||||
match item {
|
||||
DroppedItemType::Launcher {
|
||||
launcher_type,
|
||||
base_path,
|
||||
inner_base,
|
||||
} => ClassificationResult::Launcher {
|
||||
launcher_type: launcher_type.to_string(),
|
||||
base_path: base_path.to_string_lossy().to_string(),
|
||||
inner_base,
|
||||
},
|
||||
DroppedItemType::HmclLauncher {
|
||||
launcher_dir,
|
||||
data_dir,
|
||||
} => ClassificationResult::HmclLauncher {
|
||||
launcher_dir: launcher_dir.to_string_lossy().to_string(),
|
||||
data_dir: data_dir.to_string_lossy().to_string(),
|
||||
},
|
||||
DroppedItemType::Mod { file_path } => ClassificationResult::Mod {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
},
|
||||
DroppedItemType::Litematic { file_path } => {
|
||||
ClassificationResult::Litematic {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
}
|
||||
}
|
||||
DroppedItemType::ResourcePack {
|
||||
file_path,
|
||||
candidates,
|
||||
inner_base,
|
||||
} => ClassificationResult::ResourcePack {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
candidates,
|
||||
inner_base,
|
||||
},
|
||||
DroppedItemType::ShaderPack {
|
||||
file_path,
|
||||
inner_base,
|
||||
} => ClassificationResult::ShaderPack {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
inner_base,
|
||||
},
|
||||
DroppedItemType::WorldSave {
|
||||
file_path,
|
||||
inner_base,
|
||||
} => ClassificationResult::WorldSave {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
inner_base,
|
||||
},
|
||||
DroppedItemType::ShortcutResolved {
|
||||
original,
|
||||
resolved_to,
|
||||
} => ClassificationResult::ShortcutResolved {
|
||||
original: original.to_string_lossy().to_string(),
|
||||
resolved_to: Box::new(ClassificationResult::from(*resolved_to)),
|
||||
},
|
||||
DroppedItemType::Modpack { file_path } => {
|
||||
ClassificationResult::Modpack {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
}
|
||||
}
|
||||
DroppedItemType::Multiple {
|
||||
file_path,
|
||||
candidates,
|
||||
} => ClassificationResult::Multiple {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
candidates: candidates.into_iter().map(Into::into).collect(),
|
||||
},
|
||||
DroppedItemType::Unknown { reason } => {
|
||||
ClassificationResult::Unknown { reason }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("drop")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
drop_classify,
|
||||
drop_classify_extract,
|
||||
drop_extract_zip_to_temp,
|
||||
drop_scan_launcher_instances,
|
||||
drop_remove_temp_dir,
|
||||
drop_detect_file_lock,
|
||||
drop_extract_mod_metadata,
|
||||
drop_lookup_mod_hash,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
/// Classify a dropped file or folder path.
|
||||
///
|
||||
/// Returns a `ClassificationResult` with an `item_type` tag that the frontend
|
||||
/// can use to decide what UI to show (confirm dialog, error, etc.).
|
||||
#[tauri::command]
|
||||
pub async fn drop_classify<R: tauri::Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
path: String,
|
||||
allow_nested_extraction: Option<bool>,
|
||||
) -> Result<ClassificationResult, String> {
|
||||
debug!("Drop event received: {}", path);
|
||||
let path = std::path::PathBuf::from(&path);
|
||||
let path_label = path.to_string_lossy().to_string();
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "classify",
|
||||
"currentItem": path_label,
|
||||
"processed": 0,
|
||||
"total": null,
|
||||
}),
|
||||
);
|
||||
// The first pass never unpacks nested archives; when one would be needed
|
||||
// the classification reports the total nested size so the frontend can
|
||||
// confirm the potentially slow unpack with the user before retrying.
|
||||
// Batch drops classify several files concurrently, so the classifier must
|
||||
// run on a blocking thread instead of occupying the async runtime.
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
if allow_nested_extraction.unwrap_or(false) {
|
||||
classify_dropped_item_with_candidates(&path, true)
|
||||
} else {
|
||||
classify_dropped_item_with_candidates(&path, false)
|
||||
}
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Classification task panicked: {e}"))?;
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "done",
|
||||
"currentItem": path_label,
|
||||
"processed": 1,
|
||||
"total": 1,
|
||||
}),
|
||||
);
|
||||
let classification = ClassificationResult::from(result);
|
||||
info!("Classification result: {:?}", classification);
|
||||
Ok(classification)
|
||||
}
|
||||
|
||||
/// Classify ZIP
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn drop_classify_extract<R: tauri::Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
path: String,
|
||||
) -> Result<ClassificationResult, String> {
|
||||
debug!("Drop classify with extraction: {}", path);
|
||||
let path = std::path::PathBuf::from(&path);
|
||||
let path_label = path.to_string_lossy().to_string();
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "extract",
|
||||
"currentItem": &path_label,
|
||||
"processed": 0,
|
||||
"total": null,
|
||||
}),
|
||||
);
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
classify_zip_with_extraction(&path)
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Extraction task panicked: {e}"))?;
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "done",
|
||||
"currentItem": &path_label,
|
||||
"processed": 1,
|
||||
"total": 1,
|
||||
}),
|
||||
);
|
||||
let classification = ClassificationResult::from(result);
|
||||
info!(
|
||||
"Classification result (with extraction): {:?}",
|
||||
classification
|
||||
);
|
||||
Ok(classification)
|
||||
}
|
||||
|
||||
/// Root directory under the system temp where compressed launcher folders
|
||||
/// are extracted for scanning and importing. Entries are removed with
|
||||
/// `drop_remove_temp_dir` once the frontend flow ends.
|
||||
fn launcher_import_temp_base() -> std::path::PathBuf {
|
||||
std::env::temp_dir().join("axolotl-launcher-import")
|
||||
}
|
||||
|
||||
/// Remove `drop-*` directories under `base` whose contents are older than
|
||||
/// one day. The frontend cleans up after every flow, but a crashed process
|
||||
/// would otherwise leave stale extractions behind forever.
|
||||
fn sweep_stale_launcher_import_dirs(base: &std::path::Path) {
|
||||
let Ok(entries) = std::fs::read_dir(base) else {
|
||||
return;
|
||||
};
|
||||
let cutoff = std::time::SystemTime::now()
|
||||
.checked_sub(std::time::Duration::from_secs(24 * 60 * 60));
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
let Some(name) = path.file_name().and_then(|n| n.to_str()) else {
|
||||
continue;
|
||||
};
|
||||
if !name.starts_with("drop-") {
|
||||
continue;
|
||||
}
|
||||
let stale = match path.metadata().and_then(|m| m.modified()) {
|
||||
Ok(modified) => cutoff.is_none_or(|cutoff| modified < cutoff),
|
||||
Err(_) => false,
|
||||
};
|
||||
if stale {
|
||||
tracing::debug!(
|
||||
"Removing stale launcher import temp dir: {}",
|
||||
path.display()
|
||||
);
|
||||
let _ = std::fs::remove_dir_all(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract a ZIP archive into a fresh temporary directory and return its
|
||||
/// path. The frontend scans and imports instances from the extraction, then
|
||||
/// calls [`drop_remove_temp_dir`] to clean it up — the archive is unpacked
|
||||
/// exactly once.
|
||||
#[tauri::command]
|
||||
pub async fn drop_extract_zip_to_temp<R: tauri::Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
zip_path: String,
|
||||
) -> Result<String, String> {
|
||||
let zip_path = std::path::PathBuf::from(&zip_path);
|
||||
info!("Extracting launcher ZIP to temp: {}", zip_path.display());
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "extract",
|
||||
"currentItem": zip_path.to_string_lossy(),
|
||||
"processed": 0,
|
||||
"total": null,
|
||||
}),
|
||||
);
|
||||
|
||||
let base = launcher_import_temp_base();
|
||||
let zip_path_label = zip_path.to_string_lossy().to_string();
|
||||
let extracted =
|
||||
tokio::task::spawn_blocking(move || -> Result<String, String> {
|
||||
std::fs::create_dir_all(&base).map_err(|e| {
|
||||
format!("Failed to create temp base '{}': {e}", base.display())
|
||||
})?;
|
||||
sweep_stale_launcher_import_dirs(&base);
|
||||
let dir = base.join(format!(
|
||||
"drop-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos()
|
||||
));
|
||||
std::fs::create_dir(&dir)
|
||||
.map_err(|e| format!("Failed to create temp directory: {e}"))?;
|
||||
theseus::drop_classifier::extract_zip_to_dir(&zip_path, &dir)
|
||||
.map_err(|e| {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
tracing::warn!(
|
||||
"Launcher ZIP extraction failed for '{}': {e}",
|
||||
zip_path.display()
|
||||
);
|
||||
e
|
||||
})?;
|
||||
Ok(dir.to_string_lossy().to_string())
|
||||
})
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Launcher ZIP extraction task panicked: {e}");
|
||||
format!("Extraction task panicked: {e}")
|
||||
})??;
|
||||
|
||||
info!("Extracted launcher ZIP to: {extracted}");
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "done",
|
||||
"currentItem": zip_path_label,
|
||||
"processed": 1,
|
||||
"total": 1,
|
||||
}),
|
||||
);
|
||||
Ok(extracted)
|
||||
}
|
||||
|
||||
/// Remove a temporary directory created by [`drop_extract_zip_to_temp`].
|
||||
/// Only paths inside the launcher import temp root are accepted.
|
||||
#[tauri::command]
|
||||
pub async fn drop_remove_temp_dir(path: String) -> Result<(), String> {
|
||||
let base = launcher_import_temp_base();
|
||||
let base = std::fs::canonicalize(&base)
|
||||
.map_err(|e| format!("Launcher import temp base missing: {e}"))?;
|
||||
let target = std::fs::canonicalize(&path)
|
||||
.map_err(|e| format!("Temp path missing: {e}"))?;
|
||||
if !target.starts_with(&base) {
|
||||
return Err(format!(
|
||||
"Refusing to remove '{}': not inside the launcher import temp root",
|
||||
target.display()
|
||||
));
|
||||
}
|
||||
if !target.is_dir() {
|
||||
return Err(format!(
|
||||
"Refusing to remove '{}': not a directory",
|
||||
target.display()
|
||||
));
|
||||
}
|
||||
tokio::task::spawn_blocking(move || {
|
||||
std::fs::remove_dir_all(&target).map_err(|e| {
|
||||
format!("Failed to remove temp dir '{}': {e}", target.display())
|
||||
})
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Cleanup task panicked: {e}"))?
|
||||
}
|
||||
|
||||
/// Scan for importable instances in a launcher's data directory.
|
||||
///
|
||||
/// `launcher_type` must be one of the `ImportLauncherType` variant names
|
||||
/// (e.g. `"MultiMC"`, `"PrismLauncher"`, `"HMCL"`).
|
||||
#[tauri::command]
|
||||
pub async fn drop_scan_launcher_instances<R: tauri::Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
launcher_type: String,
|
||||
base_path: String,
|
||||
) -> Result<Vec<ScannedInstance>, String> {
|
||||
info!(
|
||||
"Scanning launcher instances — type: {launcher_type}, path: {base_path}"
|
||||
);
|
||||
let base_path_label = base_path.clone();
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "scan",
|
||||
"currentItem": &base_path_label,
|
||||
"processed": 0,
|
||||
"total": null,
|
||||
}),
|
||||
);
|
||||
let lt: ImportLauncherType =
|
||||
serde_json::from_str(&format!("\"{launcher_type}\"")).map_err(|e| {
|
||||
format!("Invalid launcher type '{launcher_type}': {e}")
|
||||
})?;
|
||||
let base = std::path::PathBuf::from(&base_path);
|
||||
let instances = get_importable_instances(lt, base)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
info!("Scan complete — found {} instance(s)", instances.len());
|
||||
for inst in &instances {
|
||||
debug!(
|
||||
"Scanned instance: name={:?} path={:?} compatible_mode={}",
|
||||
inst.name, inst.path, inst.compatible_mode
|
||||
);
|
||||
}
|
||||
let _ = app.emit(
|
||||
"drop_classify_progress",
|
||||
serde_json::json!({
|
||||
"phase": "done",
|
||||
"currentItem": &base_path_label,
|
||||
"processed": 1,
|
||||
"total": 1,
|
||||
}),
|
||||
);
|
||||
Ok(instances
|
||||
.into_iter()
|
||||
.map(|i| ScannedInstance {
|
||||
name: i.name,
|
||||
path: i.path,
|
||||
compatible_mode: i.compatible_mode,
|
||||
version_path: i.version_path,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Detect processes holding a file lock on the given path.
|
||||
///
|
||||
/// Returns an empty list when detection is unavailable on the current platform
|
||||
/// or the required tools are not installed.
|
||||
#[tauri::command]
|
||||
pub async fn drop_detect_file_lock(
|
||||
path: String,
|
||||
) -> Result<Vec<LockingProcess>, String> {
|
||||
let path = std::path::PathBuf::from(&path);
|
||||
info!("Detecting file lock for: {}", path.display());
|
||||
let processes = get_locking_processes(&path);
|
||||
if !processes.is_empty() {
|
||||
warn!("File locked by {} process(es)", processes.len());
|
||||
}
|
||||
Ok(processes)
|
||||
}
|
||||
|
||||
/// Extract mod metadata from a JAR file without installing it.
|
||||
///
|
||||
/// Reads the JAR bytes, extracts embedded mod metadata (fabric.mod.json,
|
||||
/// quilt.mod.json, META-INF/mods.toml, etc.), and returns the parsed
|
||||
/// `LocalModMetadata` as a JSON string.
|
||||
#[tauri::command]
|
||||
pub async fn drop_extract_mod_metadata(path: String) -> Result<String, String> {
|
||||
let path = std::path::PathBuf::from(&path);
|
||||
|
||||
let meta = tokio::task::spawn_blocking(move || {
|
||||
let file_bytes = std::fs::read(&path)
|
||||
.map_err(|e| format!("Failed to read file: {e}"))?;
|
||||
let bytes = bytes::Bytes::from(file_bytes);
|
||||
theseus::mod_metadata::extract_mod_metadata(&bytes)
|
||||
.ok_or_else(|| "No mod metadata found in file".to_string())
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Metadata extraction task panicked: {e}"))??;
|
||||
serde_json::to_string(&meta)
|
||||
.map_err(|e| format!("Failed to serialize metadata: {e}"))
|
||||
}
|
||||
|
||||
/// Look up a mod file by SHA1 hash to find matching Modrinth project and version.
|
||||
///
|
||||
/// Computes the SHA1 hash of the given file and queries the Modrinth API
|
||||
/// to find matching versions. Returns project and version information if found.
|
||||
#[tauri::command]
|
||||
pub async fn drop_lookup_mod_hash(
|
||||
path: String,
|
||||
) -> Result<Option<ModrinthLookupResult>, String> {
|
||||
let path = std::path::PathBuf::from(&path);
|
||||
info!("Looking up mod hash for: {}", path.display());
|
||||
|
||||
lookup_mod_hash(&path)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to lookup mod hash: {e}"))
|
||||
}
|
||||
614
apps/app/src/api/files.rs
Normal file
@ -0,0 +1,614 @@
|
||||
use crate::api::Result;
|
||||
use async_zip::base::read::seek::ZipFileReader;
|
||||
use image::ImageEncoder;
|
||||
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Cursor;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Mutex;
|
||||
use tauri::{Emitter, Runtime};
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
use theseus::instance::get_full_path;
|
||||
|
||||
const STUDIO_FILES_CHANGED_EVENT: &str = "studio-files-changed";
|
||||
|
||||
pub(crate) fn ensure_browsable<R: tauri::Runtime>(
|
||||
app: &tauri::AppHandle<R>,
|
||||
root: &std::path::Path,
|
||||
) {
|
||||
use tauri_plugin_fs::FsExt;
|
||||
if let Err(error) = app.fs_scope().allow_directory(root, true) {
|
||||
tracing::warn!(%error, path = %root.display(), "Failed to grant webview access to external instance");
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct StudioWatchers {
|
||||
watchers: Mutex<HashMap<String, StudioWatcher>>,
|
||||
}
|
||||
|
||||
struct StudioWatcher {
|
||||
registration_id: String,
|
||||
root: PathBuf,
|
||||
watcher: RecommendedWatcher,
|
||||
}
|
||||
|
||||
impl Drop for StudioWatcher {
|
||||
fn drop(&mut self) {
|
||||
if let Err(error) = self.watcher.unwatch(&self.root) {
|
||||
tracing::warn!(%error, "Failed to stop Studio file watcher");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct StudioFilesChangedEvent {
|
||||
instance_id: String,
|
||||
registration_id: String,
|
||||
paths: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn init<R: Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("files")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
file_extract_zip,
|
||||
file_save_as,
|
||||
file_read_dragged_file,
|
||||
screenshot_thumbnail,
|
||||
instance_icon_thumbnail,
|
||||
studio_read_text,
|
||||
studio_read_binary,
|
||||
studio_write_binary,
|
||||
studio_trash,
|
||||
studio_watch_register,
|
||||
studio_watch_unregister,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn studio_trash(instance_id: &str, file_path: &str) -> Result<()> {
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let source = tokio::fs::canonicalize(base.join(file_path)).await?;
|
||||
let canonical_base = tokio::fs::canonicalize(&base).await?;
|
||||
if !source.starts_with(&canonical_base) {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"file_path escapes the instance directory".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
tokio::task::spawn_blocking(move || trash::delete(source))
|
||||
.await
|
||||
.map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to send file to trash: {error}"
|
||||
)))
|
||||
})?
|
||||
.map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to send file to trash: {error}"
|
||||
)))
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn studio_read_text(
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
) -> Result<String> {
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let source = tokio::fs::canonicalize(base.join(file_path)).await?;
|
||||
let canonical_base = tokio::fs::canonicalize(&base).await?;
|
||||
if !source.starts_with(&canonical_base) {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"file_path escapes the instance directory".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
|
||||
let bytes = tokio::fs::read(source).await?;
|
||||
if bytes.contains(&0) {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"File is not a text file".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
String::from_utf8(bytes).map_err(|_| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"File is not a UTF-8 text file".to_string(),
|
||||
))
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
async fn studio_file_path(
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
) -> Result<PathBuf> {
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let source = tokio::fs::canonicalize(base.join(file_path)).await?;
|
||||
let canonical_base = tokio::fs::canonicalize(&base).await?;
|
||||
if !source.starts_with(&canonical_base) {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"file_path escapes the instance directory".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
Ok(source)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn studio_read_binary(
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
) -> Result<tauri::ipc::Response> {
|
||||
Ok(tauri::ipc::Response::new(
|
||||
tokio::fs::read(studio_file_path(instance_id, file_path).await?)
|
||||
.await?,
|
||||
))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn studio_write_binary(
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
bytes: Vec<u8>,
|
||||
) -> Result<()> {
|
||||
tokio::fs::write(studio_file_path(instance_id, file_path).await?, bytes)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn studio_watch_register<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
state: tauri::State<'_, StudioWatchers>,
|
||||
instance_id: String,
|
||||
) -> Result<String> {
|
||||
let root = get_full_path(&instance_id).await?;
|
||||
if !root.is_dir() {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"Instance directory does not exist".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
|
||||
let registration_id = uuid::Uuid::new_v4().to_string();
|
||||
let event_instance_id = instance_id.clone();
|
||||
let event_registration_id = registration_id.clone();
|
||||
let event_root = root.clone();
|
||||
let mut watcher = notify::recommended_watcher(
|
||||
move |result: notify::Result<notify::Event>| match result {
|
||||
Ok(event) => {
|
||||
let mut paths = event
|
||||
.paths
|
||||
.into_iter()
|
||||
.filter_map(|path| {
|
||||
path.strip_prefix(&event_root)
|
||||
.ok()
|
||||
.filter(|relative| !relative.as_os_str().is_empty())
|
||||
.map(|relative| {
|
||||
relative.to_string_lossy().replace('\\', "/")
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
paths.sort();
|
||||
paths.dedup();
|
||||
if paths.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Err(error) = app.emit(
|
||||
STUDIO_FILES_CHANGED_EVENT,
|
||||
StudioFilesChangedEvent {
|
||||
instance_id: event_instance_id.clone(),
|
||||
registration_id: event_registration_id.clone(),
|
||||
paths,
|
||||
},
|
||||
) {
|
||||
tracing::warn!(%error, "Failed to emit Studio file watcher event");
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
tracing::warn!(%error, "Studio file watcher failed");
|
||||
}
|
||||
},
|
||||
)
|
||||
.map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to create Studio file watcher: {error}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
watcher
|
||||
.watch(&root, RecursiveMode::Recursive)
|
||||
.map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to watch instance directory: {error}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
let mut watchers = state.watchers.lock().map_err(|_| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"Studio watcher state is unavailable".to_string(),
|
||||
))
|
||||
})?;
|
||||
watchers.insert(
|
||||
instance_id,
|
||||
StudioWatcher {
|
||||
registration_id: registration_id.clone(),
|
||||
root,
|
||||
watcher,
|
||||
},
|
||||
);
|
||||
|
||||
Ok(registration_id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn studio_watch_unregister(
|
||||
state: tauri::State<'_, StudioWatchers>,
|
||||
instance_id: String,
|
||||
registration_id: String,
|
||||
) -> Result<()> {
|
||||
let mut watchers = state.watchers.lock().map_err(|_| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"Studio watcher state is unavailable".to_string(),
|
||||
))
|
||||
})?;
|
||||
if watchers
|
||||
.get(&instance_id)
|
||||
.is_some_and(|watcher| watcher.registration_id == registration_id)
|
||||
{
|
||||
watchers.remove(&instance_id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ExtractDryRunResult {
|
||||
modpack_name: Option<String>,
|
||||
conflicting_files: Vec<String>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn file_read_dragged_file(
|
||||
path: String,
|
||||
) -> Result<tauri::ipc::Response> {
|
||||
let metadata = tokio::fs::metadata(&path).await?;
|
||||
if !metadata.is_file() {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"Dropped path is not a file".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
|
||||
// Raw binary payload: the frontend receives an ArrayBuffer instead of a
|
||||
// JSON number array, which would balloon multi-hundred-MB files to
|
||||
// gigabytes of transient memory on both sides of the IPC boundary.
|
||||
Ok(tauri::ipc::Response::new(tokio::fs::read(path).await?))
|
||||
}
|
||||
|
||||
/// Decodes a screenshot and returns a downscaled thumbnail as raw image bytes,
|
||||
/// so the webview never decodes high-resolution originals in the screenshots grid.
|
||||
/// Files that already fit within `max_dimension` are returned unchanged.
|
||||
#[tauri::command]
|
||||
pub async fn screenshot_thumbnail(
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
max_dimension: u32,
|
||||
) -> Result<tauri::ipc::Response> {
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let canonical_source =
|
||||
tokio::fs::canonicalize(base.join(file_path)).await?;
|
||||
let canonical_base = tokio::fs::canonicalize(&base).await?;
|
||||
if !canonical_source.starts_with(&canonical_base) {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"file_path escapes the instance directory".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
|
||||
let bytes = tokio::fs::read(&canonical_source).await?;
|
||||
let max_dimension = max_dimension.max(1);
|
||||
let thumbnail = tokio::task::spawn_blocking(move || -> Result<Vec<u8>> {
|
||||
let (width, height) =
|
||||
image::ImageReader::new(Cursor::new(bytes.as_slice()))
|
||||
.with_guessed_format()
|
||||
.map_err(|error| thumbnail_error(error.into()))?
|
||||
.into_dimensions()
|
||||
.map_err(thumbnail_error)?;
|
||||
if width <= max_dimension && height <= max_dimension {
|
||||
return Ok(bytes);
|
||||
}
|
||||
|
||||
let decoded = image::ImageReader::new(Cursor::new(bytes.as_slice()))
|
||||
.with_guessed_format()
|
||||
.map_err(|error| thumbnail_error(error.into()))?
|
||||
.decode()
|
||||
.map_err(thumbnail_error)?;
|
||||
let thumbnail = decoded.thumbnail(max_dimension, max_dimension);
|
||||
let mut output = Vec::new();
|
||||
if thumbnail.color().has_alpha() {
|
||||
let rgba = thumbnail.to_rgba8();
|
||||
image::codecs::png::PngEncoder::new(&mut output)
|
||||
.write_image(
|
||||
rgba.as_raw(),
|
||||
rgba.width(),
|
||||
rgba.height(),
|
||||
image::ExtendedColorType::Rgba8,
|
||||
)
|
||||
.map_err(thumbnail_error)?;
|
||||
} else {
|
||||
let rgb = thumbnail.to_rgb8();
|
||||
image::codecs::jpeg::JpegEncoder::new_with_quality(&mut output, 85)
|
||||
.write_image(
|
||||
rgb.as_raw(),
|
||||
rgb.width(),
|
||||
rgb.height(),
|
||||
image::ExtendedColorType::Rgb8,
|
||||
)
|
||||
.map_err(thumbnail_error)?;
|
||||
}
|
||||
Ok(output)
|
||||
})
|
||||
.await
|
||||
.map_err(|e| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Screenshot thumbnail task failed: {e}"
|
||||
)))
|
||||
})??;
|
||||
|
||||
Ok(tauri::ipc::Response::new(thumbnail))
|
||||
}
|
||||
|
||||
pub(crate) async fn local_instance_icon_path(
|
||||
instance_id: &str,
|
||||
max_dimension: u32,
|
||||
) -> Result<Option<String>> {
|
||||
const LOCAL_ICON_NAMES: [&str; 4] =
|
||||
["icon.png", "icon.jpg", "icon.jpeg", "icon.webp"];
|
||||
const MAX_LOCAL_ICON_BYTES: usize = 2 * 1024 * 1024;
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let max_dimension = max_dimension.max(1);
|
||||
|
||||
for file_name in LOCAL_ICON_NAMES {
|
||||
let source = base.join(file_name);
|
||||
if !source.is_file() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let candidate: Result<Option<String>> = async {
|
||||
let bytes = tokio::fs::read(&source).await?;
|
||||
let (processed, cache_name) = tokio::task::spawn_blocking(
|
||||
move || -> Result<(Vec<u8>, &'static str)> {
|
||||
let (width, height) =
|
||||
image::ImageReader::new(Cursor::new(bytes.as_slice()))
|
||||
.with_guessed_format()
|
||||
.map_err(|error| thumbnail_error(error.into()))?
|
||||
.into_dimensions()
|
||||
.map_err(|error| thumbnail_error(error.into()))?;
|
||||
|
||||
if width <= max_dimension
|
||||
&& height <= max_dimension
|
||||
&& bytes.len() <= MAX_LOCAL_ICON_BYTES
|
||||
{
|
||||
return Ok((bytes, file_name));
|
||||
}
|
||||
|
||||
let decoded =
|
||||
image::ImageReader::new(Cursor::new(bytes.as_slice()))
|
||||
.with_guessed_format()
|
||||
.map_err(|error| thumbnail_error(error.into()))?
|
||||
.decode()
|
||||
.map_err(|error| thumbnail_error(error.into()))?;
|
||||
let thumbnail =
|
||||
decoded.thumbnail(max_dimension, max_dimension);
|
||||
let mut output = Vec::new();
|
||||
if thumbnail.color().has_alpha() {
|
||||
let rgba = thumbnail.to_rgba8();
|
||||
image::codecs::png::PngEncoder::new(&mut output)
|
||||
.write_image(
|
||||
rgba.as_raw(),
|
||||
rgba.width(),
|
||||
rgba.height(),
|
||||
image::ExtendedColorType::Rgba8,
|
||||
)
|
||||
.map_err(|error| thumbnail_error(error.into()))?;
|
||||
Ok((output, "icon.png"))
|
||||
} else {
|
||||
let rgb = thumbnail.to_rgb8();
|
||||
image::codecs::jpeg::JpegEncoder::new_with_quality(
|
||||
&mut output,
|
||||
85,
|
||||
)
|
||||
.write_image(
|
||||
rgb.as_raw(),
|
||||
rgb.width(),
|
||||
rgb.height(),
|
||||
image::ExtendedColorType::Rgb8,
|
||||
)
|
||||
.map_err(|error| thumbnail_error(error.into()))?;
|
||||
Ok((output, "icon.jpg"))
|
||||
}
|
||||
},
|
||||
)
|
||||
.await
|
||||
.map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Instance icon thumbnail task failed: {error}"
|
||||
)))
|
||||
})??;
|
||||
|
||||
let cached_path =
|
||||
theseus::instance::cache_icon(cache_name, processed).await?;
|
||||
Ok(Some(cached_path))
|
||||
}
|
||||
.await;
|
||||
|
||||
if let Ok(Some(path)) = candidate {
|
||||
return Ok(Some(path));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_icon_thumbnail(
|
||||
instance_id: &str,
|
||||
max_dimension: u32,
|
||||
) -> Result<Option<String>> {
|
||||
local_instance_icon_path(instance_id, max_dimension).await
|
||||
}
|
||||
|
||||
fn thumbnail_error(error: image::ImageError) -> theseus::Error {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to process screenshot: {error}"
|
||||
)))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn file_extract_zip(
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
override_conflicts: bool,
|
||||
dry_run: bool,
|
||||
) -> Result<Option<ExtractDryRunResult>> {
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let zip_path = base.join(file_path);
|
||||
let canonical_zip = tokio::fs::canonicalize(&zip_path).await?;
|
||||
let canonical_base = tokio::fs::canonicalize(&base).await?;
|
||||
if !canonical_zip.starts_with(&canonical_base) {
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::OtherError(
|
||||
"file_path escapes the instance directory".to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
let extract_dir = zip_path
|
||||
.parent()
|
||||
.map(|p| p.to_path_buf())
|
||||
.unwrap_or_else(|| base.clone());
|
||||
|
||||
let file_bytes = tokio::fs::read(&zip_path).await?;
|
||||
let reader = Cursor::new(file_bytes);
|
||||
|
||||
let zip_reader = ZipFileReader::with_tokio(reader).await.map_err(|e| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to read zip file: {e}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
let entries: Vec<(usize, String)> = zip_reader
|
||||
.file()
|
||||
.entries()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, entry)| {
|
||||
let name = entry.filename().as_str().ok()?.to_string();
|
||||
if name.ends_with('/') {
|
||||
None
|
||||
} else {
|
||||
Some((i, name))
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
if dry_run {
|
||||
let mut conflicting_files = Vec::new();
|
||||
let canonical_extract = tokio::fs::canonicalize(&extract_dir).await?;
|
||||
for (_, name) in &entries {
|
||||
let target = extract_dir.join(name);
|
||||
if let Some(parent) = target.parent() {
|
||||
let normalized = parent
|
||||
.canonicalize()
|
||||
.unwrap_or_else(|_| extract_dir.join(parent));
|
||||
if !normalized.starts_with(&canonical_extract) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if target.exists() {
|
||||
conflicting_files.push(name.clone());
|
||||
}
|
||||
}
|
||||
return Ok(Some(ExtractDryRunResult {
|
||||
modpack_name: None,
|
||||
conflicting_files,
|
||||
}));
|
||||
}
|
||||
|
||||
let canonical_extract_dir = tokio::fs::canonicalize(&extract_dir).await?;
|
||||
let mut zip_reader = zip_reader;
|
||||
for (index, name) in &entries {
|
||||
let target = extract_dir.join(name);
|
||||
|
||||
if !override_conflicts && target.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(parent) = target.parent() {
|
||||
tokio::fs::create_dir_all(parent).await?;
|
||||
let canonical_parent = tokio::fs::canonicalize(parent).await?;
|
||||
if !canonical_parent.starts_with(&canonical_extract_dir) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let mut file_bytes = Vec::new();
|
||||
let mut entry_reader =
|
||||
zip_reader.reader_with_entry(*index).await.map_err(|e| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to read zip entry: {e}"
|
||||
)))
|
||||
})?;
|
||||
entry_reader
|
||||
.read_to_end_checked(&mut file_bytes)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to extract zip entry: {e}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
tokio::fs::write(&target, &file_bytes).await?;
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn file_save_as<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
instance_id: &str,
|
||||
file_path: &str,
|
||||
) -> Result<()> {
|
||||
let base = get_full_path(instance_id).await?;
|
||||
let source = base.join(file_path);
|
||||
let file_name = source
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
let (tx, rx) = tokio::sync::oneshot::channel();
|
||||
app.dialog()
|
||||
.file()
|
||||
.set_file_name(&file_name)
|
||||
.save_file(|path| {
|
||||
let _ = tx.send(path);
|
||||
});
|
||||
|
||||
if let Some(dest) = rx.await.unwrap_or(None) {
|
||||
let dest_path = std::path::PathBuf::try_from(dest).map_err(|e| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Invalid save path: {e}"
|
||||
)))
|
||||
})?;
|
||||
tokio::fs::copy(&source, &dest_path).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
33
apps/app/src/api/friends.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use theseus::prelude::{UserFriend, UserStatus};
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("friends")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
friends,
|
||||
friend_statuses,
|
||||
add_friend,
|
||||
remove_friend
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn friends() -> crate::api::Result<Vec<UserFriend>> {
|
||||
Ok(theseus::friends::friends().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn friend_statuses() -> crate::api::Result<Vec<UserStatus>> {
|
||||
Ok(theseus::friends::friend_statuses().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn add_friend(user_id: &str) -> crate::api::Result<()> {
|
||||
Ok(theseus::friends::add_friend(user_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn remove_friend(user_id: &str) -> crate::api::Result<()> {
|
||||
Ok(theseus::friends::remove_friend(user_id).await?)
|
||||
}
|
||||
48
apps/app/src/api/import.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::api::Result;
|
||||
use theseus::pack::import::{ImportLauncherType, ImportableInstance};
|
||||
|
||||
use theseus::pack::import;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("import")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_importable_instances,
|
||||
is_valid_importable_instance,
|
||||
get_default_launcher_path,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
/// Gets a list of importable instances from a launcher type and base path.
|
||||
/// Each entry includes the display name and the resolved filesystem path.
|
||||
#[tauri::command]
|
||||
pub async fn get_importable_instances(
|
||||
launcher_type: ImportLauncherType,
|
||||
base_path: PathBuf,
|
||||
) -> Result<Vec<ImportableInstance>> {
|
||||
Ok(import::get_importable_instances(launcher_type, base_path).await?)
|
||||
}
|
||||
|
||||
/// Checks if this instance is valid for importing, given a certain launcher type
|
||||
/// eg: is_valid_importable_instance(PathBuf::from("C:/MultiMC/Instance 1"), ImportLauncherType::MultiMC)
|
||||
#[tauri::command]
|
||||
pub async fn is_valid_importable_instance(
|
||||
instance_folder: PathBuf,
|
||||
launcher_type: ImportLauncherType,
|
||||
) -> Result<bool> {
|
||||
Ok(
|
||||
import::is_valid_importable_instance(instance_folder, launcher_type)
|
||||
.await,
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the default path for the given launcher type
|
||||
/// None if it can't be found or doesn't exist
|
||||
#[tauri::command]
|
||||
pub async fn get_default_launcher_path(
|
||||
launcher_type: ImportLauncherType,
|
||||
) -> Result<Option<PathBuf>> {
|
||||
Ok(import::get_default_launcher_path(launcher_type))
|
||||
}
|
||||
405
apps/app/src/api/install.rs
Normal file
@ -0,0 +1,405 @@
|
||||
use crate::api::Result;
|
||||
use crate::api::instance::InstanceLink;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
use theseus::data::ModLoader;
|
||||
use theseus::install::{
|
||||
ImportPlanRequest, InstallJobSnapshot, InstallModpackPreview,
|
||||
InstallPostInstallEdit,
|
||||
};
|
||||
use theseus::pack::import::ImportLauncherType;
|
||||
use theseus::pack::install_from::CreatePackLocation;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("install")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
install_get_modpack_preview,
|
||||
install_create_instance,
|
||||
install_create_modpack_instance,
|
||||
install_import_instance,
|
||||
install_start_import_plan,
|
||||
install_cancel_import_plan,
|
||||
install_duplicate_instance,
|
||||
install_existing_instance,
|
||||
install_pack_to_existing_instance,
|
||||
install_job_list,
|
||||
install_job_get,
|
||||
install_job_retry,
|
||||
install_job_repair_cache_and_retry,
|
||||
install_job_resume,
|
||||
install_job_skip_missing_content,
|
||||
install_job_missing_files,
|
||||
install_job_scan_missing_files,
|
||||
install_job_retry_missing_file,
|
||||
install_job_import_missing_file,
|
||||
install_job_cancel,
|
||||
install_job_dismiss,
|
||||
install_job_support_details,
|
||||
download_job_list,
|
||||
download_job_get,
|
||||
download_job_retry,
|
||||
download_job_resume,
|
||||
download_job_cancel,
|
||||
download_job_delete,
|
||||
download_history_clear,
|
||||
download_job_support_details,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InstallCreateInstanceRequest {
|
||||
pub name: String,
|
||||
pub game_version: String,
|
||||
pub loader: ModLoader,
|
||||
pub loader_version: Option<String>,
|
||||
#[serde(default)]
|
||||
pub adjuncts: Vec<theseus::data::LoaderComponent>,
|
||||
pub icon_path: Option<String>,
|
||||
pub link: Option<InstanceLink>,
|
||||
#[serde(default)]
|
||||
pub game_dir_override: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InstallPostInstallEditRequest {
|
||||
pub name: Option<String>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "serde_with::rust::double_option"
|
||||
)]
|
||||
pub icon_path: Option<Option<String>>,
|
||||
pub link: Option<InstanceLink>,
|
||||
}
|
||||
|
||||
impl InstallPostInstallEditRequest {
|
||||
fn into_core(self) -> Result<InstallPostInstallEdit> {
|
||||
Ok(InstallPostInstallEdit {
|
||||
name: self.name,
|
||||
icon_path: self.icon_path,
|
||||
link: self.link.map(|link| link.into_core()).transpose()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_get_modpack_preview(
|
||||
location: CreatePackLocation,
|
||||
) -> Result<InstallModpackPreview> {
|
||||
Ok(theseus::pack::install_from::get_instance_from_pack(location).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_create_instance(
|
||||
request: InstallCreateInstanceRequest,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::create_instance_with_adjuncts(
|
||||
request.name.trim().to_string(),
|
||||
request.game_version,
|
||||
request.loader,
|
||||
request.loader_version,
|
||||
request.adjuncts,
|
||||
request.icon_path,
|
||||
match request.link {
|
||||
Some(link) => link.into_core()?,
|
||||
None => theseus::data::InstanceLink::Unmanaged,
|
||||
},
|
||||
request.game_dir_override,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_create_modpack_instance(
|
||||
location: CreatePackLocation,
|
||||
post_install_edit: Option<InstallPostInstallEditRequest>,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::create_modpack_instance(
|
||||
location,
|
||||
post_install_edit.map(|edit| edit.into_core()).transpose()?,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_import_instance(
|
||||
launcher_type: ImportLauncherType,
|
||||
base_path: PathBuf,
|
||||
instance_folder: String,
|
||||
instance_path: Option<String>,
|
||||
symlink: bool,
|
||||
game_version: Option<String>,
|
||||
loader: Option<ModLoader>,
|
||||
loader_version: Option<String>,
|
||||
game_dir_override: Option<String>,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
tracing::debug!(
|
||||
"install_import_instance called: launcher_type={launcher_type:?} base_path={} instance_folder={} instance_path={:?} symlink={symlink} game_version={game_version:?} loader={loader:?} loader_version={loader_version:?} game_dir_override={game_dir_override:?}",
|
||||
base_path.display(),
|
||||
instance_folder,
|
||||
instance_path,
|
||||
);
|
||||
// Extracted launcher archives live in a temporary folder that is removed
|
||||
// after the import; a symlink into it would dangle immediately.
|
||||
if symlink
|
||||
&& base_path
|
||||
.starts_with(std::env::temp_dir().join("axolotl-launcher-import"))
|
||||
{
|
||||
return Err(theseus::Error::from(theseus::ErrorKind::InputError(
|
||||
"Symbolic-link import is unavailable for extracted archives: \
|
||||
the temporary folder is deleted after the import completes. \
|
||||
Choose copy instead."
|
||||
.to_string(),
|
||||
))
|
||||
.into());
|
||||
}
|
||||
Ok(theseus::install::import_instance_with_plan(
|
||||
launcher_type,
|
||||
base_path,
|
||||
instance_folder,
|
||||
instance_path,
|
||||
symlink,
|
||||
game_version,
|
||||
loader,
|
||||
loader_version,
|
||||
game_dir_override,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_start_import_plan(
|
||||
request: ImportPlanRequest,
|
||||
) -> Result<String> {
|
||||
Ok(theseus::install::start_import_plan(request)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_cancel_import_plan(request_id: String) -> Result<()> {
|
||||
Ok(theseus::install::cancel_import_plan(&request_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_duplicate_instance(
|
||||
source_instance_id: String,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::duplicate_instance(source_instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_existing_instance(
|
||||
instance_id: String,
|
||||
force: bool,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::install_existing_instance(instance_id, force).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_pack_to_existing_instance(
|
||||
instance_id: String,
|
||||
location: CreatePackLocation,
|
||||
post_install_edit: Option<InstallPostInstallEditRequest>,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::install_pack_to_existing_instance(
|
||||
instance_id,
|
||||
location,
|
||||
post_install_edit.map(|edit| edit.into_core()).transpose()?,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_list(
|
||||
include_finished: bool,
|
||||
) -> Result<Vec<InstallJobSnapshot>> {
|
||||
Ok(theseus::install::list_jobs(include_finished).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_get(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::get_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_retry(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::retry_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_repair_cache_and_retry(
|
||||
job_id: Uuid,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::repair_cache_and_retry_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_resume(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::resume_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_skip_missing_content(
|
||||
job_id: Uuid,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::skip_missing_content_and_resume_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_missing_files(
|
||||
job_id: Uuid,
|
||||
) -> Result<theseus::install::MissingModpackContentView> {
|
||||
Ok(theseus::install::list_missing_modpack_files(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_scan_missing_files(
|
||||
job_id: Uuid,
|
||||
scan_directory: Option<PathBuf>,
|
||||
) -> Result<theseus::install::MissingModpackScanResult> {
|
||||
Ok(
|
||||
theseus::install::scan_missing_modpack_files(job_id, scan_directory)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_retry_missing_file(
|
||||
job_id: Uuid,
|
||||
item_id: String,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::retry_missing_modpack_file(job_id, item_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_import_missing_file(
|
||||
job_id: Uuid,
|
||||
item_id: String,
|
||||
selected_file_path: PathBuf,
|
||||
) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::import_missing_modpack_file(
|
||||
job_id,
|
||||
item_id,
|
||||
selected_file_path,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_cancel(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::cancel_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_dismiss(job_id: Uuid) -> Result<()> {
|
||||
Ok(theseus::install::dismiss_job(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_job_support_details(job_id: String) -> Result<String> {
|
||||
let Ok(uuid) = Uuid::parse_str(&job_id) else {
|
||||
// Synthetic, frontend-tracked jobs (e.g. server downloads) use non-UUID
|
||||
// identifiers and do not expose backend diagnostic details.
|
||||
return Ok(String::new());
|
||||
};
|
||||
Ok(theseus::install::job_support_details(uuid).await?)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DownloadJobListRequest {
|
||||
pub status: Option<String>,
|
||||
pub provider: Option<String>,
|
||||
pub query: Option<String>,
|
||||
pub cursor: Option<String>,
|
||||
pub limit: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DownloadJobPage {
|
||||
pub jobs: Vec<InstallJobSnapshot>,
|
||||
pub next_cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_list(
|
||||
request: Option<DownloadJobListRequest>,
|
||||
) -> Result<DownloadJobPage> {
|
||||
let request = request.unwrap_or_default();
|
||||
let mut jobs = theseus::install::list_jobs(true).await?;
|
||||
if let Some(status) = request.status.as_deref() {
|
||||
jobs.retain(|job| job.status.as_str() == status);
|
||||
}
|
||||
if let Some(provider) = request.provider.as_deref() {
|
||||
jobs.retain(|job| {
|
||||
format!("{:?}", job.provider)
|
||||
.to_ascii_lowercase()
|
||||
.replace('_', "")
|
||||
== provider.to_ascii_lowercase().replace('_', "")
|
||||
});
|
||||
}
|
||||
if let Some(query) = request.query.as_deref() {
|
||||
let query = query.trim().to_ascii_lowercase();
|
||||
if !query.is_empty() {
|
||||
jobs.retain(|job| {
|
||||
job.display.as_ref().is_some_and(|display| {
|
||||
display.title.to_ascii_lowercase().contains(&query)
|
||||
}) || job.job_id.to_string().contains(&query)
|
||||
});
|
||||
}
|
||||
}
|
||||
jobs.sort_by(|a, b| b.created.cmp(&a.created));
|
||||
let offset = request
|
||||
.cursor
|
||||
.as_deref()
|
||||
.and_then(|cursor| cursor.parse::<usize>().ok())
|
||||
.unwrap_or(0);
|
||||
let limit = request.limit.unwrap_or(100).clamp(1, 250);
|
||||
let jobs = jobs
|
||||
.into_iter()
|
||||
.skip(offset)
|
||||
.take(limit)
|
||||
.collect::<Vec<_>>();
|
||||
let next_cursor =
|
||||
(jobs.len() == limit).then(|| (offset + limit).to_string());
|
||||
Ok(DownloadJobPage { jobs, next_cursor })
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_get(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
install_job_get(job_id).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_retry(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
Ok(theseus::install::retry_job_as_new(job_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_resume(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
install_job_resume(job_id).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_cancel(job_id: Uuid) -> Result<InstallJobSnapshot> {
|
||||
install_job_cancel(job_id).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_delete(job_id: Uuid) -> Result<()> {
|
||||
install_job_dismiss(job_id).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_history_clear() -> Result<u64> {
|
||||
Ok(theseus::install::clear_job_history().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_job_support_details(job_id: String) -> Result<String> {
|
||||
install_job_support_details(job_id).await
|
||||
}
|
||||
1496
apps/app/src/api/instance.rs
Normal file
170
apps/app/src/api/jre.rs
Normal file
@ -0,0 +1,170 @@
|
||||
use crate::api::Result;
|
||||
use std::path::PathBuf;
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use theseus::prelude::*;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("jre")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_java_versions,
|
||||
get_java_default_versions,
|
||||
set_java_version,
|
||||
set_java_default_version,
|
||||
remove_java_default_version,
|
||||
remove_java_version,
|
||||
jre_find_filtered_jres,
|
||||
jre_get_jre,
|
||||
jre_test_jre,
|
||||
jre_auto_install_java,
|
||||
jre_respond_to_download_confirmation,
|
||||
jre_get_max_memory,
|
||||
jre_get_memory_status,
|
||||
jre_optimize_memory,
|
||||
list_java_distribution_versions,
|
||||
list_java_feed_vendors,
|
||||
list_java_feed_versions,
|
||||
download_java_from_feed,
|
||||
download_java,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_java_versions() -> Result<Vec<JavaVersion>> {
|
||||
Ok(jre::get_java_versions().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_java_default_versions() -> Result<Vec<JavaVersion>> {
|
||||
Ok(jre::get_java_default_versions().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_java_version(java_version: JavaVersion) -> Result<()> {
|
||||
jre::set_java_version(java_version).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_java_default_version(
|
||||
major_version: u32,
|
||||
path: String,
|
||||
) -> Result<JavaVersion> {
|
||||
Ok(jre::set_java_default_version(major_version, path).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn remove_java_default_version(major_version: u32) -> Result<()> {
|
||||
jre::remove_java_default_version(major_version).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn remove_java_version(path: String) -> Result<()> {
|
||||
jre::remove_java_version(path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Finds the installation of Java 8, if it exists
|
||||
#[tauri::command]
|
||||
pub async fn jre_find_filtered_jres(
|
||||
version: Option<u32>,
|
||||
full_scan: bool,
|
||||
force_fresh: bool,
|
||||
exhaustive: bool,
|
||||
) -> Result<Vec<JavaVersion>> {
|
||||
Ok(
|
||||
jre::find_filtered_jres(version, full_scan, force_fresh, exhaustive)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
// Validates JRE at a given path
|
||||
// Returns None if the path is not a valid JRE
|
||||
#[tauri::command]
|
||||
pub async fn jre_get_jre(path: PathBuf) -> Result<JavaVersion> {
|
||||
Ok(jre::check_jre(path).await?)
|
||||
}
|
||||
|
||||
// Tests JRE of a certain version
|
||||
#[tauri::command]
|
||||
pub async fn jre_test_jre(path: PathBuf, major_version: u32) -> Result<bool> {
|
||||
Ok(jre::test_jre(path, major_version).await?)
|
||||
}
|
||||
|
||||
// Auto installs java for the given java version
|
||||
#[tauri::command]
|
||||
pub async fn jre_auto_install_java(
|
||||
java_version: u32,
|
||||
) -> Result<Option<PathBuf>> {
|
||||
Ok(jre::auto_install_java(java_version).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn jre_respond_to_download_confirmation(
|
||||
request_id: uuid::Uuid,
|
||||
approved: bool,
|
||||
) -> bool {
|
||||
jre::respond_to_java_download_confirmation(request_id, approved)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_java_distribution_versions(
|
||||
distribution: String,
|
||||
) -> Result<Vec<u32>> {
|
||||
Ok(jre::list_java_distribution_versions(distribution).await?)
|
||||
}
|
||||
|
||||
// Gets the maximum memory a system has available.
|
||||
#[tauri::command]
|
||||
pub async fn jre_get_max_memory() -> Result<u64> {
|
||||
Ok(jre::get_max_memory().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn jre_get_memory_status(
|
||||
instance_id: Option<String>,
|
||||
requested_memory_mb: u32,
|
||||
automatic: bool,
|
||||
) -> Result<jre::MemoryStatus> {
|
||||
Ok(jre::get_memory_status(
|
||||
instance_id.as_deref(),
|
||||
requested_memory_mb,
|
||||
automatic,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn jre_optimize_memory()
|
||||
-> Result<theseus::memory::MemoryOptimizationResult> {
|
||||
Ok(theseus::memory::optimize().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_java_feed_vendors() -> Result<Vec<String>> {
|
||||
Ok(jre::list_java_feed_vendors().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_java_feed_versions(
|
||||
vendor: String,
|
||||
) -> Result<Vec<JdkVersionInfo>> {
|
||||
Ok(jre::list_java_feed_versions(&vendor).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_java_from_feed(
|
||||
vendor: String,
|
||||
jdk_version_major: u32,
|
||||
) -> Result<PathBuf> {
|
||||
Ok(jre::download_java_from_feed(&vendor, jdk_version_major).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_java(
|
||||
vendor: String,
|
||||
version: u32,
|
||||
) -> Result<theseus::install::InstallJobSnapshot> {
|
||||
Ok(theseus::install::download_java(vendor, version).await?)
|
||||
}
|
||||
187
apps/app/src/api/logs.rs
Normal file
@ -0,0 +1,187 @@
|
||||
use crate::api::Result;
|
||||
use async_zip::tokio::write::ZipFileWriter;
|
||||
use std::path::PathBuf;
|
||||
use theseus::logs::LogType;
|
||||
use theseus::logs::{
|
||||
self, CensoredString, CrashAnalysis, CrashAnalysisAiExplanation,
|
||||
CrashAnalysisAiSettings, LatestLogCursor, Logs,
|
||||
};
|
||||
|
||||
/*
|
||||
A log is a struct containing the filename string, stdout, and stderr, as follows:
|
||||
|
||||
pub struct Logs {
|
||||
pub filename: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String,
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("logs")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
logs_get_logs,
|
||||
logs_get_logs_by_filename,
|
||||
logs_get_output_by_filename,
|
||||
logs_delete_logs,
|
||||
logs_delete_logs_by_filename,
|
||||
logs_get_latest_log_cursor,
|
||||
logs_get_minecraft_latest_log_cursor,
|
||||
logs_get_live_log_buffer,
|
||||
logs_clear_live_log_buffer,
|
||||
logs_analyze_crash,
|
||||
logs_get_crash_analysis_ai_settings,
|
||||
logs_update_crash_analysis_ai_settings,
|
||||
logs_explain_crash_with_ai,
|
||||
logs_undo_added_mod,
|
||||
logs_export_crash_context,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
/// Get all logs for an instance, sorted by filename.
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_logs(
|
||||
instance_id: &str,
|
||||
clear_contents: Option<bool>,
|
||||
) -> Result<Vec<Logs>> {
|
||||
let val = logs::get_logs(instance_id, clear_contents).await?;
|
||||
|
||||
Ok(val)
|
||||
}
|
||||
|
||||
/// Get a log struct for an instance by filename.
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_logs_by_filename(
|
||||
instance_id: &str,
|
||||
log_type: LogType,
|
||||
filename: String,
|
||||
) -> Result<Logs> {
|
||||
Ok(logs::get_logs_by_filename(instance_id, log_type, filename).await?)
|
||||
}
|
||||
|
||||
/// Get the output for an instance by filename.
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_output_by_filename(
|
||||
instance_id: &str,
|
||||
log_type: LogType,
|
||||
filename: String,
|
||||
) -> Result<CensoredString> {
|
||||
Ok(logs::get_output_by_filename(instance_id, log_type, &filename).await?)
|
||||
}
|
||||
|
||||
/// Delete all logs for an instance.
|
||||
#[tauri::command]
|
||||
pub async fn logs_delete_logs(instance_id: &str) -> Result<()> {
|
||||
Ok(logs::delete_logs(instance_id).await?)
|
||||
}
|
||||
|
||||
/// Delete a log for an instance by filename.
|
||||
#[tauri::command]
|
||||
pub async fn logs_delete_logs_by_filename(
|
||||
instance_id: &str,
|
||||
log_type: LogType,
|
||||
filename: String,
|
||||
) -> Result<()> {
|
||||
Ok(logs::delete_logs_by_filename(instance_id, log_type, &filename).await?)
|
||||
}
|
||||
|
||||
/// Get live log from a cursor
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_latest_log_cursor(
|
||||
instance_id: &str,
|
||||
cursor: u64, // 0 to start at beginning of file
|
||||
) -> Result<LatestLogCursor> {
|
||||
Ok(logs::get_latest_log_cursor(instance_id, cursor).await?)
|
||||
}
|
||||
|
||||
/// Get Minecraft's logs/latest.log from a cursor.
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_minecraft_latest_log_cursor(
|
||||
instance_id: &str,
|
||||
cursor: u64, // 0 to start at beginning of file
|
||||
) -> Result<LatestLogCursor> {
|
||||
Ok(
|
||||
logs::get_generic_live_log_cursor(instance_id, "latest.log", cursor)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
/// Get all buffered live log lines for an instance.
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_live_log_buffer(
|
||||
instance_id: &str,
|
||||
) -> Result<CensoredString> {
|
||||
Ok(logs::get_live_log_buffer(instance_id).await?)
|
||||
}
|
||||
|
||||
/// Clear the live log buffer for an instance.
|
||||
#[tauri::command]
|
||||
pub async fn logs_clear_live_log_buffer(instance_id: &str) -> Result<()> {
|
||||
logs::clear_live_log_buffer(instance_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Collect and locally analyze the files produced by the instance's latest run.
|
||||
#[tauri::command]
|
||||
pub async fn logs_analyze_crash(instance_id: &str) -> Result<CrashAnalysis> {
|
||||
Ok(logs::analyze_crash(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_crash_analysis_ai_settings()
|
||||
-> Result<CrashAnalysisAiSettings> {
|
||||
Ok(logs::get_crash_analysis_ai_settings().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn logs_update_crash_analysis_ai_settings(
|
||||
settings: CrashAnalysisAiSettings,
|
||||
) -> Result<()> {
|
||||
Ok(logs::update_crash_analysis_ai_settings(settings).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn logs_explain_crash_with_ai(
|
||||
instance_id: &str,
|
||||
) -> Result<CrashAnalysisAiExplanation> {
|
||||
Ok(logs::explain_crash_with_ai(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn logs_undo_added_mod(
|
||||
instance_id: &str,
|
||||
filename: &str,
|
||||
expected_hash: &str,
|
||||
) -> Result<()> {
|
||||
Ok(logs::undo_added_mod(instance_id, filename, expected_hash).await?)
|
||||
}
|
||||
|
||||
/// Export the latest run's censored diagnostic context as a ZIP archive.
|
||||
#[tauri::command]
|
||||
pub async fn logs_export_crash_context(
|
||||
instance_id: &str,
|
||||
output_path: PathBuf,
|
||||
) -> Result<()> {
|
||||
let analysis = logs::analyze_crash(instance_id).await?;
|
||||
let archive = tokio::fs::File::create(&output_path).await?;
|
||||
let mut writer = ZipFileWriter::with_tokio(archive);
|
||||
let report = serde_json::to_vec_pretty(&analysis).map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to serialize crash analysis: {error}"
|
||||
)))
|
||||
})?;
|
||||
crate::api::utils::write_zip_entry(&mut writer, "analysis.json", &report)
|
||||
.await?;
|
||||
for source in &analysis.sources {
|
||||
let safe_name = source.filename.replace(['/', '\\'], "_");
|
||||
crate::api::utils::write_zip_entry(
|
||||
&mut writer,
|
||||
&format!("logs/{safe_name}"),
|
||||
source.content.as_str().as_bytes(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
writer.close().await.map_err(crate::api::utils::zip_error)?;
|
||||
Ok(())
|
||||
}
|
||||
48
apps/app/src/api/mcarchive.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use crate::api::Result;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("mcarchive")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
mcarchive_get_game_versions,
|
||||
mcarchive_search_mods,
|
||||
mcarchive_get_mod_by_slug,
|
||||
mcarchive_get_file_by_filename,
|
||||
mcarchive_get_file_by_sha256,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mcarchive_get_game_versions()
|
||||
-> Result<Vec<theseus::mcarchive::McArchiveGameVersion>> {
|
||||
Ok(theseus::mcarchive::get_game_versions().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mcarchive_search_mods(
|
||||
keyword: &str,
|
||||
game_version: Option<&str>,
|
||||
) -> Result<Vec<theseus::mcarchive::McArchiveMod>> {
|
||||
Ok(theseus::mcarchive::search_mods(keyword, game_version).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mcarchive_get_mod_by_slug(
|
||||
slug: &str,
|
||||
) -> Result<theseus::mcarchive::McArchiveMod> {
|
||||
Ok(theseus::mcarchive::get_mod_by_slug(slug).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mcarchive_get_file_by_filename(
|
||||
filename: &str,
|
||||
) -> Result<Option<theseus::mcarchive::McArchiveFile>> {
|
||||
Ok(theseus::mcarchive::get_file_by_filename(filename).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mcarchive_get_file_by_sha256(
|
||||
sha256: &str,
|
||||
) -> Result<Option<theseus::mcarchive::McArchiveFile>> {
|
||||
Ok(theseus::mcarchive::get_file_by_sha256(sha256).await?)
|
||||
}
|
||||
35
apps/app/src/api/metadata.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use crate::api::Result;
|
||||
use daedalus::minecraft::VersionManifest;
|
||||
use daedalus::modded::Manifest;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("metadata")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
metadata_get_game_versions,
|
||||
metadata_get_loader_versions,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
/// Gets the game versions from daedalus
|
||||
#[tauri::command]
|
||||
pub async fn metadata_get_game_versions() -> Result<VersionManifest> {
|
||||
Ok(theseus::metadata::get_minecraft_versions().await?)
|
||||
}
|
||||
|
||||
/// Gets the fabric versions from daedalus
|
||||
#[tauri::command]
|
||||
pub async fn metadata_get_loader_versions(
|
||||
loader: &str,
|
||||
game_version: Option<&str>,
|
||||
) -> Result<Manifest> {
|
||||
if let Some(game_version) = game_version {
|
||||
Ok(theseus::metadata::get_loader_versions_for_game(
|
||||
loader,
|
||||
game_version,
|
||||
)
|
||||
.await?)
|
||||
} else {
|
||||
Ok(theseus::metadata::get_loader_versions(loader).await?)
|
||||
}
|
||||
}
|
||||
147
apps/app/src/api/minecraft_skins.rs
Normal file
@ -0,0 +1,147 @@
|
||||
use crate::api::Result;
|
||||
|
||||
use std::path::Path;
|
||||
use theseus::minecraft_skins::{
|
||||
self, Bytes, Cape, MinecraftSkinVariant, Skin, UrlOrBlob,
|
||||
};
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("minecraft-skins")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_available_capes,
|
||||
get_available_skins,
|
||||
add_and_equip_custom_skin,
|
||||
equip_skin,
|
||||
remove_custom_skin,
|
||||
save_custom_skin,
|
||||
set_custom_skin_order,
|
||||
unequip_skin,
|
||||
flush_pending_skin_change,
|
||||
flush_pending_skin_change_for_profile,
|
||||
normalize_skin_texture,
|
||||
get_dragged_skin_data,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|get_available_capes')`
|
||||
///
|
||||
/// See also: [minecraft_skins::get_available_capes]
|
||||
#[tauri::command]
|
||||
pub async fn get_available_capes() -> Result<Vec<Cape>> {
|
||||
Ok(minecraft_skins::get_available_capes().await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|get_available_skins')`
|
||||
///
|
||||
/// See also: [minecraft_skins::get_available_skins]
|
||||
#[tauri::command]
|
||||
pub async fn get_available_skins() -> Result<Vec<Skin>> {
|
||||
Ok(minecraft_skins::get_available_skins().await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|add_and_equip_custom_skin', texture_blob, variant, cape)`
|
||||
///
|
||||
/// See also: [minecraft_skins::add_and_equip_custom_skin]
|
||||
#[tauri::command]
|
||||
pub async fn add_and_equip_custom_skin(
|
||||
texture_blob: Bytes,
|
||||
variant: MinecraftSkinVariant,
|
||||
cape: Option<Cape>,
|
||||
) -> Result<Skin> {
|
||||
Ok(
|
||||
minecraft_skins::add_and_equip_custom_skin(texture_blob, variant, cape)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|equip_skin', skin)`
|
||||
///
|
||||
/// See also: [minecraft_skins::equip_skin]
|
||||
#[tauri::command]
|
||||
pub async fn equip_skin(skin: Skin) -> Result<()> {
|
||||
Ok(minecraft_skins::equip_skin(skin).await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|remove_custom_skin', skin)`
|
||||
///
|
||||
/// See also: [minecraft_skins::remove_custom_skin]
|
||||
#[tauri::command]
|
||||
pub async fn remove_custom_skin(skin: Skin) -> Result<()> {
|
||||
Ok(minecraft_skins::remove_custom_skin(skin).await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|save_custom_skin', skin, texture_blob, variant, cape, replace_texture)`
|
||||
///
|
||||
/// See also: [minecraft_skins::save_custom_skin]
|
||||
#[tauri::command]
|
||||
pub async fn save_custom_skin(
|
||||
skin: Skin,
|
||||
texture_blob: Bytes,
|
||||
variant: MinecraftSkinVariant,
|
||||
cape: Option<Cape>,
|
||||
replace_texture: bool,
|
||||
) -> Result<Skin> {
|
||||
Ok(minecraft_skins::save_custom_skin(
|
||||
skin,
|
||||
texture_blob,
|
||||
variant,
|
||||
cape,
|
||||
replace_texture,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|set_custom_skin_order', texture_keys)`
|
||||
///
|
||||
/// See also: [minecraft_skins::set_custom_skin_order]
|
||||
#[tauri::command]
|
||||
pub async fn set_custom_skin_order(texture_keys: Vec<String>) -> Result<()> {
|
||||
Ok(minecraft_skins::set_custom_skin_order(texture_keys).await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|unequip_skin')`
|
||||
///
|
||||
/// See also: [minecraft_skins::unequip_skin]
|
||||
#[tauri::command]
|
||||
pub async fn unequip_skin() -> Result<()> {
|
||||
Ok(minecraft_skins::unequip_skin().await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|flush_pending_skin_change')`
|
||||
///
|
||||
/// See also: [minecraft_skins::flush_pending_skin_change]
|
||||
#[tauri::command]
|
||||
pub async fn flush_pending_skin_change() -> Result<()> {
|
||||
Ok(minecraft_skins::flush_pending_skin_change().await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|flush_pending_skin_change_for_profile', profile_id)`
|
||||
///
|
||||
/// See also: [minecraft_skins::flush_pending_skin_change_for_profile]
|
||||
#[tauri::command]
|
||||
pub async fn flush_pending_skin_change_for_profile(
|
||||
profile_id: uuid::Uuid,
|
||||
) -> Result<()> {
|
||||
Ok(
|
||||
minecraft_skins::flush_pending_skin_change_for_profile(profile_id)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|normalize_skin_texture')`
|
||||
///
|
||||
/// See also: [minecraft_skins::normalize_skin_texture]
|
||||
#[tauri::command]
|
||||
pub async fn normalize_skin_texture(texture: UrlOrBlob) -> Result<Bytes> {
|
||||
Ok(minecraft_skins::normalize_skin_texture(&texture).await?)
|
||||
}
|
||||
|
||||
/// `invoke('plugin:minecraft-skins|get_dragged_skin_data', path)`
|
||||
///
|
||||
/// See also: [minecraft_skins::get_dragged_skin_data]
|
||||
#[tauri::command]
|
||||
pub async fn get_dragged_skin_data(path: String) -> Result<Bytes> {
|
||||
let path = Path::new(&path);
|
||||
Ok(minecraft_skins::get_dragged_skin_data(path).await?)
|
||||
}
|
||||
142
apps/app/src/api/mod.rs
Normal file
@ -0,0 +1,142 @@
|
||||
use serde::ser::SerializeStruct;
|
||||
use serde::{Serialize, Serializer};
|
||||
use thiserror::Error;
|
||||
|
||||
pub mod ai;
|
||||
pub mod auth;
|
||||
pub mod import;
|
||||
pub mod install;
|
||||
pub mod instance;
|
||||
pub mod jre;
|
||||
pub mod logs;
|
||||
pub mod mcarchive;
|
||||
pub mod metadata;
|
||||
pub mod minecraft_skins;
|
||||
pub mod mod_translation;
|
||||
pub mod mr_auth;
|
||||
pub mod multiplayer;
|
||||
pub mod planet_minecraft;
|
||||
pub mod process;
|
||||
pub mod schematic_preview;
|
||||
pub mod seed_map;
|
||||
pub mod servers;
|
||||
pub mod settings;
|
||||
pub mod shortcuts;
|
||||
pub mod storage;
|
||||
pub mod system_accent;
|
||||
pub mod tags;
|
||||
pub mod telemetry;
|
||||
pub mod terracotta;
|
||||
pub mod translation;
|
||||
pub mod utils;
|
||||
|
||||
pub mod cache;
|
||||
pub mod content_favorites;
|
||||
pub mod content_search;
|
||||
pub mod curseforge;
|
||||
pub mod datapacks;
|
||||
pub mod drop;
|
||||
pub mod files;
|
||||
pub mod friends;
|
||||
pub mod worlds;
|
||||
|
||||
mod oauth_utils;
|
||||
mod search_cancellation;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;
|
||||
|
||||
// // Main returnable Theseus GUI error
|
||||
// // Needs to be Serializable to be returned to the JavaScript side
|
||||
// #[derive(Error, Debug, Serialize)]
|
||||
// pub enum TheseusGuiError {
|
||||
// #[error(transparent)]
|
||||
// Serializable(),
|
||||
// }
|
||||
|
||||
// Serializable error intermediary, so TheseusGuiError can be Serializable (eg: so that we can return theseus::Errors in Tauri directly)
|
||||
#[derive(Error, Debug)]
|
||||
pub enum TheseusSerializableError {
|
||||
#[error("{0}")]
|
||||
Theseus(#[from] theseus::Error),
|
||||
|
||||
#[error("IO error: {0}")]
|
||||
IO(#[from] std::io::Error),
|
||||
|
||||
#[error("Tauri error: {0}")]
|
||||
Tauri(#[from] tauri::Error),
|
||||
|
||||
#[cfg(feature = "updater")]
|
||||
#[error("Updater error: {0}")]
|
||||
Updater(#[from] tauri_plugin_updater::Error),
|
||||
|
||||
#[cfg(feature = "updater")]
|
||||
#[error("HTTP error: {0}")]
|
||||
Http(#[from] tauri_plugin_http::reqwest::Error),
|
||||
|
||||
#[error("Search request cancelled: {0}")]
|
||||
SearchCancelled(String),
|
||||
}
|
||||
|
||||
// Generic implementation of From<T> for ErrorTypeA
|
||||
// impl<T> From<T> for TheseusGuiError
|
||||
// where
|
||||
// TheseusSerializableError: From<T>,
|
||||
// {
|
||||
// fn from(error: T) -> Self {
|
||||
// TheseusGuiError::Serializable(TheseusSerializableError::from(error))
|
||||
// }
|
||||
// }
|
||||
|
||||
// This is a very simple macro that implements a very basic Serializable for each variant of TheseusSerializableError,
|
||||
// where the field is the string. (This allows easy extension to errors without many match arms)
|
||||
macro_rules! impl_serialize {
|
||||
($($variant:ident),* $(,)?) => {
|
||||
impl Serialize for TheseusSerializableError {
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
match self {
|
||||
// For the Theseus variant, we add a special display for the error,
|
||||
// to view the spans if subscribed to them (which is information that is lost when serializing)
|
||||
TheseusSerializableError::Theseus(theseus_error) => {
|
||||
$crate::error::display_tracing_error(theseus_error);
|
||||
|
||||
let mut state = serializer.serialize_struct("Theseus", 2)?;
|
||||
state.serialize_field("field_name", "Theseus")?;
|
||||
state.serialize_field(
|
||||
"message",
|
||||
&theseus_error.user_facing_message(),
|
||||
)?;
|
||||
state.end()
|
||||
}
|
||||
$(
|
||||
TheseusSerializableError::$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()
|
||||
},
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Use the macro to implement Serialize for TheseusSerializableError
|
||||
#[cfg(not(feature = "updater"))]
|
||||
impl_serialize! {
|
||||
IO,
|
||||
Tauri,
|
||||
SearchCancelled,
|
||||
}
|
||||
|
||||
#[cfg(feature = "updater")]
|
||||
impl_serialize! {
|
||||
IO,
|
||||
Tauri,
|
||||
Updater,
|
||||
Http,
|
||||
SearchCancelled,
|
||||
}
|
||||
754
apps/app/src/api/mod_translation.rs
Normal file
@ -0,0 +1,754 @@
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use std::sync::{Arc, Mutex, OnceLock};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use tauri::{Emitter, Runtime};
|
||||
|
||||
use crate::mod_translation;
|
||||
use crate::mod_translation::analyze::{AnalysisSummary, JarInspection};
|
||||
use crate::mod_translation::error::TranslateErrorCode;
|
||||
use crate::mod_translation::repair::{RepairActivity, RepairEmitter};
|
||||
use crate::mod_translation::translate::{
|
||||
PreparedTranslationWorkspace, TranslationReport, TranslationSample,
|
||||
};
|
||||
|
||||
const WORKSPACE_SUBDIR: &str = "mod-translation";
|
||||
const TASK_EVENT: &str = "mod-translation-task-event";
|
||||
const ANALYSIS_TTL: Duration = Duration::from_secs(30 * 60);
|
||||
const MAX_SNAPSHOT_EVENTS: usize = 400;
|
||||
|
||||
struct TaskHandle {
|
||||
cancel: Arc<AtomicBool>,
|
||||
sequence: AtomicU64,
|
||||
event_gate: Mutex<()>,
|
||||
snapshot: Mutex<TaskSnapshot>,
|
||||
lock_keys: Vec<String>,
|
||||
}
|
||||
|
||||
struct PreparedAnalysis {
|
||||
created_at: SystemTime,
|
||||
input_path: PathBuf,
|
||||
input_hash: String,
|
||||
workspace: PathBuf,
|
||||
inspection: JarInspection,
|
||||
}
|
||||
|
||||
static TASKS: OnceLock<Mutex<HashMap<String, Arc<TaskHandle>>>> =
|
||||
OnceLock::new();
|
||||
static ACTIVE_LOCKS: OnceLock<Mutex<HashMap<String, String>>> = OnceLock::new();
|
||||
static ANALYSES: OnceLock<Mutex<HashMap<String, PreparedAnalysis>>> =
|
||||
OnceLock::new();
|
||||
|
||||
fn tasks() -> &'static Mutex<HashMap<String, Arc<TaskHandle>>> {
|
||||
TASKS.get_or_init(|| Mutex::new(HashMap::new()))
|
||||
}
|
||||
|
||||
fn active_locks() -> &'static Mutex<HashMap<String, String>> {
|
||||
ACTIVE_LOCKS.get_or_init(|| Mutex::new(HashMap::new()))
|
||||
}
|
||||
|
||||
fn analyses() -> &'static Mutex<HashMap<String, PreparedAnalysis>> {
|
||||
ANALYSES.get_or_init(|| Mutex::new(HashMap::new()))
|
||||
}
|
||||
|
||||
pub fn init<R: Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("mod-translation")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
mod_translation_analyze,
|
||||
mod_translation_translate,
|
||||
mod_translation_cancel,
|
||||
mod_translation_list_tasks,
|
||||
mod_translation_get_task,
|
||||
mod_translation_dismiss_task,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ModTranslationOptions {
|
||||
#[serde(default = "default_batch_size")]
|
||||
pub batch_size: usize,
|
||||
#[serde(default = "default_deep_batch_size")]
|
||||
pub deep_batch_size: usize,
|
||||
#[serde(default)]
|
||||
pub generate_mod_name: bool,
|
||||
#[serde(default = "default_repair_enabled")]
|
||||
pub repair_enabled: bool,
|
||||
#[serde(default)]
|
||||
pub class_text_enabled: bool,
|
||||
#[serde(default = "default_class_batch")]
|
||||
pub max_class_batch: usize,
|
||||
}
|
||||
|
||||
impl Default for ModTranslationOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
batch_size: default_batch_size(),
|
||||
deep_batch_size: default_deep_batch_size(),
|
||||
generate_mod_name: false,
|
||||
repair_enabled: default_repair_enabled(),
|
||||
class_text_enabled: false,
|
||||
max_class_batch: default_class_batch(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_batch_size() -> usize {
|
||||
40
|
||||
}
|
||||
|
||||
fn default_deep_batch_size() -> usize {
|
||||
24
|
||||
}
|
||||
|
||||
fn default_repair_enabled() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_class_batch() -> usize {
|
||||
16
|
||||
}
|
||||
|
||||
impl From<ModTranslationOptions>
|
||||
for mod_translation::translate::TranslateOptions
|
||||
{
|
||||
fn from(value: ModTranslationOptions) -> Self {
|
||||
Self {
|
||||
batch_size: value.batch_size.clamp(10, 80),
|
||||
deep_batch_size: value.deep_batch_size.clamp(4, 40),
|
||||
generate_mod_name: value.generate_mod_name,
|
||||
repair_enabled: value.repair_enabled,
|
||||
class_text_enabled: value.class_text_enabled,
|
||||
max_class_batch: value.max_class_batch.clamp(4, 20),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ModTranslationAnalysis {
|
||||
pub analysis_id: String,
|
||||
pub input_hash: String,
|
||||
#[serde(flatten)]
|
||||
pub summary: AnalysisSummary,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TaskFailure {
|
||||
pub code: String,
|
||||
pub message: String,
|
||||
pub details: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ModTranslationTaskEvent {
|
||||
pub event_id: String,
|
||||
pub task_id: String,
|
||||
pub sequence: u64,
|
||||
pub occurred_at: String,
|
||||
pub event_type: String,
|
||||
pub status: String,
|
||||
pub progress: Option<TranslationSample>,
|
||||
pub activity: Option<RepairActivity>,
|
||||
pub report: Option<TranslationReport>,
|
||||
pub error: Option<TaskFailure>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TaskSnapshot {
|
||||
pub task_id: String,
|
||||
pub input_path: PathBuf,
|
||||
pub output_path: PathBuf,
|
||||
pub input_hash: String,
|
||||
pub started_at: String,
|
||||
pub updated_at: String,
|
||||
pub status: String,
|
||||
pub sequence: u64,
|
||||
pub progress: Option<TranslationSample>,
|
||||
pub activities: Vec<RepairActivity>,
|
||||
pub report: Option<TranslationReport>,
|
||||
pub error: Option<TaskFailure>,
|
||||
pub events: Vec<ModTranslationTaskEvent>,
|
||||
}
|
||||
|
||||
async fn workspace_root() -> crate::api::Result<PathBuf> {
|
||||
let state = theseus::State::get().await?;
|
||||
Ok(state.directories.caches_dir().join(WORKSPACE_SUBDIR))
|
||||
}
|
||||
|
||||
fn to_command_error(error: mod_translation::error::TranslateError) -> String {
|
||||
tracing::error!(code = ?error.code, message = %error.message, "mod translation command failed");
|
||||
error.user_message()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mod_translation_analyze(
|
||||
input_path: String,
|
||||
) -> Result<ModTranslationAnalysis, String> {
|
||||
let root = workspace_root().await.map_err(|error| error.to_string())?;
|
||||
let input = PathBuf::from(&input_path);
|
||||
if !input.is_file() {
|
||||
return Err("找不到输入 JAR 文件".to_string());
|
||||
}
|
||||
let input_for_analysis = input.clone();
|
||||
let (directory, inspection, input_hash) =
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let input_hash =
|
||||
mod_translation::analyze::input_file_hash(&input_for_analysis)
|
||||
.map_err(to_command_error)?;
|
||||
let (directory, inspection) =
|
||||
mod_translation::analyze::extract_and_inspect(
|
||||
&input_for_analysis,
|
||||
&root,
|
||||
)
|
||||
.map_err(to_command_error)?;
|
||||
Ok::<_, String>((directory, inspection, input_hash))
|
||||
})
|
||||
.await
|
||||
.map_err(|error| error.to_string())??;
|
||||
let analysis_id = format!("ANALYSIS-{}", uuid::Uuid::new_v4());
|
||||
let summary = mod_translation::translate::analysis_summary(&inspection);
|
||||
let mut registry = analyses()
|
||||
.lock()
|
||||
.map_err(|_| "分析注册表不可用".to_string())?;
|
||||
prune_analyses(&mut registry);
|
||||
registry.insert(
|
||||
analysis_id.clone(),
|
||||
PreparedAnalysis {
|
||||
created_at: SystemTime::now(),
|
||||
input_path: input,
|
||||
input_hash: input_hash.clone(),
|
||||
workspace: directory,
|
||||
inspection,
|
||||
},
|
||||
);
|
||||
Ok(ModTranslationAnalysis {
|
||||
analysis_id,
|
||||
input_hash,
|
||||
summary,
|
||||
})
|
||||
}
|
||||
|
||||
async fn validate_ai_config(
|
||||
provider_id: &str,
|
||||
model_id: &str,
|
||||
) -> Result<(), String> {
|
||||
let state = theseus::ai::get_state()
|
||||
.await
|
||||
.map_err(|error| error.to_string())?;
|
||||
if !state.settings.enabled {
|
||||
return Err(format!(
|
||||
"{}: 请在 AI 设置中启用 AI 功能后再试",
|
||||
TranslateErrorCode::AiDisabled.as_str()
|
||||
));
|
||||
}
|
||||
let Some(provider) = state
|
||||
.providers
|
||||
.iter()
|
||||
.find(|provider| provider.provider_id == provider_id)
|
||||
else {
|
||||
return Err(format!(
|
||||
"{}: 未找到已配置的 AI 提供商 {provider_id},请先在 AI 设置中添加",
|
||||
TranslateErrorCode::AiProviderDisabled.as_str()
|
||||
));
|
||||
};
|
||||
if !provider.enabled {
|
||||
return Err(format!(
|
||||
"{}: AI 提供商 {provider_id} 当前已禁用,请在 AI 设置中启用",
|
||||
TranslateErrorCode::AiProviderDisabled.as_str()
|
||||
));
|
||||
}
|
||||
if model_id.trim().is_empty()
|
||||
|| !provider.models.iter().any(|model| model.id == model_id)
|
||||
{
|
||||
return Err(format!(
|
||||
"{}: 请先在翻译设置或 AI 设置中选择模型",
|
||||
TranslateErrorCode::AiModelNotSelected.as_str()
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mod_translation_translate<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
input_path: String,
|
||||
output_path: String,
|
||||
provider_id: String,
|
||||
model_id: String,
|
||||
analysis_id: Option<String>,
|
||||
input_hash: Option<String>,
|
||||
options: Option<ModTranslationOptions>,
|
||||
) -> Result<TaskSnapshot, String> {
|
||||
validate_ai_config(&provider_id, &model_id).await?;
|
||||
let input = PathBuf::from(&input_path);
|
||||
let output = PathBuf::from(&output_path);
|
||||
if !input.is_file() {
|
||||
return Err("找不到输入 JAR 文件".to_string());
|
||||
}
|
||||
if !mod_translation::jar::is_clean_absolute_path(&output) {
|
||||
return Err("输出路径必须是合法的绝对路径".to_string());
|
||||
}
|
||||
if output.exists() {
|
||||
return Err(format!("输出文件已存在:{}", output.display()));
|
||||
}
|
||||
let actual_hash = {
|
||||
let input = input.clone();
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
mod_translation::analyze::input_file_hash(&input)
|
||||
})
|
||||
.await
|
||||
.map_err(|error| error.to_string())?
|
||||
.map_err(to_command_error)?
|
||||
};
|
||||
let root = workspace_root().await.map_err(|error| error.to_string())?;
|
||||
let task_id = new_task_id();
|
||||
let lock_keys = vec![
|
||||
format!("output:{}", normalized_path_lock_key(&output)),
|
||||
format!("checkpoint:{actual_hash}"),
|
||||
];
|
||||
claim_locks(&task_id, &lock_keys)?;
|
||||
let prepared = match take_prepared_analysis(
|
||||
analysis_id.as_deref(),
|
||||
input_hash.as_deref(),
|
||||
&actual_hash,
|
||||
&input,
|
||||
) {
|
||||
Ok(prepared) => prepared,
|
||||
Err(error) => {
|
||||
release_lock_keys(&task_id, &lock_keys);
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
let now = iso_now();
|
||||
let snapshot = TaskSnapshot {
|
||||
task_id: task_id.clone(),
|
||||
input_path: input.clone(),
|
||||
output_path: output.clone(),
|
||||
input_hash: actual_hash,
|
||||
started_at: now.clone(),
|
||||
updated_at: now,
|
||||
status: "running".to_string(),
|
||||
sequence: 0,
|
||||
progress: None,
|
||||
activities: Vec::new(),
|
||||
report: None,
|
||||
error: None,
|
||||
events: Vec::new(),
|
||||
};
|
||||
let handle = Arc::new(TaskHandle {
|
||||
cancel: Arc::new(AtomicBool::new(false)),
|
||||
sequence: AtomicU64::new(0),
|
||||
event_gate: Mutex::new(()),
|
||||
snapshot: Mutex::new(snapshot.clone()),
|
||||
lock_keys,
|
||||
});
|
||||
match tasks().lock() {
|
||||
Ok(mut registry) => {
|
||||
registry.insert(task_id.clone(), handle.clone());
|
||||
}
|
||||
Err(_) => {
|
||||
release_lock_keys(&task_id, &handle.lock_keys);
|
||||
if let Some(prepared) = &prepared {
|
||||
let _ = std::fs::remove_dir_all(&prepared.workspace);
|
||||
}
|
||||
return Err("任务注册表不可用".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
let mut translate_options: mod_translation::translate::TranslateOptions =
|
||||
options.unwrap_or_default().into();
|
||||
translate_options.provider_id = provider_id;
|
||||
translate_options.model_id = model_id;
|
||||
let emitter = make_progress_emitter(app.clone(), handle.clone());
|
||||
let repair_emitter = make_repair_emitter(app.clone(), handle.clone());
|
||||
let cancel = handle.cancel.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let result = mod_translation::translate::run_translation_task(
|
||||
task_id.clone(),
|
||||
input,
|
||||
output,
|
||||
translate_options,
|
||||
root,
|
||||
prepared,
|
||||
cancel,
|
||||
emitter,
|
||||
repair_emitter,
|
||||
)
|
||||
.await;
|
||||
if let Err(error) = result {
|
||||
ensure_terminal_error(&app, &handle, &error);
|
||||
}
|
||||
release_locks(&handle);
|
||||
});
|
||||
Ok(snapshot)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn mod_translation_cancel(task_id: String) -> Result<(), String> {
|
||||
if let Some(handle) = tasks()
|
||||
.lock()
|
||||
.map_err(|_| "任务注册表不可用".to_string())?
|
||||
.get(&task_id)
|
||||
{
|
||||
handle.cancel.store(true, Ordering::Relaxed);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn mod_translation_list_tasks() -> Result<Vec<TaskSnapshot>, String> {
|
||||
let registry =
|
||||
tasks().lock().map_err(|_| "任务注册表不可用".to_string())?;
|
||||
let mut snapshots = registry
|
||||
.values()
|
||||
.filter_map(|handle| {
|
||||
handle.snapshot.lock().ok().map(|snapshot| snapshot.clone())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
snapshots.sort_by(|left, right| right.started_at.cmp(&left.started_at));
|
||||
Ok(snapshots)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn mod_translation_get_task(
|
||||
task_id: String,
|
||||
) -> Result<Option<TaskSnapshot>, String> {
|
||||
let registry =
|
||||
tasks().lock().map_err(|_| "任务注册表不可用".to_string())?;
|
||||
Ok(registry.get(&task_id).and_then(|handle| {
|
||||
handle.snapshot.lock().ok().map(|snapshot| snapshot.clone())
|
||||
}))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn mod_translation_dismiss_task(task_id: String) -> Result<(), String> {
|
||||
let mut registry =
|
||||
tasks().lock().map_err(|_| "任务注册表不可用".to_string())?;
|
||||
let Some(handle) = registry.get(&task_id) else {
|
||||
return Ok(());
|
||||
};
|
||||
let running = handle
|
||||
.snapshot
|
||||
.lock()
|
||||
.map_err(|_| "任务快照不可用".to_string())?
|
||||
.status
|
||||
== "running";
|
||||
if running {
|
||||
return Err("运行中的任务不能移除,请先取消".to_string());
|
||||
}
|
||||
registry.remove(&task_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn make_progress_emitter<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
handle: Arc<TaskHandle>,
|
||||
) -> mod_translation::translate::EventEmitter {
|
||||
Arc::new(move |progress: TranslationSample| {
|
||||
let report = progress.report.as_deref().and_then(|value| {
|
||||
serde_json::from_str::<TranslationReport>(value).ok()
|
||||
});
|
||||
let error = if progress.finished && !progress.ok {
|
||||
Some(parse_failure(
|
||||
progress.report.as_deref().unwrap_or(&progress.message),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
emit_task_event(
|
||||
&app,
|
||||
&handle,
|
||||
"progress",
|
||||
Some(progress),
|
||||
None,
|
||||
report,
|
||||
error,
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
fn make_repair_emitter<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
handle: Arc<TaskHandle>,
|
||||
) -> RepairEmitter {
|
||||
Arc::new(move |activity: RepairActivity| {
|
||||
emit_task_event(
|
||||
&app,
|
||||
&handle,
|
||||
"activity",
|
||||
None,
|
||||
Some(activity),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
fn emit_task_event<R: Runtime>(
|
||||
app: &tauri::AppHandle<R>,
|
||||
handle: &Arc<TaskHandle>,
|
||||
event_type: &str,
|
||||
progress: Option<TranslationSample>,
|
||||
activity: Option<RepairActivity>,
|
||||
report: Option<TranslationReport>,
|
||||
error: Option<TaskFailure>,
|
||||
) {
|
||||
let Ok(_event_guard) = handle.event_gate.lock() else {
|
||||
return;
|
||||
};
|
||||
let event = {
|
||||
let Ok(mut snapshot) = handle.snapshot.lock() else {
|
||||
return;
|
||||
};
|
||||
let sequence = handle.sequence.fetch_add(1, Ordering::SeqCst) + 1;
|
||||
let occurred_at = iso_now();
|
||||
if let Some(progress) = &progress {
|
||||
snapshot.progress = Some(progress.clone());
|
||||
if progress.finished {
|
||||
snapshot.status =
|
||||
if progress.ok { "completed" } else { "failed" }
|
||||
.to_string();
|
||||
}
|
||||
}
|
||||
if let Some(activity) = &activity {
|
||||
snapshot.activities.push(activity.clone());
|
||||
if snapshot.activities.len() > MAX_SNAPSHOT_EVENTS {
|
||||
snapshot.activities.remove(0);
|
||||
}
|
||||
}
|
||||
if report.is_some() {
|
||||
snapshot.report = report.clone();
|
||||
}
|
||||
if error.is_some() {
|
||||
snapshot.error = error.clone();
|
||||
snapshot.status = "failed".to_string();
|
||||
}
|
||||
snapshot.sequence = sequence;
|
||||
snapshot.updated_at = occurred_at.clone();
|
||||
let event = ModTranslationTaskEvent {
|
||||
event_id: format!("EVENT-{}", uuid::Uuid::new_v4()),
|
||||
task_id: snapshot.task_id.clone(),
|
||||
sequence,
|
||||
occurred_at,
|
||||
event_type: event_type.to_string(),
|
||||
status: snapshot.status.clone(),
|
||||
progress,
|
||||
activity,
|
||||
report,
|
||||
error,
|
||||
};
|
||||
snapshot.events.push(event.clone());
|
||||
if snapshot.events.len() > MAX_SNAPSHOT_EVENTS {
|
||||
snapshot.events.remove(0);
|
||||
}
|
||||
event
|
||||
};
|
||||
if let Err(error) = app.emit(TASK_EVENT, event) {
|
||||
tracing::warn!(error = %error, "mod translation task event emit failed");
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_terminal_error<R: Runtime>(
|
||||
app: &tauri::AppHandle<R>,
|
||||
handle: &Arc<TaskHandle>,
|
||||
error: &mod_translation::error::TranslateError,
|
||||
) {
|
||||
let already_terminal = handle
|
||||
.snapshot
|
||||
.lock()
|
||||
.map(|snapshot| {
|
||||
snapshot.status != "running" && snapshot.error.is_some()
|
||||
})
|
||||
.unwrap_or(false);
|
||||
if already_terminal {
|
||||
return;
|
||||
}
|
||||
emit_task_event(
|
||||
app,
|
||||
handle,
|
||||
"finished",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(TaskFailure {
|
||||
code: error.code.as_str().to_string(),
|
||||
message: error.message.clone(),
|
||||
details: None,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
fn parse_failure(value: &str) -> TaskFailure {
|
||||
let (code, message) = value
|
||||
.split_once(": ")
|
||||
.map(|(code, message)| (code.to_string(), message.to_string()))
|
||||
.unwrap_or_else(|| ("UNKNOWN".to_string(), value.to_string()));
|
||||
let details = message
|
||||
.rsplit_once(';')
|
||||
.and_then(|(_, json)| serde_json::from_str::<Value>(json).ok());
|
||||
TaskFailure {
|
||||
code,
|
||||
message,
|
||||
details,
|
||||
}
|
||||
}
|
||||
|
||||
fn take_prepared_analysis(
|
||||
analysis_id: Option<&str>,
|
||||
requested_hash: Option<&str>,
|
||||
actual_hash: &str,
|
||||
input_path: &PathBuf,
|
||||
) -> Result<Option<PreparedTranslationWorkspace>, String> {
|
||||
let Some(analysis_id) = analysis_id else {
|
||||
return Ok(None);
|
||||
};
|
||||
let mut registry = analyses()
|
||||
.lock()
|
||||
.map_err(|_| "分析注册表不可用".to_string())?;
|
||||
prune_analyses(&mut registry);
|
||||
let Some(prepared) = registry.remove(analysis_id) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let matches = requested_hash == Some(prepared.input_hash.as_str())
|
||||
&& prepared.input_hash == actual_hash
|
||||
&& prepared.input_path == *input_path
|
||||
&& prepared.workspace.is_dir();
|
||||
if !matches {
|
||||
let _ = std::fs::remove_dir_all(prepared.workspace);
|
||||
return Ok(None);
|
||||
}
|
||||
Ok(Some(PreparedTranslationWorkspace {
|
||||
workspace: prepared.workspace,
|
||||
inspection: prepared.inspection,
|
||||
input_hash: prepared.input_hash,
|
||||
}))
|
||||
}
|
||||
|
||||
fn prune_analyses(registry: &mut HashMap<String, PreparedAnalysis>) {
|
||||
let now = SystemTime::now();
|
||||
let expired = registry
|
||||
.iter()
|
||||
.filter_map(|(id, prepared)| {
|
||||
now.duration_since(prepared.created_at)
|
||||
.ok()
|
||||
.filter(|age| *age > ANALYSIS_TTL)
|
||||
.map(|_| id.clone())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
for id in expired {
|
||||
if let Some(prepared) = registry.remove(&id) {
|
||||
let _ = std::fs::remove_dir_all(prepared.workspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn claim_locks(task_id: &str, keys: &[String]) -> Result<(), String> {
|
||||
let mut locks = active_locks()
|
||||
.lock()
|
||||
.map_err(|_| "任务锁不可用".to_string())?;
|
||||
if let Some(key) = keys.iter().find(|key| locks.contains_key(*key)) {
|
||||
return Err(format!("该输出或检查点已有运行中的任务:{key}"));
|
||||
}
|
||||
for key in keys {
|
||||
locks.insert(key.clone(), task_id.to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn normalized_path_lock_key(path: &std::path::Path) -> String {
|
||||
let normalized = path.to_string_lossy().replace('\\', "/");
|
||||
if cfg!(windows) {
|
||||
normalized.to_lowercase()
|
||||
} else {
|
||||
normalized
|
||||
}
|
||||
}
|
||||
|
||||
fn release_locks(handle: &TaskHandle) {
|
||||
let task_id = handle
|
||||
.snapshot
|
||||
.lock()
|
||||
.ok()
|
||||
.map(|snapshot| snapshot.task_id.clone())
|
||||
.unwrap_or_default();
|
||||
release_lock_keys(&task_id, &handle.lock_keys);
|
||||
}
|
||||
|
||||
fn release_lock_keys(task_id: &str, keys: &[String]) {
|
||||
if let Ok(mut locks) = active_locks().lock() {
|
||||
for key in keys {
|
||||
if locks.get(key).is_some_and(|owner| owner == task_id) {
|
||||
locks.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn new_task_id() -> String {
|
||||
let timestamp = chrono::Utc::now().format("%Y%m%dT%H%M%S").to_string();
|
||||
format!("TASK-{timestamp}-{}", uuid::Uuid::new_v4().simple())
|
||||
}
|
||||
|
||||
fn iso_now() -> String {
|
||||
chrono::Utc::now().to_rfc3339()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn handle(task_id: &str, lock_keys: Vec<String>) -> TaskHandle {
|
||||
let now = iso_now();
|
||||
TaskHandle {
|
||||
cancel: Arc::new(AtomicBool::new(false)),
|
||||
sequence: AtomicU64::new(0),
|
||||
event_gate: Mutex::new(()),
|
||||
snapshot: Mutex::new(TaskSnapshot {
|
||||
task_id: task_id.to_string(),
|
||||
input_path: PathBuf::from("C:/mods/demo.jar"),
|
||||
output_path: PathBuf::from("C:/mods/demo-zh_cn.jar"),
|
||||
input_hash: "hash".to_string(),
|
||||
started_at: now.clone(),
|
||||
updated_at: now,
|
||||
status: "running".to_string(),
|
||||
sequence: 0,
|
||||
progress: None,
|
||||
activities: Vec::new(),
|
||||
report: None,
|
||||
error: None,
|
||||
events: Vec::new(),
|
||||
}),
|
||||
lock_keys,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_output_or_checkpoint_locks_are_rejected_until_release() {
|
||||
let key = format!("output:test-{}", uuid::Uuid::new_v4());
|
||||
claim_locks("TASK-a", std::slice::from_ref(&key)).unwrap();
|
||||
assert!(claim_locks("TASK-b", std::slice::from_ref(&key)).is_err());
|
||||
let first = handle("TASK-a", vec![key.clone()]);
|
||||
release_locks(&first);
|
||||
claim_locks("TASK-b", std::slice::from_ref(&key)).unwrap();
|
||||
let second = handle("TASK-b", vec![key]);
|
||||
release_locks(&second);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn task_failures_preserve_the_backend_error_code() {
|
||||
let failure =
|
||||
parse_failure("UNSUPPORTED_RESOURCE: assets/demo/data.txt");
|
||||
assert_eq!(failure.code, "UNSUPPORTED_RESOURCE");
|
||||
assert_eq!(failure.message, "assets/demo/data.txt");
|
||||
}
|
||||
}
|
||||
84
apps/app/src/api/mr_auth.rs
Normal file
@ -0,0 +1,84 @@
|
||||
use crate::api::Result;
|
||||
use crate::api::TheseusSerializableError;
|
||||
use crate::api::oauth_utils;
|
||||
use tauri::Manager;
|
||||
use tauri::Runtime;
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
use theseus::prelude::*;
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("mr-auth")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
modrinth_login,
|
||||
logout,
|
||||
get,
|
||||
cancel_modrinth_login,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn modrinth_login<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
) -> Result<ModrinthCredentials> {
|
||||
let (auth_code_recv_socket_tx, auth_code_recv_socket) = oneshot::channel();
|
||||
let auth_code = tokio::spawn(oauth_utils::auth_code_reply::listen(
|
||||
auth_code_recv_socket_tx,
|
||||
));
|
||||
|
||||
let auth_code_recv_socket = auth_code_recv_socket.await.unwrap()?;
|
||||
|
||||
let auth_request_uri = format!(
|
||||
"{}?launcher=true&ipver={}&port={}",
|
||||
mr_auth::authenticate_begin_flow(),
|
||||
if auth_code_recv_socket.is_ipv4() {
|
||||
"4"
|
||||
} else {
|
||||
"6"
|
||||
},
|
||||
auth_code_recv_socket.port()
|
||||
);
|
||||
|
||||
app.opener()
|
||||
.open_url(auth_request_uri, None::<&str>)
|
||||
.map_err(|e| {
|
||||
TheseusSerializableError::Theseus(
|
||||
theseus::ErrorKind::OtherError(format!(
|
||||
"Failed to open auth request URI: {e}"
|
||||
))
|
||||
.into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let Some(auth_reply) = auth_code.await.unwrap()? else {
|
||||
return Err(TheseusSerializableError::Theseus(
|
||||
theseus::ErrorKind::OtherError("Login canceled".into()).into(),
|
||||
));
|
||||
};
|
||||
|
||||
let credentials =
|
||||
mr_auth::authenticate_finish_flow(&auth_reply.code).await?;
|
||||
|
||||
if let Some(main_window) = app.get_window("main") {
|
||||
main_window.set_focus().ok();
|
||||
}
|
||||
|
||||
Ok(credentials)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn logout() -> Result<()> {
|
||||
Ok(theseus::mr_auth::logout().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get() -> Result<Option<ModrinthCredentials>> {
|
||||
Ok(theseus::mr_auth::get_credentials().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn cancel_modrinth_login() {
|
||||
oauth_utils::auth_code_reply::stop_listeners();
|
||||
}
|
||||
110
apps/app/src/api/multiplayer.rs
Normal file
@ -0,0 +1,110 @@
|
||||
use crate::api::Result;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("multiplayer")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
multiplayer_get_state,
|
||||
multiplayer_get_nodes,
|
||||
multiplayer_get_detected_ports,
|
||||
multiplayer_download_hongshi,
|
||||
multiplayer_switch_provider,
|
||||
multiplayer_prepare_terracotta,
|
||||
multiplayer_host,
|
||||
multiplayer_join,
|
||||
multiplayer_stop,
|
||||
multiplayer_reset,
|
||||
multiplayer_get_player_name,
|
||||
multiplayer_open_hongshi_logs,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_download_hongshi() -> Result<()> {
|
||||
Ok(theseus::hongshi::download()
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_get_state()
|
||||
-> Result<theseus::multiplayer::MultiplayerState> {
|
||||
Ok(theseus::multiplayer::get_state().await)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_get_nodes(
|
||||
force_refresh: Option<bool>,
|
||||
) -> Result<Vec<theseus::hongshi::HongshiNode>> {
|
||||
Ok(theseus::hongshi::get_nodes(force_refresh.unwrap_or(false))
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_get_detected_ports()
|
||||
-> Result<Vec<theseus::hongshi::DetectedLanPort>> {
|
||||
Ok(theseus::hongshi::get_detected_ports().await)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_switch_provider(
|
||||
provider: theseus::multiplayer::MultiplayerProvider,
|
||||
) -> Result<()> {
|
||||
Ok(theseus::multiplayer::switch_provider(provider)
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_prepare_terracotta() -> Result<()> {
|
||||
Ok(theseus::multiplayer::prepare_terracotta()
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_host(
|
||||
request: theseus::multiplayer::MultiplayerHostRequest,
|
||||
) -> Result<()> {
|
||||
Ok(theseus::multiplayer::host(request)
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_join(
|
||||
request: theseus::multiplayer::MultiplayerJoinRequest,
|
||||
) -> Result<()> {
|
||||
Ok(theseus::multiplayer::join(request)
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_stop() -> Result<()> {
|
||||
Ok(theseus::multiplayer::stop()
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_reset() -> Result<()> {
|
||||
Ok(theseus::multiplayer::reset()
|
||||
.await
|
||||
.map_err(theseus::Error::from)?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_get_player_name() -> Result<String> {
|
||||
Ok(theseus::terracotta::get_player_name().await)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn multiplayer_open_hongshi_logs<R: tauri::Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
) -> Result<()> {
|
||||
tokio::fs::create_dir_all(theseus::hongshi::logs_dir()).await?;
|
||||
crate::api::utils::open_path(app, theseus::hongshi::logs_dir()).await;
|
||||
Ok(())
|
||||
}
|
||||
219
apps/app/src/api/oauth_utils/auth_code_reply.rs
Normal file
@ -0,0 +1,219 @@
|
||||
//! A minimal OAuth 2.0 authorization code grant flow redirection/reply loopback URI HTTP
|
||||
//! server implementation, compliant with [RFC 6749]'s authorization code grant flow and
|
||||
//! [RFC 8252]'s best current practices for OAuth 2.0 in native apps.
|
||||
//!
|
||||
//! This server is needed for the step 4 of the OAuth authentication dance represented in
|
||||
//! figure 1 of [RFC 8252].
|
||||
//!
|
||||
//! Further reading: https://www.oauth.com/oauth2-servers/oauth-native-apps/redirect-urls-for-native-apps/
|
||||
//!
|
||||
//! [RFC 6749]: https://datatracker.ietf.org/doc/html/rfc6749
|
||||
//! [RFC 8252]: https://datatracker.ietf.org/doc/html/rfc8252
|
||||
|
||||
use std::{
|
||||
net::SocketAddr,
|
||||
sync::{LazyLock, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use hyper::body::Incoming;
|
||||
use hyper_util::rt::{TokioIo, TokioTimer};
|
||||
use theseus::ErrorKind;
|
||||
use theseus::prelude::tcp_listen_any_loopback;
|
||||
use tokio::sync::{broadcast, oneshot};
|
||||
|
||||
static SERVER_SHUTDOWN: LazyLock<broadcast::Sender<()>> =
|
||||
LazyLock::new(|| broadcast::channel(1024).0);
|
||||
|
||||
/// Starts a temporary HTTP server to receive OAuth 2.0 authorization code grant flow redirects
|
||||
/// on a loopback interface with an ephemeral port. The caller can know the bound socket address
|
||||
/// by listening on the counterpart channel for `listen_socket_tx`.
|
||||
///
|
||||
/// If the server is stopped before receiving an authorization code, `Ok(None)` is returned.
|
||||
pub async fn listen(
|
||||
listen_socket_tx: oneshot::Sender<Result<SocketAddr, theseus::Error>>,
|
||||
) -> Result<Option<AuthorizationCodeReply>, theseus::Error> {
|
||||
let listener = tcp_listen_any_loopback().await;
|
||||
listen_with_listener(listener, listen_socket_tx).await
|
||||
}
|
||||
|
||||
/// Starts a temporary HTTP server on a registered loopback callback address.
|
||||
pub async fn listen_fixed(
|
||||
address: SocketAddr,
|
||||
listen_socket_tx: oneshot::Sender<Result<SocketAddr, theseus::Error>>,
|
||||
) -> Result<Option<AuthorizationCodeReply>, theseus::Error> {
|
||||
let listener = tokio::net::TcpListener::bind(address).await;
|
||||
listen_with_listener(listener, listen_socket_tx).await
|
||||
}
|
||||
|
||||
async fn listen_with_listener(
|
||||
listener: Result<tokio::net::TcpListener, std::io::Error>,
|
||||
listen_socket_tx: oneshot::Sender<Result<SocketAddr, theseus::Error>>,
|
||||
) -> Result<Option<AuthorizationCodeReply>, theseus::Error> {
|
||||
let listener = match listener {
|
||||
Ok(listener) => {
|
||||
listen_socket_tx
|
||||
.send(listener.local_addr().map_err(|e| {
|
||||
ErrorKind::OtherError(format!(
|
||||
"Failed to get auth code reply socket address: {e}"
|
||||
))
|
||||
.into()
|
||||
}))
|
||||
.ok();
|
||||
|
||||
listener
|
||||
}
|
||||
Err(e) => {
|
||||
let error_msg =
|
||||
format!("Failed to bind auth code reply socket: {e}");
|
||||
|
||||
listen_socket_tx
|
||||
.send(Err(ErrorKind::OtherError(error_msg.clone()).into()))
|
||||
.ok();
|
||||
|
||||
return Err(ErrorKind::OtherError(error_msg).into());
|
||||
}
|
||||
};
|
||||
|
||||
let mut auth_code = Mutex::new(None);
|
||||
let mut shutdown_notification = SERVER_SHUTDOWN.subscribe();
|
||||
|
||||
while auth_code.get_mut().unwrap().is_none() {
|
||||
let client_socket = tokio::select! {
|
||||
biased;
|
||||
_ = shutdown_notification.recv() => {
|
||||
break;
|
||||
}
|
||||
conn_accept_result = listener.accept() => {
|
||||
match conn_accept_result {
|
||||
Ok((socket, _)) => socket,
|
||||
Err(e) => {
|
||||
tracing::warn!("Failed to accept auth code reply: {e}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(e) = hyper::server::conn::http1::Builder::new()
|
||||
.keep_alive(false)
|
||||
.header_read_timeout(Duration::from_secs(5))
|
||||
.timer(TokioTimer::new())
|
||||
.auto_date_header(false)
|
||||
.serve_connection(
|
||||
TokioIo::new(client_socket),
|
||||
hyper::service::service_fn(|req| handle_reply(req, &auth_code)),
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::warn!("Failed to handle auth code reply: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(auth_code.into_inner().unwrap())
|
||||
}
|
||||
|
||||
/// Stops any active OAuth 2.0 authorization code grant flow reply listening HTTP servers.
|
||||
pub fn stop_listeners() {
|
||||
SERVER_SHUTDOWN.send(()).ok();
|
||||
}
|
||||
|
||||
pub struct AuthorizationCodeReply {
|
||||
pub code: String,
|
||||
pub state: Option<String>,
|
||||
}
|
||||
|
||||
struct ReplyPageCopy {
|
||||
language: &'static str,
|
||||
success_title: &'static str,
|
||||
success_message: &'static str,
|
||||
error_title: &'static str,
|
||||
error_message: &'static str,
|
||||
}
|
||||
|
||||
fn reply_page_copy(
|
||||
accept_language: Option<&hyper::header::HeaderValue>,
|
||||
) -> ReplyPageCopy {
|
||||
let is_chinese = accept_language
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.is_some_and(|value| {
|
||||
value
|
||||
.split(',')
|
||||
.any(|language| language.trim_start().starts_with("zh"))
|
||||
});
|
||||
|
||||
if is_chinese {
|
||||
ReplyPageCopy {
|
||||
language: "zh-CN",
|
||||
success_title: "登录成功",
|
||||
success_message: "你已成功登录!现在可以关闭此页面。",
|
||||
error_title: "发生错误",
|
||||
error_message: "未找到授权代码。请重新尝试登录。",
|
||||
}
|
||||
} else {
|
||||
ReplyPageCopy {
|
||||
language: "en",
|
||||
success_title: "Success",
|
||||
success_message: "You have successfully signed in! You can close this page now.",
|
||||
error_title: "Error",
|
||||
error_message: "Authorization code not found. Please try signing in again.",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_reply_page(language: &str, title: &str, message: &str) -> String {
|
||||
include_str!("auth_code_reply/page.html")
|
||||
.replace("lang=en", &format!("lang={language}"))
|
||||
.replace("{{title}}", title)
|
||||
.replace("{{message}}", message)
|
||||
}
|
||||
|
||||
async fn handle_reply(
|
||||
req: hyper::Request<Incoming>,
|
||||
auth_code_out: &Mutex<Option<AuthorizationCodeReply>>,
|
||||
) -> Result<hyper::Response<String>, hyper::http::Error> {
|
||||
if req.method() != hyper::Method::GET {
|
||||
return hyper::Response::builder()
|
||||
.status(hyper::StatusCode::METHOD_NOT_ALLOWED)
|
||||
.header("Allow", "GET")
|
||||
.body("".into());
|
||||
}
|
||||
|
||||
let copy =
|
||||
reply_page_copy(req.headers().get(hyper::header::ACCEPT_LANGUAGE));
|
||||
|
||||
// The authorization code is guaranteed to be sent as a "code" query parameter
|
||||
// in the request URI query string as per RFC 6749 § 4.1.2
|
||||
let auth_code = req.uri().query().and_then(|query_string| {
|
||||
let params: std::collections::HashMap<_, _> =
|
||||
url::form_urlencoded::parse(query_string.as_bytes()).collect();
|
||||
Some(AuthorizationCodeReply {
|
||||
code: params.get("code")?.to_string(),
|
||||
state: params.get("state").map(ToString::to_string),
|
||||
})
|
||||
});
|
||||
|
||||
let response = if let Some(auth_code) = auth_code {
|
||||
*auth_code_out.lock().unwrap() = Some(auth_code);
|
||||
|
||||
hyper::Response::builder()
|
||||
.status(hyper::StatusCode::OK)
|
||||
.header("Content-Type", "text/html;charset=utf-8")
|
||||
.body(render_reply_page(
|
||||
copy.language,
|
||||
copy.success_title,
|
||||
copy.success_message,
|
||||
))
|
||||
} else {
|
||||
hyper::Response::builder()
|
||||
.status(hyper::StatusCode::BAD_REQUEST)
|
||||
.header("Content-Type", "text/html;charset=utf-8")
|
||||
.body(render_reply_page(
|
||||
copy.language,
|
||||
copy.error_title,
|
||||
copy.error_message,
|
||||
))
|
||||
}?;
|
||||
|
||||
Ok(response)
|
||||
}
|
||||
1
apps/app/src/api/oauth_utils/auth_code_reply/page.html
Normal file
3
apps/app/src/api/oauth_utils/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
//! Assorted utilities for OAuth 2.0 authorization flows.
|
||||
|
||||
pub mod auth_code_reply;
|
||||
31
apps/app/src/api/planet_minecraft.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use crate::api::Result;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("planet-minecraft")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
planet_minecraft_connector_available,
|
||||
planet_minecraft_search_projects,
|
||||
planet_minecraft_get_project,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn planet_minecraft_connector_available() -> bool {
|
||||
theseus::planet_minecraft::connector_base_url().is_ok()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn planet_minecraft_search_projects(
|
||||
query: &str,
|
||||
game_version: Option<&str>,
|
||||
) -> Result<Vec<theseus::planet_minecraft::PlanetMinecraftProject>> {
|
||||
Ok(theseus::planet_minecraft::search_projects(query, game_version).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn planet_minecraft_get_project(
|
||||
id: &str,
|
||||
) -> Result<theseus::planet_minecraft::PlanetMinecraftProject> {
|
||||
Ok(theseus::planet_minecraft::get_project(id).await?)
|
||||
}
|
||||
36
apps/app/src/api/process.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use crate::api::Result;
|
||||
use theseus::prelude::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("process")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
process_get_all,
|
||||
process_get_by_instance_id,
|
||||
process_kill,
|
||||
process_wait_for,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn process_get_all() -> Result<Vec<ProcessMetadata>> {
|
||||
Ok(process::get_all().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn process_get_by_instance_id(
|
||||
instance_id: &str,
|
||||
) -> Result<Vec<ProcessMetadata>> {
|
||||
Ok(process::get_by_instance_id(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn process_kill(uuid: Uuid) -> Result<()> {
|
||||
Ok(process::kill(uuid).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn process_wait_for(uuid: Uuid) -> Result<()> {
|
||||
Ok(process::wait_for(uuid).await?)
|
||||
}
|
||||