mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 00:31:33 +10:00
Compare commits
5 Commits
160-generi
...
bigpicture
| Author | SHA1 | Date | |
|---|---|---|---|
| 31f7d5bcfa | |||
| ab9e06f6c4 | |||
| dbf9c8e8e5 | |||
| 864640d6ae | |||
| e29d5c8ead |
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<NuxtLoadingIndicator color="#2563eb" />
|
||||
<NuxtLoadingIndicator color="#2563eb" />
|
||||
<NuxtLayout class="select-none w-screen h-screen">
|
||||
<NuxtPage />
|
||||
<ModalStack />
|
||||
@ -7,14 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import "~/composables/downloads.js";
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useAppState } from "./composables/app-state.js";
|
||||
import {
|
||||
initialNavigation,
|
||||
setupHooks,
|
||||
} from "./composables/state-navigation.js";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
<div class="h-16 bg-zinc-950 flex flex-row justify-between">
|
||||
<div class="flex flex-row grow items-center pl-5 pr-2 py-3">
|
||||
<div class="inline-flex items-center gap-x-10">
|
||||
<NuxtLink to="/store">
|
||||
<Wordmark class="h-8 mb-0.5" />
|
||||
</NuxtLink>
|
||||
<Wordmark class="h-8 mb-0.5" />
|
||||
<nav class="inline-flex items-center mt-0.5">
|
||||
<ol class="inline-flex items-center gap-x-6">
|
||||
<NuxtLink
|
||||
@ -42,7 +40,7 @@
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<WindowControl />
|
||||
<WindowControl />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@ -76,7 +76,6 @@ import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
|
||||
import { ChevronDownIcon } from "@heroicons/vue/16/solid";
|
||||
import type { NavigationItem } from "../types";
|
||||
import HeaderWidget from "./HeaderWidget.vue";
|
||||
import { useAppState } from "~/composables/app-state";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
const open = ref(false);
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-x-2">
|
||||
<div class="flex flex-col gap-x-2">
|
||||
<p
|
||||
class="text-sm whitespace-nowrap font-display font-semibold"
|
||||
>
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<NuxtLink
|
||||
class="inline-flex items-center gap-x-2 px-1 py-0.5 rounded bg-blue-900 text-zinc-100 hover:bg-blue-800"
|
||||
>
|
||||
<slot />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
@ -9,13 +9,17 @@ export default defineNuxtConfig({
|
||||
},
|
||||
},
|
||||
|
||||
css: ["~/assets/main.scss"],
|
||||
|
||||
ssr: false,
|
||||
|
||||
extends: [["../libs/drop-base"]],
|
||||
extends: ["../shared", "../libs/drop-base"],
|
||||
|
||||
app: {
|
||||
baseURL: "/main",
|
||||
}
|
||||
},
|
||||
|
||||
devtools: {
|
||||
enabled: false,
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
||||
@ -116,7 +116,7 @@ platformInfo.value = currentPlatform;
|
||||
async function openDataDir() {
|
||||
if (!dataDir.value) return;
|
||||
try {
|
||||
await invoke("open_fs", { path: dataDir.value });
|
||||
await open(dataDir.value);
|
||||
} catch (error) {
|
||||
console.error("Failed to open data dir:", error);
|
||||
}
|
||||
@ -126,7 +126,7 @@ async function openLogFile() {
|
||||
if (!dataDir.value) return;
|
||||
try {
|
||||
const logPath = `${dataDir.value}/drop.log`;
|
||||
await invoke("open_fs", { path: logPath });
|
||||
await open(logPath);
|
||||
} catch (error) {
|
||||
console.error("Failed to open log file:", error);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ export default {
|
||||
"./plugins/**/*.{js,ts}",
|
||||
"./app.vue",
|
||||
"./error.vue",
|
||||
"../shared/components/**/*.vue"
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.7.0",
|
||||
"@tauri-apps/plugin-deep-link": "^2.4.1",
|
||||
"@tauri-apps/plugin-dialog": "^2.4.0",
|
||||
"@tauri-apps/plugin-opener": "^2.5.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.3.2",
|
||||
"@tauri-apps/plugin-opener": "^2.4.0",
|
||||
"@tauri-apps/plugin-os": "^2.3.0",
|
||||
"@tauri-apps/plugin-shell": "^2.3.0",
|
||||
"pino": "^9.7.0",
|
||||
|
||||
50
shared/app.vue
Normal file
50
shared/app.vue
Normal file
@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<NuxtLoadingIndicator color="#2563eb" />
|
||||
<NuxtLayout class="select-none w-screen h-screen">
|
||||
<NuxtPage />
|
||||
<ModalStack />
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import "~/composables/downloads.js";
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useAppState } from "./composables/app-state.js";
|
||||
import {
|
||||
initialNavigation,
|
||||
setupHooks,
|
||||
} from "./composables/state-navigation.js";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const state = useAppState();
|
||||
|
||||
async function fetchState() {
|
||||
try {
|
||||
state.value = JSON.parse(await invoke("fetch_state"));
|
||||
if (!state.value)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: `App state is: ${state.value}`,
|
||||
fatal: true,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("failed to parse state", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
await fetchState();
|
||||
|
||||
// This is inefficient but apparently we do it lol
|
||||
router.beforeEach(async () => {
|
||||
await fetchState();
|
||||
});
|
||||
|
||||
setupHooks();
|
||||
initialNavigation(state);
|
||||
|
||||
useHead({
|
||||
title: "Drop",
|
||||
});
|
||||
</script>
|
||||
84
shared/assets/main.scss
Normal file
84
shared/assets/main.scss
Normal file
@ -0,0 +1,84 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
html,
|
||||
body {
|
||||
-ms-overflow-style: none; /* IE and Edge /
|
||||
scrollbar-width: none; / Firefox */
|
||||
}
|
||||
|
||||
/* Hide scrollbar for Chrome, Safari and Opera */
|
||||
html::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
$motiva: (
|
||||
("MotivaSansThin.ttf", "ttf", 100, normal),
|
||||
("MotivaSansLight.woff.ttf", "woff", 300, normal),
|
||||
("MotivaSansRegular.woff.ttf", "woff", 400, normal),
|
||||
("MotivaSansMedium.woff.ttf", "woff", 500, normal),
|
||||
("MotivaSansBold.woff.ttf", "woff", 600, normal),
|
||||
("MotivaSansExtraBold.ttf", "woff", 700, normal),
|
||||
("MotivaSansBlack.woff.ttf", "woff", 900, normal)
|
||||
);
|
||||
|
||||
$helvetica: (
|
||||
("Helvetica.woff", "woff", 400, normal),
|
||||
("Helvetica-Oblique.woff", "woff", 400, italic),
|
||||
("Helvetica-Bold.woff", "woff", 600, normal),
|
||||
("Helvetica-BoldOblique.woff", "woff", 600, italic),
|
||||
("helvetica-light-587ebe5a59211.woff2", "woff2", 300, normal)
|
||||
);
|
||||
|
||||
@each $file, $format, $weight, $style in $motiva {
|
||||
@font-face {
|
||||
font-family: "Motiva Sans";
|
||||
src: url("/fonts/motiva/#{$file}") format($format);
|
||||
font-weight: $weight;
|
||||
font-style: $style;
|
||||
}
|
||||
}
|
||||
|
||||
@each $file, $format, $weight, $style in $helvetica {
|
||||
@font-face {
|
||||
font-family: "Helvetica";
|
||||
src: url("/fonts/helvetica/#{$file}") format($format);
|
||||
font-weight: $weight;
|
||||
font-style: $style;
|
||||
}
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("/fonts/inter/InterVariable.ttf");
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("/fonts/inter/InterVariable-Italic.ttf");
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* ===== Scrollbar CSS ===== */
|
||||
/* Firefox */
|
||||
* {
|
||||
scrollbar-width: 4px;
|
||||
scrollbar-color: #52525b #00000000;
|
||||
}
|
||||
|
||||
/* Chrome, Edge, and Safari */
|
||||
*::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background-color: #52525b;
|
||||
border-radius: 10px;
|
||||
border: 3px solid #52525b;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
|
||||
export const useObject = async (id: string) => {
|
||||
export const useObject = (id: string) => {
|
||||
return convertFileSrc(id, "object");
|
||||
};
|
||||
91
shared/error.vue
Normal file
91
shared/error.vue
Normal file
@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<NuxtLayout name="default">
|
||||
<div
|
||||
class="grid min-h-full grid-cols-1 grid-rows-[1fr,auto,1fr] lg:grid-cols-[max(50%,36rem),1fr]"
|
||||
>
|
||||
<header
|
||||
class="mx-auto w-full max-w-7xl px-6 pt-6 sm:pt-10 lg:col-span-2 lg:col-start-1 lg:row-start-1 lg:px-8"
|
||||
>
|
||||
<Logo class="h-10 w-auto sm:h-12" />
|
||||
|
||||
</header>
|
||||
<main
|
||||
class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"
|
||||
>
|
||||
<div class="max-w-lg">
|
||||
<p class="text-base font-semibold leading-8 text-blue-600">
|
||||
{{ error?.statusCode }}
|
||||
</p>
|
||||
<h1
|
||||
class="mt-4 text-3xl font-bold font-display tracking-tight text-zinc-100 sm:text-5xl"
|
||||
>
|
||||
Oh no!
|
||||
</h1>
|
||||
<p
|
||||
v-if="message"
|
||||
class="mt-3 font-bold text-base leading-7 text-red-500"
|
||||
>
|
||||
{{ message }}
|
||||
</p>
|
||||
<p class="mt-6 text-base leading-7 text-zinc-400">
|
||||
An error occurred while responding to your request. If you believe
|
||||
this to be a bug, please report it. Try signing in and see if it
|
||||
resolves the issue.
|
||||
</p>
|
||||
<div class="mt-10">
|
||||
<!-- full app reload to fix errors -->
|
||||
<a
|
||||
href="/store"
|
||||
class="text-sm font-semibold leading-7 text-blue-600"
|
||||
><span aria-hidden="true">←</span> Back to store</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="self-end lg:col-span-2 lg:col-start-1 lg:row-start-3">
|
||||
<div class="border-t border-zinc-700 bg-zinc-900 py-10">
|
||||
<nav
|
||||
class="mx-auto flex w-full max-w-7xl items-center gap-x-4 px-6 text-sm leading-7 text-zinc-400 lg:px-8"
|
||||
>
|
||||
<NuxtLink href="/docs">Documentation</NuxtLink>
|
||||
<svg
|
||||
viewBox="0 0 2 2"
|
||||
aria-hidden="true"
|
||||
class="h-0.5 w-0.5 fill-zinc-600"
|
||||
>
|
||||
<circle cx="1" cy="1" r="1" />
|
||||
</svg>
|
||||
<a href="https://discord.gg/NHx46XKJWA" target="_blank"
|
||||
>Support Discord</a
|
||||
>
|
||||
</nav>
|
||||
</div>
|
||||
</footer>
|
||||
<div
|
||||
class="hidden lg:relative lg:col-start-2 lg:row-start-1 lg:row-end-4 lg:block"
|
||||
>
|
||||
<img
|
||||
src="@/assets/wallpaper.jpg"
|
||||
alt=""
|
||||
class="absolute inset-0 h-full w-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { NuxtError } from "#app";
|
||||
|
||||
const props = defineProps({
|
||||
error: Object as () => NuxtError,
|
||||
});
|
||||
|
||||
const statusCode = props.error?.statusCode;
|
||||
const message =
|
||||
props.error?.statusMessage ||
|
||||
props.error?.message ||
|
||||
"An unknown error occurred.";
|
||||
|
||||
console.error(props.error);
|
||||
</script>
|
||||
25
shared/nuxt.config.ts
Normal file
25
shared/nuxt.config.ts
Normal file
@ -0,0 +1,25 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: "2024-04-03",
|
||||
|
||||
postcss: {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
},
|
||||
|
||||
css: ["~/assets/main.scss"],
|
||||
|
||||
ssr: false,
|
||||
|
||||
extends: [["../libs/drop-base"]],
|
||||
|
||||
app: {
|
||||
baseURL: "/main",
|
||||
},
|
||||
|
||||
devtools: {
|
||||
enabled: false,
|
||||
},
|
||||
});
|
||||
37
shared/package.json
Normal file
37
shared/package.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "view",
|
||||
"private": true,
|
||||
"version": "0.3.3",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt generate",
|
||||
"dev": "nuxt dev",
|
||||
"postinstall": "nuxt prepare",
|
||||
"tauri": "tauri"
|
||||
},
|
||||
"dependencies": {
|
||||
"@headlessui/vue": "^1.7.23",
|
||||
"@heroicons/vue": "^2.1.5",
|
||||
"@nuxtjs/tailwindcss": "^6.12.2",
|
||||
"@tauri-apps/api": "^2.7.0",
|
||||
"koa": "^2.16.1",
|
||||
"markdown-it": "^14.1.0",
|
||||
"micromark": "^4.0.1",
|
||||
"nuxt": "^3.16.0",
|
||||
"scss": "^0.2.4",
|
||||
"vue-router": "latest",
|
||||
"vuedraggable": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/forms": "^0.5.9",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.47",
|
||||
"sass-embedded": "^1.79.4",
|
||||
"tailwindcss": "^3.4.13",
|
||||
"typescript": "^5.8.3",
|
||||
"vue-tsc": "^2.2.10"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
20
shared/tailwind.config.js
Normal file
20
shared/tailwind.config.js
Normal file
@ -0,0 +1,20 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: [
|
||||
"./components/**/*.{js,vue,ts}",
|
||||
"./layouts/**/*.vue",
|
||||
"./pages/**/*.vue",
|
||||
"./plugins/**/*.{js,ts}",
|
||||
"./app.vue",
|
||||
"./error.vue",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ["Inter"],
|
||||
display: ["Motiva Sans"],
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require("@tailwindcss/forms"), require('@tailwindcss/typography')],
|
||||
};
|
||||
5
shared/tsconfig.json
Normal file
5
shared/tsconfig.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json",
|
||||
"exclude": ["src-tauri/**/*"]
|
||||
}
|
||||
96
shared/types.ts
Normal file
96
shared/types.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import type { Component } from "vue";
|
||||
|
||||
export type NavigationItem = {
|
||||
prefix: string;
|
||||
route: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
export type QuickActionNav = {
|
||||
icon: Component;
|
||||
notifications?: number;
|
||||
action: () => Promise<void>;
|
||||
};
|
||||
|
||||
export type User = {
|
||||
id: string;
|
||||
username: string;
|
||||
admin: boolean;
|
||||
displayName: string;
|
||||
profilePictureObjectId: string;
|
||||
};
|
||||
|
||||
export type AppState = {
|
||||
status: AppStatus;
|
||||
user?: User;
|
||||
};
|
||||
|
||||
export type Game = {
|
||||
id: string;
|
||||
mName: string;
|
||||
mShortDescription: string;
|
||||
mDescription: string;
|
||||
mIconObjectId: string;
|
||||
mBannerObjectId: string;
|
||||
mCoverObjectId: string;
|
||||
mImageLibraryObjectIds: string[];
|
||||
mImageCarouselObjectIds: string[];
|
||||
};
|
||||
|
||||
export type Collection = {
|
||||
id: string;
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
entries: Array<{ gameId: string; game: Game }>;
|
||||
};
|
||||
|
||||
export type GameVersion = {
|
||||
launchCommandTemplate: string;
|
||||
};
|
||||
|
||||
export enum AppStatus {
|
||||
NotConfigured = "NotConfigured",
|
||||
Offline = "Offline",
|
||||
SignedOut = "SignedOut",
|
||||
SignedIn = "SignedIn",
|
||||
SignedInNeedsReauth = "SignedInNeedsReauth",
|
||||
ServerUnavailable = "ServerUnavailable",
|
||||
}
|
||||
|
||||
export enum GameStatusEnum {
|
||||
Remote = "Remote",
|
||||
Queued = "Queued",
|
||||
Downloading = "Downloading",
|
||||
Validating = "Validating",
|
||||
Installed = "Installed",
|
||||
Updating = "Updating",
|
||||
Uninstalling = "Uninstalling",
|
||||
SetupRequired = "SetupRequired",
|
||||
Running = "Running",
|
||||
PartiallyInstalled = "PartiallyInstalled",
|
||||
}
|
||||
|
||||
export type GameStatus = {
|
||||
type: GameStatusEnum;
|
||||
version_name?: string;
|
||||
install_dir?: string;
|
||||
};
|
||||
|
||||
export enum DownloadableType {
|
||||
Game = "Game",
|
||||
Tool = "Tool",
|
||||
DLC = "DLC",
|
||||
Mod = "Mod",
|
||||
}
|
||||
|
||||
export type DownloadableMetadata = {
|
||||
id: string;
|
||||
version: string;
|
||||
downloadType: DownloadableType;
|
||||
};
|
||||
|
||||
export type Settings = {
|
||||
autostart: boolean;
|
||||
maxDownloadThreads: number;
|
||||
forceOffline: boolean;
|
||||
};
|
||||
8091
shared/yarn.lock
Normal file
8091
shared/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
237
src-tauri/Cargo.lock
generated
237
src-tauri/Cargo.lock
generated
@ -2,6 +2,15 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.25.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
@ -399,6 +408,21 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.10.1"
|
||||
@ -486,7 +510,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"generic-array 0.14.9",
|
||||
"generic-array 0.14.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -495,7 +519,7 @@ version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array 0.14.9",
|
||||
"generic-array 0.14.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -755,9 +779,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
@ -785,7 +809,6 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitcode",
|
||||
"database",
|
||||
"drop-consts",
|
||||
"log",
|
||||
"serde",
|
||||
"tauri",
|
||||
@ -798,7 +821,6 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"database",
|
||||
"dirs 6.0.0",
|
||||
"drop-consts",
|
||||
"log",
|
||||
"regex",
|
||||
"rustix 1.1.2",
|
||||
@ -981,7 +1003,7 @@ version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array 0.14.9",
|
||||
"generic-array 0.14.8",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
@ -1067,10 +1089,8 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
||||
name = "database"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitcode",
|
||||
"chrono",
|
||||
"dirs 6.0.0",
|
||||
"drop-consts",
|
||||
"log",
|
||||
"native_model",
|
||||
"rustbreak",
|
||||
@ -1179,7 +1199,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array 0.14.9",
|
||||
"generic-array 0.14.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1379,7 +1399,7 @@ dependencies = [
|
||||
"rayon",
|
||||
"regex",
|
||||
"remote",
|
||||
"reqwest 0.12.24",
|
||||
"reqwest 0.12.23",
|
||||
"reqwest-middleware 0.4.2",
|
||||
"reqwest-middleware-cache",
|
||||
"reqwest-websocket",
|
||||
@ -1418,13 +1438,6 @@ dependencies = [
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "drop-consts"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "droplet-rs"
|
||||
version = "0.7.3"
|
||||
@ -1852,14 +1865,13 @@ dependencies = [
|
||||
"boxcar",
|
||||
"database",
|
||||
"download_manager",
|
||||
"drop-consts",
|
||||
"hex 0.4.3",
|
||||
"log",
|
||||
"md5 0.8.0",
|
||||
"native_model",
|
||||
"rayon",
|
||||
"remote",
|
||||
"reqwest 0.12.24",
|
||||
"reqwest 0.12.23",
|
||||
"rustix 1.1.2",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -1980,9 +1992,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.9"
|
||||
version = "0.14.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2"
|
||||
checksum = "1dc8f7d2ded5f9209535e4b3fd4d39c002f30902ff5ce9f64e2c33d549576500"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
@ -1990,12 +2002,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gethostname"
|
||||
version = "1.1.0"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
|
||||
checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55"
|
||||
dependencies = [
|
||||
"rustix 1.1.2",
|
||||
"windows-link 0.2.1",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2024,18 +2036,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.4"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasip2",
|
||||
"wasi 0.14.7+wasi-0.2.4",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.32.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.18.4"
|
||||
@ -2520,7 +2538,7 @@ dependencies = [
|
||||
"libc",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"socket2 0.6.1",
|
||||
"socket2 0.6.0",
|
||||
"system-configuration 0.6.1",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
@ -2716,6 +2734,17 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-uring"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
|
||||
dependencies = [
|
||||
"bitflags 2.9.4",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.11.0"
|
||||
@ -2751,15 +2780,6 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
@ -2817,7 +2837,7 @@ version = "0.1.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.3.3",
|
||||
"libc",
|
||||
]
|
||||
|
||||
@ -2956,23 +2976,6 @@ version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "library"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"client",
|
||||
"database",
|
||||
"futures",
|
||||
"itertools",
|
||||
"log",
|
||||
"remote",
|
||||
"serde",
|
||||
"serde_with",
|
||||
"tauri",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.10"
|
||||
@ -3695,6 +3698,15 @@ dependencies = [
|
||||
"objc2-security",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.37.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oid-registry"
|
||||
version = "0.7.1"
|
||||
@ -3745,9 +3757,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.74"
|
||||
version = "0.10.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654"
|
||||
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
||||
dependencies = [
|
||||
"bitflags 2.9.4",
|
||||
"cfg-if",
|
||||
@ -3777,9 +3789,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.110"
|
||||
version = "0.9.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2"
|
||||
checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@ -4312,7 +4324,7 @@ dependencies = [
|
||||
"quinn-udp",
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"socket2 0.6.1",
|
||||
"socket2 0.6.0",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@ -4326,7 +4338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.3.3",
|
||||
"lru-slab",
|
||||
"rand 0.9.2",
|
||||
"ring",
|
||||
@ -4349,7 +4361,7 @@ dependencies = [
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"socket2 0.6.1",
|
||||
"socket2 0.6.0",
|
||||
"tracing",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
@ -4458,7 +4470,7 @@ version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4593,9 +4605,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
checksum = "4a52d8d02cacdb176ef4678de6c052efb4b3da14b78e4db683a4252762be5433"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@ -4605,9 +4617,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.13"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||
checksum = "722166aa0d7438abbaa4d5cc2c649dac844e8c56d82fb3d33e9c34b5cd268fc6"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@ -4616,9 +4628,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.8"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
checksum = "c3160422bbd54dd5ecfdca71e5fd59b7b8fe2b1697ab2baf64f6d05dcc66d298"
|
||||
|
||||
[[package]]
|
||||
name = "remote"
|
||||
@ -4634,7 +4646,7 @@ dependencies = [
|
||||
"http 1.3.1",
|
||||
"log",
|
||||
"md5 0.8.0",
|
||||
"reqwest 0.12.24",
|
||||
"reqwest 0.12.23",
|
||||
"reqwest-websocket",
|
||||
"serde",
|
||||
"serde_with",
|
||||
@ -4682,9 +4694,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.12.24"
|
||||
version = "0.12.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f"
|
||||
checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
@ -4754,7 +4766,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"http 1.3.1",
|
||||
"reqwest 0.12.24",
|
||||
"reqwest 0.12.23",
|
||||
"serde",
|
||||
"thiserror 1.0.69",
|
||||
"tower-service",
|
||||
@ -4789,7 +4801,7 @@ dependencies = [
|
||||
"async-tungstenite",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"reqwest 0.12.24",
|
||||
"reqwest 0.12.23",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
@ -4881,6 +4893,12 @@ dependencies = [
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.1"
|
||||
@ -4947,9 +4965,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-native-certs"
|
||||
version = "0.8.2"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923"
|
||||
checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3"
|
||||
dependencies = [
|
||||
"openssl-probe",
|
||||
"rustls-pki-types",
|
||||
@ -5511,12 +5529,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.1"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881"
|
||||
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5801,9 +5819,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.34.4"
|
||||
version = "0.34.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6121216ff67fe4bcfe64508ea1700bc15f74937d835a07b4a209cc00a8926a84"
|
||||
checksum = "959469667dbcea91e5485fc48ba7dd6023face91bb0f1a14681a70f99847c3f7"
|
||||
dependencies = [
|
||||
"bitflags 2.9.4",
|
||||
"block2 0.6.2",
|
||||
@ -5888,7 +5906,7 @@ dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"embed_plist",
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.3.3",
|
||||
"glob",
|
||||
"gtk",
|
||||
"heck 0.5.0",
|
||||
@ -5907,7 +5925,7 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
"plist",
|
||||
"raw-window-handle",
|
||||
"reqwest 0.12.24",
|
||||
"reqwest 0.12.23",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
@ -6268,7 +6286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.3.3",
|
||||
"once_cell",
|
||||
"rustix 1.1.2",
|
||||
"windows-sys 0.61.2",
|
||||
@ -6414,26 +6432,29 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.48.0"
|
||||
version = "1.47.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408"
|
||||
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"io-uring",
|
||||
"libc",
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2 0.6.1",
|
||||
"slab",
|
||||
"socket2 0.6.0",
|
||||
"tokio-macros",
|
||||
"tracing",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.6.0"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -6877,7 +6898,7 @@ version = "1.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.3.3",
|
||||
"js-sys",
|
||||
"rand 0.9.2",
|
||||
"serde",
|
||||
@ -6971,6 +6992,15 @@ version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.7+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
|
||||
dependencies = [
|
||||
"wasip2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.1+wasi-0.2.4"
|
||||
@ -7153,9 +7183,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webbrowser"
|
||||
version = "1.0.6"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00f1243ef785213e3a32fa0396093424a3a6ea566f9948497e5a2309261a4c97"
|
||||
checksum = "aaf4f3c0ba838e82b4e5ccc4157003fb8c324ee24c058470ffb82820becbde98"
|
||||
dependencies = [
|
||||
"core-foundation 0.10.1",
|
||||
"jni",
|
||||
@ -8051,9 +8081,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zbus"
|
||||
version = "5.12.0"
|
||||
version = "5.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b622b18155f7a93d1cd2dc8c01d2d6a44e08fb9ebb7b3f9e6ed101488bad6c91"
|
||||
checksum = "2d07e46d035fb8e375b2ce63ba4e4ff90a7f73cf2ffb0138b29e1158d2eaadf7"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-executor",
|
||||
@ -8076,8 +8106,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"uds_windows",
|
||||
"uuid",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
"winnow 0.7.13",
|
||||
"zbus_macros",
|
||||
"zbus_names",
|
||||
@ -8086,9 +8115,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zbus_macros"
|
||||
version = "5.12.0"
|
||||
version = "5.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cdb94821ca8a87ca9c298b5d1cbd80e2a8b67115d99f6e4551ac49e42b6a314"
|
||||
checksum = "57e797a9c847ed3ccc5b6254e8bcce056494b375b511b3d6edcec0aeb4defaca"
|
||||
dependencies = [
|
||||
"proc-macro-crate 3.4.0",
|
||||
"proc-macro2",
|
||||
@ -8221,9 +8250,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "5.8.0"
|
||||
version = "5.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2be61892e4f2b1772727be11630a62664a1826b62efa43a6fe7449521cb8744c"
|
||||
checksum = "999dd3be73c52b1fccd109a4a81e4fcd20fab1d3599c8121b38d04e1419498db"
|
||||
dependencies = [
|
||||
"endi",
|
||||
"enumflags2",
|
||||
@ -8236,9 +8265,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_derive"
|
||||
version = "5.8.0"
|
||||
version = "5.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da58575a1b2b20766513b1ec59d8e2e68db2745379f961f86650655e862d2006"
|
||||
checksum = "6643fd0b26a46d226bd90d3f07c1b5321fe9bb7f04673cb37ac6d6883885b68e"
|
||||
dependencies = [
|
||||
"proc-macro-crate 3.4.0",
|
||||
"proc-macro2",
|
||||
|
||||
@ -65,9 +65,7 @@ whoami = "1.6.0"
|
||||
filetime = "0.2.25"
|
||||
walkdir = "2.5.0"
|
||||
known-folders = "1.2.0"
|
||||
native_model = { version = "0.6.4", features = [
|
||||
"rmp_serde_1_3",
|
||||
], git = "https://github.com/Drop-OSS/native_model.git" }
|
||||
native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"}
|
||||
tauri-plugin-opener = "2.4.0"
|
||||
bitcode = "0.6.6"
|
||||
reqwest-websocket = "0.5.0"
|
||||
@ -151,8 +149,6 @@ members = [
|
||||
"cloud_saves",
|
||||
"download_manager",
|
||||
"games",
|
||||
"library",
|
||||
"drop-consts",
|
||||
]
|
||||
|
||||
resolver = "3"
|
||||
@ -6,7 +6,6 @@ edition = "2024"
|
||||
[dependencies]
|
||||
bitcode = "0.6.7"
|
||||
database = { version = "0.1.0", path = "../database" }
|
||||
drop-consts = { version = "0.1.0", path = "../drop-consts" }
|
||||
log = "0.4.28"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
tauri = "2.8.5"
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use database::models::Game;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{app_status::AppStatus, user::User};
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppState {
|
||||
status: AppStatus,
|
||||
user: Option<User>,
|
||||
games: HashMap<String, Game>,
|
||||
}
|
||||
impl AppState {
|
||||
pub fn new(status: AppStatus, user: Option<User>, games: HashMap<String, Game>) -> Self {
|
||||
Self {
|
||||
status,
|
||||
user,
|
||||
games,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn status(&self) -> &AppStatus {
|
||||
&self.status
|
||||
}
|
||||
pub fn status_mut(&mut self) -> &mut AppStatus {
|
||||
&mut self.status
|
||||
}
|
||||
pub fn games(&self) -> &HashMap<String, Game> {
|
||||
&self.games
|
||||
}
|
||||
pub fn games_mut(&mut self) -> &mut HashMap<String, Game> {
|
||||
&mut self.games
|
||||
}
|
||||
pub fn user(&self) -> &Option<User> {
|
||||
&self.user
|
||||
}
|
||||
pub fn user_mut(&mut self) -> &mut Option<User> {
|
||||
&mut self.user
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ use std::{
|
||||
sync::LazyLock,
|
||||
};
|
||||
|
||||
use drop_consts::{UMU_BASE_LAUNCHER_EXECUTABLE, UMU_INSTALL_DIRS};
|
||||
use log::info;
|
||||
|
||||
pub static COMPAT_INFO: LazyLock<Option<CompatInfo>> = LazyLock::new(create_new_compat_info);
|
||||
@ -31,6 +30,9 @@ fn create_new_compat_info() -> Option<CompatInfo> {
|
||||
})
|
||||
}
|
||||
|
||||
const UMU_BASE_LAUNCHER_EXECUTABLE: &str = "umu-run";
|
||||
const UMU_INSTALL_DIRS: [&str; 4] = ["/app/share", "/use/local/share", "/usr/share", "/opt"];
|
||||
|
||||
fn get_umu_executable() -> Option<PathBuf> {
|
||||
if check_executable_exists(UMU_BASE_LAUNCHER_EXECUTABLE) {
|
||||
return Some(PathBuf::from(UMU_BASE_LAUNCHER_EXECUTABLE));
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
pub mod app_state;
|
||||
pub mod app_status;
|
||||
pub mod autostart;
|
||||
pub mod compat;
|
||||
|
||||
@ -6,7 +6,6 @@ edition = "2024"
|
||||
[dependencies]
|
||||
database = { version = "0.1.0", path = "../database" }
|
||||
dirs = "6.0.0"
|
||||
drop-consts = { version = "0.1.0", path = "../drop-consts" }
|
||||
log = "0.4.28"
|
||||
regex = "1.11.3"
|
||||
rustix = "1.1.2"
|
||||
|
||||
@ -2,7 +2,7 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use database::platform::Platform;
|
||||
use database::{db::DATA_ROOT_DIR, GameVersion};
|
||||
use database::{GameVersion, db::DATA_ROOT_DIR};
|
||||
use log::warn;
|
||||
|
||||
use crate::error::BackupError;
|
||||
@ -27,7 +27,7 @@ impl BackupManager<'_> {
|
||||
current_platform: Platform::Windows,
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
current_platform: Platform::macOS,
|
||||
current_platform: Platform::MacOs,
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
current_platform: Platform::Linux,
|
||||
@ -43,7 +43,7 @@ impl BackupManager<'_> {
|
||||
&LinuxBackupManager {} as &(dyn BackupHandler + Sync + Send),
|
||||
),
|
||||
(
|
||||
(Platform::macOS, Platform::macOS),
|
||||
(Platform::MacOs, Platform::MacOs),
|
||||
&MacBackupManager {} as &(dyn BackupHandler + Sync + Send),
|
||||
),
|
||||
]),
|
||||
|
||||
@ -4,10 +4,8 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bitcode = "0.6.7"
|
||||
chrono = "0.4.42"
|
||||
dirs = "6.0.0"
|
||||
drop-consts = { version = "0.1.0", path = "../drop-consts" }
|
||||
log = "0.4.28"
|
||||
native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"}
|
||||
rustbreak = "2.0.0"
|
||||
|
||||
@ -3,18 +3,24 @@ use std::{
|
||||
sync::{Arc, LazyLock},
|
||||
};
|
||||
|
||||
use drop_consts::DATA_ROOT_PREFIX;
|
||||
use rustbreak::{DeSerError, DeSerializer};
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
|
||||
use crate::{interface::DatabaseImpls, models::DatabaseInterface};
|
||||
use crate::interface::{DatabaseImpls, DatabaseInterface};
|
||||
|
||||
pub static DB: LazyLock<DatabaseInterface> = LazyLock::new(DatabaseInterface::set_up_database);
|
||||
|
||||
pub static DATA_ROOT_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||
#[cfg(not(debug_assertions))]
|
||||
static DATA_ROOT_PREFIX: &str = "drop";
|
||||
#[cfg(debug_assertions)]
|
||||
static DATA_ROOT_PREFIX: &str = "drop-debug";
|
||||
|
||||
pub static DATA_ROOT_DIR: LazyLock<Arc<PathBuf>> = LazyLock::new(|| {
|
||||
Arc::new(
|
||||
dirs::data_dir()
|
||||
.expect("Failed to get data dir")
|
||||
.join(DATA_ROOT_PREFIX)
|
||||
.join(DATA_ROOT_PREFIX),
|
||||
)
|
||||
});
|
||||
|
||||
// Custom JSON serializer to support everything we need
|
||||
|
||||
@ -9,14 +9,20 @@ use std::{
|
||||
use chrono::Utc;
|
||||
use log::{debug, error, info, warn};
|
||||
use rustbreak::{PathDatabase, RustbreakError};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
db::{DropDatabaseSerializer, DATA_ROOT_DIR, DB},
|
||||
models::{Database, DatabaseInterface},
|
||||
db::{DATA_ROOT_DIR, DB, DropDatabaseSerializer},
|
||||
models::data::Database,
|
||||
};
|
||||
|
||||
pub type DatabaseInterface =
|
||||
rustbreak::Database<Database, rustbreak::backend::PathBackend, DropDatabaseSerializer>;
|
||||
|
||||
pub trait DatabaseImpls {
|
||||
fn set_up_database() -> DatabaseInterface;
|
||||
fn database_is_set_up(&self) -> bool;
|
||||
fn fetch_base_url(&self) -> Url;
|
||||
}
|
||||
impl DatabaseImpls for DatabaseInterface {
|
||||
fn set_up_database() -> DatabaseInterface {
|
||||
@ -82,6 +88,16 @@ impl DatabaseImpls for DatabaseInterface {
|
||||
PathDatabase::create_at_path(db_path, default).expect("Database could not be created")
|
||||
}
|
||||
}
|
||||
|
||||
fn database_is_set_up(&self) -> bool {
|
||||
!borrow_db_checked().base_url.is_empty()
|
||||
}
|
||||
|
||||
fn fetch_base_url(&self) -> Url {
|
||||
let handle = borrow_db_checked();
|
||||
Url::parse(&handle.base_url)
|
||||
.unwrap_or_else(|_| panic!("Failed to parse base url {}", handle.base_url))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make the error relelvant rather than just assume that it's a Deserialize error
|
||||
|
||||
@ -8,7 +8,7 @@ pub mod platform;
|
||||
|
||||
pub use db::DB;
|
||||
pub use interface::{borrow_db_checked, borrow_db_mut_checked};
|
||||
pub use models::{
|
||||
pub use models::data::{
|
||||
ApplicationTransientStatus, Database, DatabaseApplications, DatabaseAuth, DownloadType,
|
||||
DownloadableMetadata, GameDownloadStatus, GameVersion, Settings,
|
||||
};
|
||||
|
||||
373
src-tauri/database/src/models.rs
Normal file
373
src-tauri/database/src/models.rs
Normal file
@ -0,0 +1,373 @@
|
||||
pub mod data {
|
||||
use std::{hash::Hash, path::PathBuf};
|
||||
|
||||
use native_model::native_model;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// NOTE: Within each version, you should NEVER use these types.
|
||||
// Declare it using the actual version that it is from, i.e. v1::Settings rather than just Settings from here
|
||||
|
||||
pub type GameVersion = v1::GameVersion;
|
||||
pub type Database = v3::Database;
|
||||
pub type Settings = v1::Settings;
|
||||
pub type DatabaseAuth = v1::DatabaseAuth;
|
||||
|
||||
pub type GameDownloadStatus = v2::GameDownloadStatus;
|
||||
pub type ApplicationTransientStatus = v1::ApplicationTransientStatus;
|
||||
/**
|
||||
* Need to be universally accessible by the ID, and the version is just a couple sprinkles on top
|
||||
*/
|
||||
pub type DownloadableMetadata = v1::DownloadableMetadata;
|
||||
pub type DownloadType = v1::DownloadType;
|
||||
pub type DatabaseApplications = v2::DatabaseApplications;
|
||||
// pub type DatabaseCompatInfo = v2::DatabaseCompatInfo;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
impl PartialEq for DownloadableMetadata {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.id == other.id && self.download_type == other.download_type
|
||||
}
|
||||
}
|
||||
impl Hash for DownloadableMetadata {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.id.hash(state);
|
||||
self.download_type.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
mod v1 {
|
||||
use serde_with::serde_as;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use crate::platform::Platform;
|
||||
|
||||
use super::{Deserialize, Serialize, native_model};
|
||||
|
||||
fn default_template() -> String {
|
||||
"{}".to_owned()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 2, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct GameVersion {
|
||||
pub game_id: String,
|
||||
pub version_name: String,
|
||||
|
||||
pub platform: Platform,
|
||||
|
||||
pub launch_command: String,
|
||||
pub launch_args: Vec<String>,
|
||||
#[serde(default = "default_template")]
|
||||
pub launch_command_template: String,
|
||||
|
||||
pub setup_command: String,
|
||||
pub setup_args: Vec<String>,
|
||||
#[serde(default = "default_template")]
|
||||
pub setup_command_template: String,
|
||||
|
||||
pub only_setup: bool,
|
||||
|
||||
pub version_index: usize,
|
||||
pub delta: bool,
|
||||
|
||||
pub umu_id_override: Option<String>,
|
||||
}
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 3, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct DatabaseApplications {
|
||||
pub install_dirs: Vec<PathBuf>,
|
||||
// Guaranteed to exist if the game also exists in the app state map
|
||||
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
||||
pub game_versions: HashMap<String, HashMap<String, GameVersion>>,
|
||||
pub installed_game_version: HashMap<String, DownloadableMetadata>,
|
||||
|
||||
#[serde(skip)]
|
||||
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 4, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct Settings {
|
||||
pub autostart: bool,
|
||||
pub max_download_threads: usize,
|
||||
pub force_offline: bool, // ... other settings ...
|
||||
}
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
autostart: false,
|
||||
max_download_threads: 4,
|
||||
force_offline: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Strings are version names for a particular game
|
||||
#[derive(Serialize, Clone, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[native_model(id = 5, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub enum GameDownloadStatus {
|
||||
Remote {},
|
||||
SetupRequired {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
Installed {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
}
|
||||
|
||||
// Stuff that shouldn't be synced to disk
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub enum ApplicationTransientStatus {
|
||||
Queued { version_name: String },
|
||||
Downloading { version_name: String },
|
||||
Uninstalling {},
|
||||
Updating { version_name: String },
|
||||
Validating { version_name: String },
|
||||
Running {},
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||
#[native_model(id = 6, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct DatabaseAuth {
|
||||
pub private: String,
|
||||
pub cert: String,
|
||||
pub client_id: String,
|
||||
pub web_token: Option<String>,
|
||||
}
|
||||
|
||||
#[native_model(id = 8, version = 1)]
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy,
|
||||
)]
|
||||
pub enum DownloadType {
|
||||
Game,
|
||||
Tool,
|
||||
Dlc,
|
||||
Mod,
|
||||
}
|
||||
|
||||
#[native_model(id = 7, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Debug, Eq, PartialOrd, Ord, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DownloadableMetadata {
|
||||
pub id: String,
|
||||
pub version: Option<String>,
|
||||
pub download_type: DownloadType,
|
||||
}
|
||||
impl DownloadableMetadata {
|
||||
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
||||
Self {
|
||||
id,
|
||||
version,
|
||||
download_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[native_model(id = 1, version = 1)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: Settings,
|
||||
pub auth: Option<DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: DatabaseApplications,
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
}
|
||||
}
|
||||
|
||||
mod v2 {
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use serde_with::serde_as;
|
||||
|
||||
use super::{Deserialize, Serialize, native_model, v1};
|
||||
|
||||
#[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from = v1::Database)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: v1::Settings,
|
||||
pub auth: Option<v1::DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: v1::DatabaseApplications,
|
||||
#[serde(skip)]
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
pub compat_info: Option<DatabaseCompatInfo>,
|
||||
}
|
||||
|
||||
#[native_model(id = 9, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
|
||||
pub struct DatabaseCompatInfo {
|
||||
pub umu_installed: bool,
|
||||
}
|
||||
|
||||
impl From<v1::Database> for Database {
|
||||
fn from(value: v1::Database) -> Self {
|
||||
Self {
|
||||
settings: value.settings,
|
||||
auth: value.auth,
|
||||
base_url: value.base_url,
|
||||
applications: value.applications,
|
||||
prev_database: value.prev_database,
|
||||
cache_dir: value.cache_dir,
|
||||
compat_info: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Strings are version names for a particular game
|
||||
#[derive(Serialize, Clone, Deserialize, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
#[native_model(id = 5, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from = v1::GameDownloadStatus)]
|
||||
pub enum GameDownloadStatus {
|
||||
Remote {},
|
||||
SetupRequired {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
Installed {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
PartiallyInstalled {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
}
|
||||
impl From<v1::GameDownloadStatus> for GameDownloadStatus {
|
||||
fn from(value: v1::GameDownloadStatus) -> Self {
|
||||
match value {
|
||||
v1::GameDownloadStatus::Remote {} => Self::Remote {},
|
||||
v1::GameDownloadStatus::SetupRequired {
|
||||
version_name,
|
||||
install_dir,
|
||||
} => Self::SetupRequired {
|
||||
version_name,
|
||||
install_dir,
|
||||
},
|
||||
v1::GameDownloadStatus::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
} => Self::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
#[serde_as]
|
||||
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 3, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from=v1::DatabaseApplications)]
|
||||
pub struct DatabaseApplications {
|
||||
pub install_dirs: Vec<PathBuf>,
|
||||
// Guaranteed to exist if the game also exists in the app state map
|
||||
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
||||
|
||||
pub game_versions: HashMap<String, HashMap<String, v1::GameVersion>>,
|
||||
pub installed_game_version: HashMap<String, v1::DownloadableMetadata>,
|
||||
|
||||
#[serde(skip)]
|
||||
pub transient_statuses:
|
||||
HashMap<v1::DownloadableMetadata, v1::ApplicationTransientStatus>,
|
||||
}
|
||||
impl From<v1::DatabaseApplications> for DatabaseApplications {
|
||||
fn from(value: v1::DatabaseApplications) -> Self {
|
||||
Self {
|
||||
game_statuses: value
|
||||
.game_statuses
|
||||
.into_iter()
|
||||
.map(|x| (x.0, x.1.into()))
|
||||
.collect::<HashMap<String, GameDownloadStatus>>(),
|
||||
install_dirs: value.install_dirs,
|
||||
game_versions: value.game_versions,
|
||||
installed_game_version: value.installed_game_version,
|
||||
transient_statuses: value.transient_statuses,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mod v3 {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::{Deserialize, Serialize, native_model, v1, v2};
|
||||
#[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde, from = v2::Database)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: v1::Settings,
|
||||
pub auth: Option<v1::DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: v2::DatabaseApplications,
|
||||
#[serde(skip)]
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
pub compat_info: Option<v2::DatabaseCompatInfo>,
|
||||
}
|
||||
|
||||
impl From<v2::Database> for Database {
|
||||
fn from(value: v2::Database) -> Self {
|
||||
Self {
|
||||
settings: value.settings,
|
||||
auth: value.auth,
|
||||
base_url: value.base_url,
|
||||
applications: value.applications.into(),
|
||||
prev_database: value.prev_database,
|
||||
cache_dir: value.cache_dir,
|
||||
compat_info: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Database {
|
||||
pub fn new<T: Into<PathBuf>>(
|
||||
games_base_dir: T,
|
||||
prev_database: Option<PathBuf>,
|
||||
cache_dir: PathBuf,
|
||||
) -> Self {
|
||||
Self {
|
||||
applications: DatabaseApplications {
|
||||
install_dirs: vec![games_base_dir.into()],
|
||||
game_statuses: HashMap::new(),
|
||||
game_versions: HashMap::new(),
|
||||
installed_game_version: HashMap::new(),
|
||||
transient_statuses: HashMap::new(),
|
||||
},
|
||||
prev_database,
|
||||
base_url: String::new(),
|
||||
auth: None,
|
||||
settings: Settings::default(),
|
||||
cache_dir,
|
||||
compat_info: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl DatabaseAuth {
|
||||
pub fn new(
|
||||
private: String,
|
||||
cert: String,
|
||||
client_id: String,
|
||||
web_token: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
private,
|
||||
cert,
|
||||
client_id,
|
||||
web_token,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,110 +0,0 @@
|
||||
mod v1;
|
||||
mod v2;
|
||||
mod v3;
|
||||
mod v4;
|
||||
|
||||
use std::{hash::Hash, path::PathBuf};
|
||||
|
||||
use native_model::native_model;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::db::DropDatabaseSerializer;
|
||||
|
||||
|
||||
// NOTE: Within each version, you should NEVER use these types.
|
||||
// Declare it using the actual version that it is from, i.e. v1::Settings rather than just Settings from here
|
||||
|
||||
pub type GameVersion = v1::GameVersion;
|
||||
pub type Database = v4::Database;
|
||||
pub type Settings = v1::Settings;
|
||||
pub type DatabaseAuth = v1::DatabaseAuth;
|
||||
|
||||
pub type GameDownloadStatus = v2::GameDownloadStatus;
|
||||
pub type ApplicationTransientStatus = v1::ApplicationTransientStatus;
|
||||
/**
|
||||
* Need to be universally accessible by the ID, and the version is just a couple sprinkles on top
|
||||
*/
|
||||
pub type DownloadableMetadata = v1::DownloadableMetadata;
|
||||
pub type DownloadType = v1::DownloadType;
|
||||
pub type DatabaseApplications = v2::DatabaseApplications;
|
||||
// pub type DatabaseCompatInfo = v2::DatabaseCompatInfo;
|
||||
|
||||
pub type Game = v1::Game;
|
||||
|
||||
impl Game {
|
||||
pub fn id(&self) -> &String {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
|
||||
pub type DatabaseInterface =
|
||||
rustbreak::Database<Database, rustbreak::backend::PathBackend, DropDatabaseSerializer>;
|
||||
|
||||
pub type LibraryMetadata = v1::LibraryMetadata;
|
||||
pub type LibraryProviderMetadata = v1::LibraryProviderMetadata;
|
||||
pub type ProviderType = v1::ProviderType;
|
||||
|
||||
pub type Collection = v1::Collection;
|
||||
pub type CollectionObject = v1::CollectionObject;
|
||||
|
||||
impl PartialEq for DownloadableMetadata {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.id == other.id && self.download_type == other.download_type
|
||||
}
|
||||
}
|
||||
impl Hash for DownloadableMetadata {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.id.hash(state);
|
||||
self.download_type.hash(state);
|
||||
}
|
||||
}
|
||||
impl LibraryProviderMetadata {
|
||||
pub fn provider(&self) -> &ProviderType {
|
||||
&self.provider
|
||||
}
|
||||
pub fn id(&self) -> usize {
|
||||
self.id
|
||||
}
|
||||
pub fn name(&self) -> &String {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl Database {
|
||||
pub fn new<T: Into<PathBuf>>(
|
||||
games_base_dir: T,
|
||||
prev_database: Option<PathBuf>,
|
||||
cache_dir: PathBuf,
|
||||
) -> Self {
|
||||
Self {
|
||||
prev_database,
|
||||
settings: Settings::default(),
|
||||
cache_dir,
|
||||
compat_info: None,
|
||||
library: v1::LibraryMetadata { providers: vec![] },
|
||||
}
|
||||
}
|
||||
}
|
||||
impl DatabaseAuth {
|
||||
pub fn new(
|
||||
private: String,
|
||||
cert: String,
|
||||
client_id: String,
|
||||
web_token: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
private,
|
||||
cert,
|
||||
client_id,
|
||||
web_token,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LibraryMetadata {
|
||||
pub fn providers(&self) -> &Vec<LibraryProviderMetadata> {
|
||||
&self.providers
|
||||
}
|
||||
}
|
||||
@ -1,201 +0,0 @@
|
||||
use bitcode::{Decode, Encode};
|
||||
use serde_with::serde_as;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use crate::{models::v1, platform::Platform};
|
||||
|
||||
use super::{Deserialize, Serialize, native_model};
|
||||
|
||||
fn default_template() -> String {
|
||||
"{}".to_owned()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 2, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct GameVersion {
|
||||
pub game_id: String,
|
||||
pub version_name: String,
|
||||
|
||||
pub platform: Platform,
|
||||
|
||||
pub launch_command: String,
|
||||
pub launch_args: Vec<String>,
|
||||
#[serde(default = "default_template")]
|
||||
pub launch_command_template: String,
|
||||
|
||||
pub setup_command: String,
|
||||
pub setup_args: Vec<String>,
|
||||
#[serde(default = "default_template")]
|
||||
pub setup_command_template: String,
|
||||
|
||||
pub only_setup: bool,
|
||||
|
||||
pub version_index: usize,
|
||||
pub delta: bool,
|
||||
|
||||
pub umu_id_override: Option<String>,
|
||||
}
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 3, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct DatabaseApplications {
|
||||
pub install_dirs: Vec<PathBuf>,
|
||||
// Guaranteed to exist if the game also exists in the app state map
|
||||
pub game_statuses: HashMap<String, v1::GameDownloadStatus>,
|
||||
pub game_versions: HashMap<String, HashMap<String, v1::GameVersion>>,
|
||||
pub installed_game_version: HashMap<String, v1::DownloadableMetadata>,
|
||||
|
||||
#[serde(skip)]
|
||||
pub transient_statuses: HashMap<v1::DownloadableMetadata, v1::ApplicationTransientStatus>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 4, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct Settings {
|
||||
pub autostart: bool,
|
||||
pub max_download_threads: usize,
|
||||
pub force_offline: bool, // ... other settings ...
|
||||
}
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
autostart: false,
|
||||
max_download_threads: 4,
|
||||
force_offline: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Strings are version names for a particular game
|
||||
#[derive(Serialize, Clone, Deserialize, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
#[native_model(id = 5, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub enum GameDownloadStatus {
|
||||
Remote {},
|
||||
SetupRequired {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
Installed {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
}
|
||||
|
||||
// Stuff that shouldn't be synced to disk
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub enum ApplicationTransientStatus {
|
||||
Queued { version_name: String },
|
||||
Downloading { version_name: String },
|
||||
Uninstalling {},
|
||||
Updating { version_name: String },
|
||||
Validating { version_name: String },
|
||||
Running {},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Encode, Decode)]
|
||||
#[native_model(id = 6, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
pub struct DatabaseAuth {
|
||||
pub private: String,
|
||||
pub cert: String,
|
||||
pub client_id: String,
|
||||
pub web_token: Option<String>,
|
||||
}
|
||||
|
||||
#[native_model(id = 8, version = 1)]
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy)]
|
||||
pub enum DownloadType {
|
||||
Game,
|
||||
Tool,
|
||||
Dlc,
|
||||
Mod,
|
||||
}
|
||||
|
||||
#[native_model(id = 7, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Debug, Eq, PartialOrd, Ord, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DownloadableMetadata {
|
||||
pub id: String,
|
||||
pub version: Option<String>,
|
||||
pub download_type: v1::DownloadType,
|
||||
}
|
||||
impl DownloadableMetadata {
|
||||
pub fn new(id: String, version: Option<String>, download_type: v1::DownloadType) -> Self {
|
||||
Self {
|
||||
id,
|
||||
version,
|
||||
download_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[native_model(id = 1, version = 1)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: Settings,
|
||||
pub auth: Option<v1::DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: v1::DatabaseApplications,
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
}
|
||||
#[native_model(id = 15, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Encode, Decode, Default)]
|
||||
pub struct LibraryMetadata {
|
||||
pub(crate) providers: Vec<v1::LibraryProviderMetadata>
|
||||
}
|
||||
|
||||
|
||||
#[native_model(id = 11, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Encode, Decode)]
|
||||
pub struct LibraryProviderMetadata {
|
||||
pub(crate) id: usize,
|
||||
pub(crate) name: String,
|
||||
pub(crate) provider: v1::ProviderType
|
||||
}
|
||||
#[native_model(id = 10, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Encode, Decode)]
|
||||
pub enum ProviderType {
|
||||
Drop(v1::DatabaseAuth),
|
||||
}
|
||||
#[native_model(id = 12, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Encode, Decode)]
|
||||
pub struct Game {
|
||||
pub library_id: LibraryProviderMetadata,
|
||||
pub(crate) id: String,
|
||||
m_name: String,
|
||||
m_short_description: String,
|
||||
m_description: String,
|
||||
// mDevelopers
|
||||
// mPublishers
|
||||
m_icon_object_id: String,
|
||||
m_banner_object_id: String,
|
||||
m_cover_object_id: String,
|
||||
m_image_library_object_ids: Vec<String>,
|
||||
m_image_carousel_object_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[native_model(id = 13, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Collection {
|
||||
id: String,
|
||||
name: String,
|
||||
is_default: bool,
|
||||
user_id: String,
|
||||
entries: Vec<CollectionObject>,
|
||||
}
|
||||
|
||||
#[native_model(id = 14, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CollectionObject {
|
||||
collection_id: String,
|
||||
game_id: String,
|
||||
game: Game,
|
||||
}
|
||||
@ -1,111 +0,0 @@
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use serde_with::serde_as;
|
||||
|
||||
use super::{Deserialize, Serialize, native_model, v1};
|
||||
|
||||
#[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from = v1::Database)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: v1::Settings,
|
||||
pub auth: Option<v1::DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: v1::DatabaseApplications,
|
||||
#[serde(skip)]
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
pub compat_info: Option<DatabaseCompatInfo>,
|
||||
}
|
||||
|
||||
#[native_model(id = 9, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
|
||||
pub struct DatabaseCompatInfo {
|
||||
pub umu_installed: bool,
|
||||
}
|
||||
|
||||
impl From<v1::Database> for Database {
|
||||
fn from(value: v1::Database) -> Self {
|
||||
Self {
|
||||
settings: value.settings,
|
||||
auth: value.auth,
|
||||
base_url: value.base_url,
|
||||
applications: value.applications,
|
||||
prev_database: value.prev_database,
|
||||
cache_dir: value.cache_dir,
|
||||
compat_info: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Strings are version names for a particular game
|
||||
#[derive(Serialize, Clone, Deserialize, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
#[native_model(id = 5, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from = v1::GameDownloadStatus)]
|
||||
pub enum GameDownloadStatus {
|
||||
Remote {},
|
||||
SetupRequired {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
Installed {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
PartiallyInstalled {
|
||||
version_name: String,
|
||||
install_dir: String,
|
||||
},
|
||||
}
|
||||
impl From<v1::GameDownloadStatus> for GameDownloadStatus {
|
||||
fn from(value: v1::GameDownloadStatus) -> Self {
|
||||
match value {
|
||||
v1::GameDownloadStatus::Remote {} => Self::Remote {},
|
||||
v1::GameDownloadStatus::SetupRequired {
|
||||
version_name,
|
||||
install_dir,
|
||||
} => Self::SetupRequired {
|
||||
version_name,
|
||||
install_dir,
|
||||
},
|
||||
v1::GameDownloadStatus::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
} => Self::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
#[serde_as]
|
||||
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[native_model(id = 3, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from=v1::DatabaseApplications)]
|
||||
pub struct DatabaseApplications {
|
||||
pub install_dirs: Vec<PathBuf>,
|
||||
// Guaranteed to exist if the game also exists in the app state map
|
||||
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
||||
|
||||
pub game_versions: HashMap<String, HashMap<String, v1::GameVersion>>,
|
||||
pub installed_game_version: HashMap<String, v1::DownloadableMetadata>,
|
||||
|
||||
#[serde(skip)]
|
||||
pub transient_statuses:
|
||||
HashMap<v1::DownloadableMetadata, v1::ApplicationTransientStatus>,
|
||||
}
|
||||
impl From<v1::DatabaseApplications> for DatabaseApplications {
|
||||
fn from(value: v1::DatabaseApplications) -> Self {
|
||||
Self {
|
||||
game_statuses: value
|
||||
.game_statuses
|
||||
.into_iter()
|
||||
.map(|x| (x.0, x.1.into()))
|
||||
.collect::<HashMap<String, GameDownloadStatus>>(),
|
||||
install_dirs: value.install_dirs,
|
||||
game_versions: value.game_versions,
|
||||
installed_game_version: value.installed_game_version,
|
||||
transient_statuses: value.transient_statuses,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use serde_with::serde_as;
|
||||
|
||||
use super::{Deserialize, Serialize, native_model, v1, v2};
|
||||
#[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde, from = v2::Database)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: v1::Settings,
|
||||
pub auth: Option<v1::DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: v2::DatabaseApplications,
|
||||
#[serde(skip)]
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
pub compat_info: Option<v2::DatabaseCompatInfo>,
|
||||
}
|
||||
|
||||
impl From<v2::Database> for Database {
|
||||
fn from(value: v2::Database) -> Self {
|
||||
Self {
|
||||
settings: value.settings,
|
||||
auth: value.auth,
|
||||
base_url: value.base_url,
|
||||
applications: value.applications.into(),
|
||||
prev_database: value.prev_database,
|
||||
cache_dir: value.cache_dir,
|
||||
compat_info: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use native_model::native_model;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::models::{
|
||||
v1::{self, LibraryMetadata},
|
||||
v2, v3,
|
||||
};
|
||||
|
||||
#[native_model(id = 1, version = 4, with = native_model::rmp_serde_1_3::RmpSerde, from = v3::Database)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: v1::Settings,
|
||||
#[serde(skip)]
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
pub compat_info: Option<v2::DatabaseCompatInfo>,
|
||||
pub library: v1::LibraryMetadata,
|
||||
}
|
||||
|
||||
impl From<v3::Database> for Database {
|
||||
fn from(value: v3::Database) -> Self {
|
||||
Self {
|
||||
settings: value.settings,
|
||||
prev_database: value.prev_database,
|
||||
cache_dir: value.cache_dir,
|
||||
compat_info: value.compat_info,
|
||||
library: v1::LibraryMetadata {
|
||||
providers: if let Some(auth) = value.auth {
|
||||
vec![v1::LibraryProviderMetadata {
|
||||
id: 0,
|
||||
name: String::from("Default"),
|
||||
provider: v1::ProviderType::Drop(auth),
|
||||
}]
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,20 +4,20 @@ use serde::{Deserialize, Serialize};
|
||||
pub enum Platform {
|
||||
Windows,
|
||||
Linux,
|
||||
macOS,
|
||||
MacOs,
|
||||
}
|
||||
|
||||
impl Platform {
|
||||
#[cfg(target_os = "windows")]
|
||||
pub const HOST: Platform = Self::Windows;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub const HOST: Platform = Self::macOS;
|
||||
pub const HOST: Platform = Self::MacOs;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const HOST: Platform = Self::Linux;
|
||||
|
||||
pub fn is_case_sensitive(&self) -> bool {
|
||||
match self {
|
||||
Self::Windows | Self::macOS => false,
|
||||
Self::Windows | Self::MacOs => false,
|
||||
Self::Linux => true,
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ impl From<&str> for Platform {
|
||||
match value.to_lowercase().trim() {
|
||||
"windows" => Self::Windows,
|
||||
"linux" => Self::Linux,
|
||||
"mac" | "macos" => Self::macOS,
|
||||
"mac" | "macos" => Self::MacOs,
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ impl From<whoami::Platform> for Platform {
|
||||
match value {
|
||||
whoami::Platform::Windows => Platform::Windows,
|
||||
whoami::Platform::Linux => Platform::Linux,
|
||||
whoami::Platform::MacOS => Platform::macOS,
|
||||
whoami::Platform::MacOS => Platform::MacOs,
|
||||
platform => unimplemented!("Playform {} is not supported", platform),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
[package]
|
||||
name = "drop-consts"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
dirs = "6.0.0"
|
||||
@ -1,16 +0,0 @@
|
||||
use std::{path::PathBuf, sync::LazyLock};
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const DATA_ROOT_PREFIX: &str = "drop";
|
||||
#[cfg(debug_assertions)]
|
||||
pub const DATA_ROOT_PREFIX: &str = "drop-debug";
|
||||
|
||||
pub const DROP_DATA_PATH: &str = ".dropdata";
|
||||
|
||||
pub const RETRY_COUNT: usize = 3;
|
||||
|
||||
pub const TARGET_BUCKET_SIZE: usize = 63 * 1000 * 1000;
|
||||
pub const MAX_FILES_PER_BUCKET: usize = (1024 / 4) - 1;
|
||||
|
||||
pub const UMU_BASE_LAUNCHER_EXECUTABLE: &str = "umu-run";
|
||||
pub const UMU_INSTALL_DIRS: [&str; 4] = ["/app/share", "/use/local/share", "/usr/share", "/opt"];
|
||||
@ -22,8 +22,5 @@ sysinfo = "0.37.2"
|
||||
tauri = "2.8.5"
|
||||
throttle_my_fn = "0.2.6"
|
||||
utils = { version = "0.1.0", path = "../utils" }
|
||||
native_model = { version = "0.6.4", features = [
|
||||
"rmp_serde_1_3",
|
||||
], git = "https://github.com/Drop-OSS/native_model.git" }
|
||||
native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"}
|
||||
serde_json = "1.0.145"
|
||||
drop-consts = { version = "0.1.0", path = "../drop-consts" }
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
use bitcode::{Decode, Encode};
|
||||
use database::models::Game;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::library::Game;
|
||||
|
||||
pub type Collections = Vec<Collection>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Encode, Decode)]
|
||||
@ -14,7 +15,7 @@ pub struct Collection {
|
||||
entries: Vec<CollectionObject>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Encode, Decode)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CollectionObject {
|
||||
collection_id: String,
|
||||
|
||||
@ -9,7 +9,6 @@ use download_manager::util::download_thread_control_flag::{
|
||||
DownloadThreadControl, DownloadThreadControlFlag,
|
||||
};
|
||||
use download_manager::util::progress_object::{ProgressHandle, ProgressObject};
|
||||
use drop_consts::{MAX_FILES_PER_BUCKET, RETRY_COUNT, TARGET_BUCKET_SIZE};
|
||||
use log::{debug, error, info, warn};
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use remote::auth::generate_authorization_header;
|
||||
@ -40,6 +39,11 @@ use crate::state::GameStatusManager;
|
||||
use super::download_logic::download_game_bucket;
|
||||
use super::drop_data::DropData;
|
||||
|
||||
static RETRY_COUNT: usize = 3;
|
||||
|
||||
const TARGET_BUCKET_SIZE: usize = 63 * 1000 * 1000;
|
||||
const MAX_FILES_PER_BUCKET: usize = (1024 / 4) - 1;
|
||||
|
||||
pub struct GameDownloadAgent {
|
||||
pub id: String,
|
||||
pub version: String,
|
||||
|
||||
@ -5,13 +5,14 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use drop_consts::DROP_DATA_PATH;
|
||||
use log::error;
|
||||
use native_model::{Decode, Encode};
|
||||
use utils::lock;
|
||||
|
||||
pub type DropData = v1::DropData;
|
||||
|
||||
pub static DROP_DATA_PATH: &str = ".dropdata";
|
||||
|
||||
pub mod v1 {
|
||||
use std::{collections::HashMap, path::PathBuf, sync::Mutex};
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
use bitcode::{Decode, Encode};
|
||||
use database::{
|
||||
borrow_db_checked, borrow_db_mut_checked, models::Game, ApplicationTransientStatus, Database, DownloadableMetadata, GameDownloadStatus, GameVersion
|
||||
ApplicationTransientStatus, Database, DownloadableMetadata, GameDownloadStatus, GameVersion,
|
||||
borrow_db_checked, borrow_db_mut_checked,
|
||||
};
|
||||
use log::{debug, error, warn};
|
||||
use remote::{
|
||||
@ -31,6 +33,26 @@ impl FetchGameStruct {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default, Encode, Decode)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Game {
|
||||
id: String,
|
||||
m_name: String,
|
||||
m_short_description: String,
|
||||
m_description: String,
|
||||
// mDevelopers
|
||||
// mPublishers
|
||||
m_icon_object_id: String,
|
||||
m_banner_object_id: String,
|
||||
m_cover_object_id: String,
|
||||
m_image_library_object_ids: Vec<String>,
|
||||
m_image_carousel_object_ids: Vec<String>,
|
||||
}
|
||||
impl Game {
|
||||
pub fn id(&self) -> &String {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
#[derive(serde::Serialize, Clone)]
|
||||
pub struct GameUpdateEvent {
|
||||
pub game_id: String,
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
use std::fs;
|
||||
|
||||
use database::{DownloadType, DownloadableMetadata, borrow_db_mut_checked};
|
||||
use drop_consts::DROP_DATA_PATH;
|
||||
use log::warn;
|
||||
|
||||
use crate::{
|
||||
downloads::drop_data::DropData,
|
||||
downloads::drop_data::{DROP_DATA_PATH, DropData},
|
||||
library::set_partially_installed_db,
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use database::{
|
||||
use database::models::data::{
|
||||
ApplicationTransientStatus, Database, DownloadType, DownloadableMetadata, GameDownloadStatus,
|
||||
};
|
||||
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
[package]
|
||||
name = "library"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.89"
|
||||
client = { version = "0.1.0", path = "../client" }
|
||||
database = { version = "0.1.0", path = "../database" }
|
||||
futures = "0.3.31"
|
||||
itertools = "0.14.0"
|
||||
log = "0.4.28"
|
||||
remote = { version = "0.1.0", path = "../remote" }
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_with = "3.15.0"
|
||||
tauri = "2.8.5"
|
||||
url = "2.5.7"
|
||||
@ -1,134 +0,0 @@
|
||||
use std::sync::nonpoison::Mutex;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use client::app_state::AppState;
|
||||
use database::{
|
||||
DatabaseAuth, GameDownloadStatus, borrow_db_mut_checked,
|
||||
models::{Collection, Game, LibraryProviderMetadata},
|
||||
};
|
||||
use log::warn;
|
||||
use remote::{
|
||||
auth::generate_authorization_header,
|
||||
cache::{cache_object, get_cached_object, get_cached_object_db},
|
||||
error::{DropServerError, RemoteAccessError},
|
||||
requests::generate_url,
|
||||
utils::DROP_CLIENT_ASYNC,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use crate::{error::LibraryError, provider::LibraryProvider};
|
||||
|
||||
pub struct DropLibraryProvider {
|
||||
metadata: LibraryProviderMetadata,
|
||||
auth: DatabaseAuth,
|
||||
base_url: Url,
|
||||
}
|
||||
|
||||
impl DropLibraryProvider {
|
||||
pub fn new(metadata: LibraryProviderMetadata, auth: DatabaseAuth, base_url: Url) -> Self {
|
||||
Self {
|
||||
metadata,
|
||||
auth,
|
||||
base_url,
|
||||
}
|
||||
}
|
||||
}
|
||||
#[async_trait]
|
||||
impl LibraryProvider for DropLibraryProvider {
|
||||
async fn get_library(
|
||||
&self,
|
||||
state: &tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<Vec<Game>, LibraryError> {
|
||||
// let do_hard_refresh = hard_fresh.unwrap_or(false);
|
||||
if
|
||||
/* !do_hard_refresh &&*/
|
||||
let Ok(library) = get_cached_object("library") {
|
||||
return Ok(library);
|
||||
}
|
||||
|
||||
let client = DROP_CLIENT_ASYNC.clone();
|
||||
let response = generate_url(&["/api/v1/client/user/library"], &[], self.base_url)?;
|
||||
let response = client
|
||||
.get(response)
|
||||
.header("Authorization", generate_authorization_header(self.auth))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| LibraryError::FetchError(RemoteAccessError::FetchError(e.into())))?;
|
||||
|
||||
if response.status() != 200 {
|
||||
let err = response.json().await.unwrap_or(DropServerError {
|
||||
status_code: 500,
|
||||
status_message: "Invalid response from server.".to_owned(),
|
||||
});
|
||||
warn!("{err:?}");
|
||||
return Err(LibraryError::FetchError(
|
||||
RemoteAccessError::InvalidResponse(err),
|
||||
));
|
||||
}
|
||||
|
||||
let mut games: Vec<Game> = response
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| RemoteAccessError::FetchError(e.into()))?;
|
||||
|
||||
let mut handle = state.lock();
|
||||
|
||||
let mut db_handle = borrow_db_mut_checked();
|
||||
|
||||
for game in &games {
|
||||
handle.games_mut().insert(game.id().clone(), game.clone());
|
||||
if !db_handle.applications.game_statuses.contains_key(game.id()) {
|
||||
db_handle
|
||||
.applications
|
||||
.game_statuses
|
||||
.insert(game.id().clone(), GameDownloadStatus::Remote {});
|
||||
}
|
||||
}
|
||||
|
||||
// Add games that are installed but no longer in library
|
||||
for meta in db_handle.applications.installed_game_version.values() {
|
||||
if games.iter().any(|e| *e.id() == meta.id) {
|
||||
continue;
|
||||
}
|
||||
// We should always have a cache of the object
|
||||
// Pass db_handle because otherwise we get a gridlock
|
||||
let game = match get_cached_object_db::<Game>(&meta.id.clone(), &db_handle) {
|
||||
Ok(game) => game,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
"{} is installed, but encountered error fetching its error: {}.",
|
||||
meta.id, err
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
games.push(game);
|
||||
}
|
||||
|
||||
drop(handle);
|
||||
drop(db_handle);
|
||||
cache_object("library", &games)?;
|
||||
|
||||
Ok(games)
|
||||
}
|
||||
async fn get_collections(&self) -> Result<Vec<Collection>, LibraryError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn install(&mut self, game_id: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn uninstall(&mut self, game_id: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn metadata(&self) -> LibraryProviderMetadata {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
async fn fetch_library_logic(state: &Mutex<AppState>) -> Result<Vec<Game>, RemoteAccessError> {}
|
||||
async fn fetch_library_logic_offline() -> Result<Vec<Game>, RemoteAccessError> {
|
||||
todo!()
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
pub mod drop;
|
||||
@ -1,31 +0,0 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use database::models::LibraryProviderMetadata;
|
||||
use remote::error::RemoteAccessError;
|
||||
use serde_with::SerializeDisplay;
|
||||
|
||||
#[derive(Debug, SerializeDisplay)]
|
||||
pub enum LibraryError {
|
||||
ProviderConnection(ProviderError),
|
||||
FetchError(RemoteAccessError)
|
||||
}
|
||||
#[derive(Debug, SerializeDisplay)]
|
||||
pub struct ProviderError {
|
||||
provider: LibraryProviderMetadata
|
||||
}
|
||||
|
||||
impl Display for LibraryError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
impl Display for ProviderError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
impl From<RemoteAccessError> for LibraryError {
|
||||
fn from(value: RemoteAccessError) -> Self {
|
||||
LibraryError::FetchError(value)
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
#![feature(nonpoison_mutex)]
|
||||
#![feature(sync_nonpoison)]
|
||||
|
||||
use std::sync::{LazyLock, nonpoison::Mutex};
|
||||
|
||||
use client::app_state::AppState;
|
||||
use database::{borrow_db_checked, models::{Game, LibraryProviderMetadata, ProviderType}};
|
||||
use futures::{StreamExt, future::join_all};
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{drop::drop::DropLibraryProvider, error::LibraryError, provider::LibraryProvider};
|
||||
|
||||
pub mod drop;
|
||||
pub mod error;
|
||||
pub mod provider;
|
||||
|
||||
pub static LIBRARY: LazyLock<Library> = LazyLock::new(Library::init);
|
||||
|
||||
pub struct Library {
|
||||
providers: Vec<Box<dyn LibraryProvider>>,
|
||||
}
|
||||
|
||||
impl Library {
|
||||
pub fn init() -> Self {
|
||||
let metadata = borrow_db_checked();
|
||||
let library = &metadata.library;
|
||||
let providers = library.providers().iter().map(|provider| {
|
||||
Library::construct(provider)
|
||||
}).collect();
|
||||
Self {
|
||||
providers
|
||||
}
|
||||
}
|
||||
fn construct(provider: &LibraryProviderMetadata) -> Box<dyn LibraryProvider> {
|
||||
todo!()
|
||||
}
|
||||
pub async fn get_library(
|
||||
&self,
|
||||
state: &tauri::State<'_, Mutex<AppState>>,
|
||||
) -> (Vec<Game>, Vec<LibraryError>) {
|
||||
let res = join_all(
|
||||
self.providers
|
||||
.iter()
|
||||
.map(|provider| provider.get_library(state)),
|
||||
)
|
||||
.await
|
||||
.into_iter()
|
||||
.fold(
|
||||
(Vec::new(), Vec::new()),
|
||||
|(mut acc_ok, mut acc_err), res| {
|
||||
match res {
|
||||
Ok(games) => acc_ok.extend(games),
|
||||
Err(e) => acc_err.push(e),
|
||||
};
|
||||
(acc_ok, acc_err)
|
||||
},
|
||||
);
|
||||
res
|
||||
}
|
||||
pub fn add(&mut self, provider: LibraryProviderMetadata) {
|
||||
let new_provider = Box::new(match provider.provider() {
|
||||
ProviderType::Drop(_) => DropLibraryProvider::new(provider),
|
||||
});
|
||||
self.providers.push(new_provider);
|
||||
}
|
||||
pub fn remove(&mut self, id: usize) {
|
||||
self.providers.retain(|v| v.metadata().id() != id);
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
use std::sync::nonpoison::Mutex;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use client::app_state::AppState;
|
||||
use database::models::{Collection, Game, LibraryProviderMetadata};
|
||||
|
||||
use crate::error::LibraryError;
|
||||
|
||||
#[async_trait]
|
||||
pub trait LibraryProvider: Sync + Send {
|
||||
async fn get_library(&self, state: &tauri::State<'_, Mutex<AppState>>) -> Result<Vec<Game>, LibraryError>;
|
||||
async fn get_collections(&self) -> Result<Vec<Collection>, LibraryError>;
|
||||
fn install(&mut self, game_id: String);
|
||||
fn uninstall(&mut self, game_id: String);
|
||||
fn metadata(&self) -> LibraryProviderMetadata;
|
||||
}
|
||||
@ -54,7 +54,7 @@ impl ProcessManager<'_> {
|
||||
current_platform: Platform::Windows,
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
current_platform: Platform::macOS,
|
||||
current_platform: Platform::MacOs,
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
current_platform: Platform::Linux,
|
||||
@ -72,7 +72,7 @@ impl ProcessManager<'_> {
|
||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||
),
|
||||
(
|
||||
(Platform::macOS, Platform::macOS),
|
||||
(Platform::MacOs, Platform::MacOs),
|
||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||
),
|
||||
(
|
||||
|
||||
@ -60,17 +60,22 @@ impl From<HandshakeResponse> for DatabaseAuth {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_authorization_header(auth: DatabaseAuth) -> String {
|
||||
pub fn generate_authorization_header() -> String {
|
||||
let certs = {
|
||||
let db = borrow_db_checked();
|
||||
db.auth.clone().expect("Authorisation not initialised")
|
||||
};
|
||||
|
||||
let nonce = Utc::now().timestamp_millis().to_string();
|
||||
|
||||
let signature =
|
||||
sign_nonce(auth.private, nonce.clone()).expect("Failed to generate authorisation header");
|
||||
sign_nonce(certs.private, nonce.clone()).expect("Failed to generate authorisation header");
|
||||
|
||||
format!("Nonce {} {} {}", auth.client_id, nonce, signature)
|
||||
format!("Nonce {} {} {}", certs.client_id, nonce, signature)
|
||||
}
|
||||
|
||||
pub async fn fetch_user(auth: DatabaseAuth, base_url: Url) -> Result<User, RemoteAccessError> {
|
||||
let response = make_authenticated_get(generate_url(&["/api/v1/client/user"], &[], base_url)?, auth).await?;
|
||||
pub async fn fetch_user() -> Result<User, RemoteAccessError> {
|
||||
let response = make_authenticated_get(generate_url(&["/api/v1/client/user"], &[])?).await?;
|
||||
if response.status() != 200 {
|
||||
let err: DropServerError = response.json().await?;
|
||||
warn!("{err:?}");
|
||||
@ -88,7 +93,12 @@ pub async fn fetch_user(auth: DatabaseAuth, base_url: Url) -> Result<User, Remot
|
||||
.map_err(std::convert::Into::into)
|
||||
}
|
||||
|
||||
pub fn auth_initiate_logic(mode: String, base_url: Url) -> Result<String, RemoteAccessError> {
|
||||
pub fn auth_initiate_logic(mode: String) -> Result<String, RemoteAccessError> {
|
||||
let base_url = {
|
||||
let db_lock = borrow_db_checked();
|
||||
Url::parse(&db_lock.base_url.clone())?
|
||||
};
|
||||
|
||||
let hostname = gethostname();
|
||||
|
||||
let endpoint = base_url.join("/api/v1/client/auth/initiate")?;
|
||||
@ -117,17 +127,26 @@ pub fn auth_initiate_logic(mode: String, base_url: Url) -> Result<String, Remote
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
pub async fn setup(auth: DatabaseAuth, base_url: Url) -> (AppStatus, Option<User>) {
|
||||
let user_result = match fetch_user(auth, base_url).await {
|
||||
Ok(data) => data,
|
||||
Err(RemoteAccessError::FetchError(_)) => {
|
||||
let user = get_cached_object::<User>("user").ok();
|
||||
return (AppStatus::Offline, user);
|
||||
}
|
||||
Err(_) => return (AppStatus::SignedInNeedsReauth, None),
|
||||
pub async fn setup() -> (AppStatus, Option<User>) {
|
||||
let auth = {
|
||||
let data = borrow_db_checked();
|
||||
data.auth.clone()
|
||||
};
|
||||
if let Err(e) = cache_object("user", &user_result) {
|
||||
warn!("Could not cache user object with error {e}");
|
||||
|
||||
if auth.is_some() {
|
||||
let user_result = match fetch_user().await {
|
||||
Ok(data) => data,
|
||||
Err(RemoteAccessError::FetchError(_)) => {
|
||||
let user = get_cached_object::<User>("user").ok();
|
||||
return (AppStatus::Offline, user);
|
||||
}
|
||||
Err(_) => return (AppStatus::SignedInNeedsReauth, None),
|
||||
};
|
||||
if let Err(e) = cache_object("user", &user_result) {
|
||||
warn!("Could not cache user object with error {e}");
|
||||
}
|
||||
return (AppStatus::SignedIn, Some(user_result));
|
||||
}
|
||||
return (AppStatus::SignedIn, Some(user_result));
|
||||
|
||||
(AppStatus::SignedOut, None)
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ macro_rules! offline {
|
||||
|
||||
async move {
|
||||
if ::database::borrow_db_checked().settings.force_offline
|
||||
|| *$var.lock().status() == ::client::app_status::AppStatus::Offline {
|
||||
|| $var.lock().status == ::client::app_status::AppStatus::Offline {
|
||||
$func2( $( $arg ), *).await
|
||||
} else {
|
||||
$func1( $( $arg ), *).await
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
use database::{DB, DatabaseAuth, interface::DatabaseImpls};
|
||||
use database::{DB, interface::DatabaseImpls};
|
||||
use http::{Response, header::CONTENT_TYPE, response::Builder as ResponseBuilder};
|
||||
use log::{debug, warn};
|
||||
use tauri::UriSchemeResponder;
|
||||
use url::Url;
|
||||
|
||||
use crate::{error::CacheError, utils::DROP_CLIENT_ASYNC};
|
||||
|
||||
@ -11,8 +10,8 @@ use super::{
|
||||
cache::{ObjectCache, cache_object, get_cached_object},
|
||||
};
|
||||
|
||||
pub async fn fetch_object_wrapper(request: http::Request<Vec<u8>>, responder: UriSchemeResponder, auth: DatabaseAuth, base_url: Url) {
|
||||
match fetch_object(request, auth, base_url).await {
|
||||
pub async fn fetch_object_wrapper(request: http::Request<Vec<u8>>, responder: UriSchemeResponder) {
|
||||
match fetch_object(request).await {
|
||||
Ok(r) => responder.respond(r),
|
||||
Err(e) => {
|
||||
warn!("Cache error: {e}");
|
||||
@ -28,8 +27,6 @@ pub async fn fetch_object_wrapper(request: http::Request<Vec<u8>>, responder: Ur
|
||||
|
||||
pub async fn fetch_object(
|
||||
request: http::Request<Vec<u8>>,
|
||||
auth: DatabaseAuth,
|
||||
base_url: Url
|
||||
) -> Result<Response<Vec<u8>>, CacheError> {
|
||||
// Drop leading /
|
||||
let object_id = &request.uri().path()[1..];
|
||||
@ -41,9 +38,9 @@ pub async fn fetch_object(
|
||||
return cache_result.try_into();
|
||||
}
|
||||
|
||||
let header = generate_authorization_header(auth);
|
||||
let header = generate_authorization_header();
|
||||
let client = DROP_CLIENT_ASYNC.clone();
|
||||
let url = format!("{}api/v1/client/object/{object_id}", base_url);
|
||||
let url = format!("{}api/v1/client/object/{object_id}", DB.fetch_base_url());
|
||||
let response = client.get(url).header("Authorization", header).send().await;
|
||||
|
||||
match response {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use database::{DB, DatabaseAuth, interface::DatabaseImpls};
|
||||
use database::{DB, interface::DatabaseImpls};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
@ -8,9 +8,8 @@ use crate::{
|
||||
pub fn generate_url<T: AsRef<str>>(
|
||||
path_components: &[T],
|
||||
query: &[(T, T)],
|
||||
base_url: Url
|
||||
) -> Result<Url, RemoteAccessError> {
|
||||
let mut base_url = base_url.clone();
|
||||
let mut base_url = DB.fetch_base_url();
|
||||
for endpoint in path_components {
|
||||
base_url = base_url.join(endpoint.as_ref())?;
|
||||
}
|
||||
@ -23,10 +22,10 @@ pub fn generate_url<T: AsRef<str>>(
|
||||
Ok(base_url)
|
||||
}
|
||||
|
||||
pub async fn make_authenticated_get(url: Url, auth: DatabaseAuth) -> Result<reqwest::Response, reqwest::Error> {
|
||||
pub async fn make_authenticated_get(url: Url) -> Result<reqwest::Response, reqwest::Error> {
|
||||
DROP_CLIENT_ASYNC
|
||||
.get(url)
|
||||
.header("Authorization", generate_authorization_header(auth))
|
||||
.header("Authorization", generate_authorization_header())
|
||||
.send()
|
||||
.await
|
||||
}
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use database::{DatabaseAuth, borrow_db_checked};
|
||||
use database::borrow_db_checked;
|
||||
use http::{Request, Response, StatusCode, Uri, uri::PathAndQuery};
|
||||
use log::warn;
|
||||
use log::{error, warn};
|
||||
use tauri::UriSchemeResponder;
|
||||
use url::Url;
|
||||
use utils::webbrowser_open::webbrowser_open;
|
||||
|
||||
use crate::utils::DROP_CLIENT_SYNC;
|
||||
@ -28,8 +27,8 @@ pub async fn handle_server_proto_offline(
|
||||
.expect("Failed to build error response for proto offline"))
|
||||
}
|
||||
|
||||
pub async fn handle_server_proto_wrapper(request: Request<Vec<u8>>, responder: UriSchemeResponder, auth: DatabaseAuth, base_url: Url) {
|
||||
match handle_server_proto(request, auth, base_url).await {
|
||||
pub async fn handle_server_proto_wrapper(request: Request<Vec<u8>>, responder: UriSchemeResponder) {
|
||||
match handle_server_proto(request).await {
|
||||
Ok(r) => responder.respond(r),
|
||||
Err(e) => {
|
||||
warn!("Cache error: {e}");
|
||||
@ -43,16 +42,23 @@ pub async fn handle_server_proto_wrapper(request: Request<Vec<u8>>, responder: U
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_server_proto(
|
||||
request: Request<Vec<u8>>,
|
||||
auth: DatabaseAuth,
|
||||
base_url: Url,
|
||||
) -> Result<Response<Vec<u8>>, StatusCode> {
|
||||
async fn handle_server_proto(request: Request<Vec<u8>>) -> Result<Response<Vec<u8>>, StatusCode> {
|
||||
let db_handle = borrow_db_checked();
|
||||
let auth = match db_handle.auth.as_ref() {
|
||||
Some(auth) => auth,
|
||||
None => {
|
||||
error!("Could not find auth in database");
|
||||
return Err(StatusCode::UNAUTHORIZED);
|
||||
}
|
||||
};
|
||||
let web_token = match &auth.web_token {
|
||||
Some(token) => token,
|
||||
None => return Err(StatusCode::UNAUTHORIZED),
|
||||
};
|
||||
let remote_uri = base_url.as_str().parse::<Uri>().expect("Failed to parse base url");
|
||||
let remote_uri = db_handle
|
||||
.base_url
|
||||
.parse::<Uri>()
|
||||
.expect("Failed to parse base url");
|
||||
|
||||
let path = request.uri().path();
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use std::sync::nonpoison::Mutex;
|
||||
|
||||
use client::app_state::AppState;
|
||||
use database::{borrow_db_checked, borrow_db_mut_checked};
|
||||
use download_manager::DOWNLOAD_MANAGER;
|
||||
use log::{debug, error};
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_autostart::ManagerExt;
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch_state(state: tauri::State<'_, Mutex<AppState>>) -> Result<String, String> {
|
||||
@ -72,10 +72,3 @@ pub fn get_autostart_enabled(app: AppHandle) -> Result<bool, tauri_plugin_autost
|
||||
|
||||
Ok(db_state)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn open_fs(path: String, app_handle: AppHandle) -> Result<(), tauri_plugin_opener::Error> {
|
||||
app_handle
|
||||
.opener()
|
||||
.open_path(path, None::<&str>)
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
use std::sync::nonpoison::Mutex;
|
||||
|
||||
use database::{GameDownloadStatus, GameVersion, borrow_db_checked, borrow_db_mut_checked, models::Game};
|
||||
use database::{GameDownloadStatus, GameVersion, borrow_db_checked, borrow_db_mut_checked};
|
||||
use games::{
|
||||
downloads::error::LibraryError,
|
||||
library::{FetchGameStruct, FrontendGameOptions, get_current_meta, uninstall_game_logic},
|
||||
library::{FetchGameStruct, FrontendGameOptions, Game, get_current_meta, uninstall_game_logic},
|
||||
state::{GameStatusManager, GameStatusWithTransient},
|
||||
};
|
||||
use log::warn;
|
||||
@ -18,7 +18,7 @@ use remote::{
|
||||
};
|
||||
use tauri::AppHandle;
|
||||
|
||||
use client::app_state::AppState;
|
||||
use crate::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn fetch_library(
|
||||
@ -38,13 +38,75 @@ pub async fn fetch_library(
|
||||
pub async fn fetch_library_logic(
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
hard_fresh: Option<bool>,
|
||||
) -> (Vec<Game>, Vec<LibraryError>) {
|
||||
) -> Result<Vec<Game>, RemoteAccessError> {
|
||||
let do_hard_refresh = hard_fresh.unwrap_or(false);
|
||||
if !do_hard_refresh && let Ok(library) = get_cached_object("library") {
|
||||
return Ok(library);
|
||||
}
|
||||
|
||||
let client = DROP_CLIENT_ASYNC.clone();
|
||||
let response = generate_url(&["/api/v1/client/user/library"], &[])?;
|
||||
let response = client
|
||||
.get(response)
|
||||
.header("Authorization", generate_authorization_header())
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if response.status() != 200 {
|
||||
let err = response.json().await.unwrap_or(DropServerError {
|
||||
status_code: 500,
|
||||
status_message: "Invalid response from server.".to_owned(),
|
||||
});
|
||||
warn!("{err:?}");
|
||||
return Err(RemoteAccessError::InvalidResponse(err));
|
||||
}
|
||||
|
||||
let mut games: Vec<Game> = response.json().await?;
|
||||
|
||||
let mut handle = state.lock();
|
||||
|
||||
let mut db_handle = borrow_db_mut_checked();
|
||||
|
||||
for game in &games {
|
||||
handle.games.insert(game.id().clone(), game.clone());
|
||||
if !db_handle.applications.game_statuses.contains_key(game.id()) {
|
||||
db_handle
|
||||
.applications
|
||||
.game_statuses
|
||||
.insert(game.id().clone(), GameDownloadStatus::Remote {});
|
||||
}
|
||||
}
|
||||
|
||||
// Add games that are installed but no longer in library
|
||||
for meta in db_handle.applications.installed_game_version.values() {
|
||||
if games.iter().any(|e| *e.id() == meta.id) {
|
||||
continue;
|
||||
}
|
||||
// We should always have a cache of the object
|
||||
// Pass db_handle because otherwise we get a gridlock
|
||||
let game = match get_cached_object_db::<Game>(&meta.id.clone(), &db_handle) {
|
||||
Ok(game) => game,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
"{} is installed, but encountered error fetching its error: {}.",
|
||||
meta.id, err
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
games.push(game);
|
||||
}
|
||||
|
||||
drop(handle);
|
||||
drop(db_handle);
|
||||
cache_object("library", &games)?;
|
||||
|
||||
Ok(games)
|
||||
}
|
||||
pub async fn fetch_library_logic_offline(
|
||||
_state: tauri::State<'_, Mutex<AppState>>,
|
||||
_hard_refresh: Option<bool>,
|
||||
) -> (Vec<Game>, Vec<LibraryError>) {
|
||||
) -> Result<Vec<Game>, RemoteAccessError> {
|
||||
let mut games: Vec<Game> = get_cached_object("library")?;
|
||||
|
||||
let db_handle = borrow_db_checked();
|
||||
@ -82,7 +144,7 @@ pub async fn fetch_game_logic(
|
||||
.cloned(),
|
||||
};
|
||||
|
||||
let game = state_handle.games().get(&id);
|
||||
let game = state_handle.games.get(&id);
|
||||
if let Some(game) = game {
|
||||
let status = GameStatusManager::fetch_state(&id, &db_lock);
|
||||
|
||||
@ -121,7 +183,7 @@ pub async fn fetch_game_logic(
|
||||
let game: Game = response.json().await?;
|
||||
|
||||
let mut state_handle = state.lock();
|
||||
state_handle.games_mut().insert(id.clone(), game.clone());
|
||||
state_handle.games.insert(id.clone(), game.clone());
|
||||
|
||||
let mut db_handle = borrow_db_mut_checked();
|
||||
|
||||
|
||||
@ -12,11 +12,9 @@ use std::{
|
||||
sync::nonpoison::Mutex, time::SystemTime,
|
||||
};
|
||||
|
||||
use ::client::{
|
||||
app_state::AppState, app_status::AppStatus, autostart::sync_autostart_on_startup,
|
||||
};
|
||||
use ::client::{app_status::AppStatus, autostart::sync_autostart_on_startup, user::User};
|
||||
use ::download_manager::DownloadManagerWrapper;
|
||||
use ::games::scan::scan_install_dirs;
|
||||
use ::games::{library::Game, scan::scan_install_dirs};
|
||||
use ::process::ProcessManagerWrapper;
|
||||
use ::remote::{
|
||||
auth::{self, HandshakeRequestBody, HandshakeResponse, generate_authorization_header},
|
||||
@ -38,6 +36,7 @@ use log4rs::{
|
||||
config::{Appender, Root},
|
||||
encode::pattern::PatternEncoder,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use tauri::{
|
||||
AppHandle, Manager, RunEvent, WindowEvent,
|
||||
menu::{Menu, MenuItem, PredefinedMenuItem},
|
||||
@ -68,6 +67,14 @@ use process::*;
|
||||
use remote::*;
|
||||
use settings::*;
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppState {
|
||||
status: AppStatus,
|
||||
user: Option<User>,
|
||||
games: HashMap<String, Game>,
|
||||
}
|
||||
|
||||
async fn setup(handle: AppHandle) -> AppState {
|
||||
let logfile = FileAppender::builder()
|
||||
.encoder(Box::new(PatternEncoder::new(
|
||||
@ -110,7 +117,11 @@ async fn setup(handle: AppHandle) -> AppState {
|
||||
scan_install_dirs();
|
||||
|
||||
if !is_set_up {
|
||||
return AppState::new(AppStatus::NotConfigured, None, games);
|
||||
return AppState {
|
||||
status: AppStatus::NotConfigured,
|
||||
user: None,
|
||||
games,
|
||||
};
|
||||
}
|
||||
|
||||
debug!("database is set up");
|
||||
@ -168,7 +179,11 @@ async fn setup(handle: AppHandle) -> AppState {
|
||||
warn!("failed to sync autostart state: {e}");
|
||||
}
|
||||
|
||||
AppState::new(app_status, user, games)
|
||||
AppState {
|
||||
status: app_status,
|
||||
user,
|
||||
games,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn custom_panic_handler(e: &PanicHookInfo) -> Option<()> {
|
||||
@ -214,7 +229,6 @@ pub fn run() {
|
||||
fetch_state,
|
||||
quit,
|
||||
fetch_system_data,
|
||||
open_fs,
|
||||
// User utils
|
||||
update_settings,
|
||||
fetch_settings,
|
||||
@ -284,7 +298,7 @@ pub fn run() {
|
||||
let _main_window = tauri::WebviewWindowBuilder::new(
|
||||
&handle,
|
||||
"main", // BTW this is not the name of the window, just the label. Keep this 'main', there are permissions & configs that depend on it
|
||||
tauri::WebviewUrl::App("main".into()),
|
||||
tauri::WebviewUrl::App("tvmode".into()),
|
||||
)
|
||||
.title("Drop Desktop App")
|
||||
.min_inner_size(1000.0, 500.0)
|
||||
@ -458,12 +472,14 @@ pub async fn recieve_handshake(app: AppHandle, path: String) {
|
||||
|
||||
let mut state_lock = app_state.lock();
|
||||
|
||||
*state_lock.status_mut() = app_status;
|
||||
*state_lock.user_mut() = user;
|
||||
state_lock.status = app_status;
|
||||
state_lock.user = user;
|
||||
|
||||
let _ = clear_cached_object("collections");
|
||||
let _ = clear_cached_object("library");
|
||||
|
||||
drop(state_lock);
|
||||
|
||||
app_emit!(&app, "auth/finished", ());
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
use std::sync::nonpoison::Mutex;
|
||||
|
||||
use process::{PROCESS_MANAGER, error::ProcessError};
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn launch_game(
|
||||
id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<(), ProcessError> {
|
||||
let state_lock = state.lock();
|
||||
let mut process_manager_lock = PROCESS_MANAGER.lock();
|
||||
//let meta = DownloadableMetadata {
|
||||
// id,
|
||||
@ -18,6 +24,9 @@ pub fn launch_game(
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
|
||||
drop(process_manager_lock);
|
||||
drop(state_lock);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::{sync::nonpoison::Mutex, time::Duration};
|
||||
|
||||
use client::{app_state::AppState, app_status::AppStatus};
|
||||
use client::app_status::AppStatus;
|
||||
use database::{borrow_db_checked, borrow_db_mut_checked};
|
||||
use futures_lite::StreamExt;
|
||||
use log::{debug, warn};
|
||||
@ -18,7 +18,7 @@ use tauri::{AppHandle, Manager};
|
||||
use url::Url;
|
||||
use utils::{app_emit, webbrowser_open::webbrowser_open};
|
||||
|
||||
use crate::{recieve_handshake};
|
||||
use crate::{AppState, recieve_handshake};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn use_remote(
|
||||
@ -45,7 +45,7 @@ pub async fn use_remote(
|
||||
}
|
||||
|
||||
let mut app_state = state.lock();
|
||||
*app_state.status_mut() = AppStatus::SignedOut;
|
||||
app_state.status = AppStatus::SignedOut;
|
||||
drop(app_state);
|
||||
|
||||
let mut db_state = borrow_db_mut_checked();
|
||||
@ -100,8 +100,8 @@ pub fn sign_out(app: AppHandle) {
|
||||
{
|
||||
let state = app.state::<Mutex<AppState>>();
|
||||
let mut app_state_handle = state.lock();
|
||||
*app_state_handle.status_mut() = AppStatus::SignedOut;
|
||||
*app_state_handle.user_mut() = None;
|
||||
app_state_handle.status = AppStatus::SignedOut;
|
||||
app_state_handle.user = None;
|
||||
}
|
||||
|
||||
// Emit event for frontend
|
||||
@ -112,9 +112,10 @@ pub fn sign_out(app: AppHandle) {
|
||||
pub async fn retry_connect(state: tauri::State<'_, Mutex<AppState>>) -> Result<(), ()> {
|
||||
let (app_status, user) = setup().await;
|
||||
|
||||
let mut state_lock = state.lock();
|
||||
*state_lock.status_mut() = app_status;
|
||||
*state_lock.user_mut() = user;
|
||||
let mut guard = state.lock();
|
||||
guard.status = app_status;
|
||||
guard.user = user;
|
||||
drop(guard);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"version": "0.3.3",
|
||||
"identifier": "dev.drop.client",
|
||||
"build": {
|
||||
"beforeDevCommand": "yarn --cwd main dev --port 1432",
|
||||
"beforeDevCommand": "yarn --cwd tvmode dev --port 1432",
|
||||
"devUrl": "http://localhost:1432/",
|
||||
"beforeBuildCommand": "yarn build",
|
||||
"frontendDist": "../.output"
|
||||
|
||||
24
tvmode/.gitignore
vendored
Normal file
24
tvmode/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Nuxt dev/build outputs
|
||||
.output
|
||||
.data
|
||||
.nuxt
|
||||
.nitro
|
||||
.cache
|
||||
dist
|
||||
|
||||
# Node dependencies
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
75
tvmode/README.md
Normal file
75
tvmode/README.md
Normal file
@ -0,0 +1,75 @@
|
||||
# Nuxt Minimal Starter
|
||||
|
||||
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
|
||||
|
||||
## Setup
|
||||
|
||||
Make sure to install dependencies:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install
|
||||
|
||||
# pnpm
|
||||
pnpm install
|
||||
|
||||
# yarn
|
||||
yarn install
|
||||
|
||||
# bun
|
||||
bun install
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
Start the development server on `http://localhost:3000`:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run dev
|
||||
|
||||
# pnpm
|
||||
pnpm dev
|
||||
|
||||
# yarn
|
||||
yarn dev
|
||||
|
||||
# bun
|
||||
bun run dev
|
||||
```
|
||||
|
||||
## Production
|
||||
|
||||
Build the application for production:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run build
|
||||
|
||||
# pnpm
|
||||
pnpm build
|
||||
|
||||
# yarn
|
||||
yarn build
|
||||
|
||||
# bun
|
||||
bun run build
|
||||
```
|
||||
|
||||
Locally preview production build:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run preview
|
||||
|
||||
# pnpm
|
||||
pnpm preview
|
||||
|
||||
# yarn
|
||||
yarn preview
|
||||
|
||||
# bun
|
||||
bun run preview
|
||||
```
|
||||
|
||||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
||||
40
tvmode/app.vue
Normal file
40
tvmode/app.vue
Normal file
@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<NuxtLoadingIndicator color="#2563eb" />
|
||||
<NuxtLayout class="select-none">
|
||||
<NuxtPage />
|
||||
<ModalStack />
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const state = useAppState();
|
||||
|
||||
async function fetchState() {
|
||||
try {
|
||||
state.value = JSON.parse(await invoke("fetch_state"));
|
||||
if (!state.value)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: `App state is: ${state.value}`,
|
||||
fatal: true,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("failed to parse state", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
await fetchState();
|
||||
|
||||
// This is inefficient but apparently we do it lol
|
||||
router.beforeEach(async () => {
|
||||
await fetchState();
|
||||
});
|
||||
|
||||
setupHooks();
|
||||
initialNavigation(state);
|
||||
const navigator = createTVNavigator();
|
||||
</script>
|
||||
84
tvmode/assets/main.scss
Normal file
84
tvmode/assets/main.scss
Normal file
@ -0,0 +1,84 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
html,
|
||||
body {
|
||||
-ms-overflow-style: none; /* IE and Edge /
|
||||
scrollbar-width: none; / Firefox */
|
||||
}
|
||||
|
||||
/* Hide scrollbar for Chrome, Safari and Opera */
|
||||
html::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
$motiva: (
|
||||
("MotivaSansThin.ttf", "ttf", 100, normal),
|
||||
("MotivaSansLight.woff.ttf", "woff", 300, normal),
|
||||
("MotivaSansRegular.woff.ttf", "woff", 400, normal),
|
||||
("MotivaSansMedium.woff.ttf", "woff", 500, normal),
|
||||
("MotivaSansBold.woff.ttf", "woff", 600, normal),
|
||||
("MotivaSansExtraBold.ttf", "woff", 700, normal),
|
||||
("MotivaSansBlack.woff.ttf", "woff", 900, normal)
|
||||
);
|
||||
|
||||
$helvetica: (
|
||||
("Helvetica.woff", "woff", 400, normal),
|
||||
("Helvetica-Oblique.woff", "woff", 400, italic),
|
||||
("Helvetica-Bold.woff", "woff", 600, normal),
|
||||
("Helvetica-BoldOblique.woff", "woff", 600, italic),
|
||||
("helvetica-light-587ebe5a59211.woff2", "woff2", 300, normal)
|
||||
);
|
||||
|
||||
@each $file, $format, $weight, $style in $motiva {
|
||||
@font-face {
|
||||
font-family: "Motiva Sans";
|
||||
src: url("/fonts/motiva/#{$file}") format($format);
|
||||
font-weight: $weight;
|
||||
font-style: $style;
|
||||
}
|
||||
}
|
||||
|
||||
@each $file, $format, $weight, $style in $helvetica {
|
||||
@font-face {
|
||||
font-family: "Helvetica";
|
||||
src: url("/fonts/helvetica/#{$file}") format($format);
|
||||
font-weight: $weight;
|
||||
font-style: $style;
|
||||
}
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("/fonts/inter/InterVariable.ttf");
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("/fonts/inter/InterVariable-Italic.ttf");
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* ===== Scrollbar CSS ===== */
|
||||
/* Firefox */
|
||||
* {
|
||||
scrollbar-width: 4px;
|
||||
scrollbar-color: #52525b #00000000;
|
||||
}
|
||||
|
||||
/* Chrome, Edge, and Safari */
|
||||
*::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background-color: #52525b;
|
||||
border-radius: 10px;
|
||||
border: 3px solid #52525b;
|
||||
}
|
||||
BIN
tvmode/assets/wallpaper.jpg
Normal file
BIN
tvmode/assets/wallpaper.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 MiB |
72
tvmode/components/Sidebar.vue
Normal file
72
tvmode/components/Sidebar.vue
Normal file
@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div class="bg-zinc-950 flex flex-col items-center pl-5 px-10 py-8">
|
||||
<div class="flex flex-col items-center gap-y-10">
|
||||
<Wordmark class="h-8 mb-0.5" />
|
||||
<ol class="flex flex-col gap-y-2">
|
||||
<NuxtLink
|
||||
v-for="(nav, navIdx) in navigation"
|
||||
:class="[
|
||||
'transition rounded focus:ring-2 ring-blue-600 px-2 uppercase font-display font-semibold text-xl',
|
||||
navIdx === currentNavigation
|
||||
? 'text-zinc-100'
|
||||
: 'text-zinc-400 hover:text-zinc-200',
|
||||
]"
|
||||
:href="nav.route"
|
||||
:tvnavDebug="`nav-link-${nav.label}`"
|
||||
>
|
||||
{{ nav.label }}
|
||||
</NuxtLink>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { BellIcon, UserGroupIcon } from "@heroicons/vue/16/solid";
|
||||
import { AppStatus, type NavigationItem, type QuickActionNav } from "../types";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
|
||||
const window = getCurrentWindow();
|
||||
const state = useAppState();
|
||||
|
||||
const navigation: Array<NavigationItem> = [
|
||||
{
|
||||
prefix: "/store",
|
||||
route: "/store",
|
||||
label: "Store",
|
||||
},
|
||||
{
|
||||
prefix: "/library",
|
||||
route: "/library",
|
||||
label: "Library",
|
||||
},
|
||||
/*
|
||||
{
|
||||
prefix: "/community",
|
||||
route: "/community",
|
||||
label: "Community",
|
||||
},
|
||||
{
|
||||
prefix: "/news",
|
||||
route: "/news",
|
||||
label: "News",
|
||||
},
|
||||
*/
|
||||
];
|
||||
|
||||
const { currentNavigation } = useCurrentNavigationIndex(navigation);
|
||||
|
||||
const quickActions: Array<QuickActionNav> = [
|
||||
{
|
||||
icon: UserGroupIcon,
|
||||
action: async () => {},
|
||||
},
|
||||
{
|
||||
icon: BellIcon,
|
||||
action: async () => {},
|
||||
},
|
||||
];
|
||||
|
||||
const queue = useQueueState();
|
||||
const currentQueueObject = computed(() => queue.value.queue.at(0));
|
||||
</script>
|
||||
254
tvmode/composables/tvmode.ts
Normal file
254
tvmode/composables/tvmode.ts
Normal file
@ -0,0 +1,254 @@
|
||||
const NAVIGATE_MODIFIED_PROP = "tvnav-id";
|
||||
const NAVIGATE_INTERACT_ID = "tvnav-iid";
|
||||
const NAVIGATE_DEBUG_TAG = "tvnavdebug";
|
||||
|
||||
const Directions = ["left", "right", "up", "down"] as const;
|
||||
type Direction = (typeof Directions)[number];
|
||||
|
||||
interface NavigationJump {
|
||||
distance: number;
|
||||
id: string;
|
||||
}
|
||||
|
||||
type Position = [number, number, number, number, string];
|
||||
|
||||
class TVModeNavigator {
|
||||
private navigationNodes: Map<string, HTMLElement> = new Map();
|
||||
|
||||
constructor() {
|
||||
const thisRef = this;
|
||||
const observer = new MutationObserver((v, k) => {
|
||||
this.onMutation(thisRef, v, k);
|
||||
});
|
||||
observer.observe(document.getRootNode(), {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", (ev) => {
|
||||
switch (ev.code) {
|
||||
case "KeyW":
|
||||
return this.moveUp();
|
||||
case "KeyS":
|
||||
return this.moveDown();
|
||||
case "KeyD":
|
||||
return this.moveRight();
|
||||
case "KeyA":
|
||||
return this.moveLeft();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getCurrentPosition(element?: HTMLElement): Position {
|
||||
const el = element || document.activeElement;
|
||||
if (!el) throw "No active position";
|
||||
const rect = el.getBoundingClientRect();
|
||||
const debugName = el.getAttribute(NAVIGATE_DEBUG_TAG);
|
||||
return [rect.left, rect.right, rect.top, rect.bottom, debugName ?? ""];
|
||||
}
|
||||
|
||||
private isSamePosition(a: Position, b: Position) {
|
||||
return a.map((v, i) => v === b[i]).every((v) => v);
|
||||
}
|
||||
|
||||
private getUniqueNavNodes() {
|
||||
const hasSeen = new Map<string, boolean>();
|
||||
return this.navigationNodes.values().filter((v) => {
|
||||
const id = this.getInteractionId(v);
|
||||
if (hasSeen.get(id)) return false;
|
||||
hasSeen.set(id, true);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
let left = current[0] - target[1]; // Our left edge vs their right left (they're to our left)
|
||||
if (left < 0) {
|
||||
left = target[0] - current[1];
|
||||
console.log("to the right");
|
||||
} // If we're less, it's our right edge vs their left edge
|
||||
|
||||
let top = current[2] - target[3]; // Our top edge vs their bottom edge
|
||||
if (top < 0) {
|
||||
top = target[2] - current[3];
|
||||
console.log("undernearth");
|
||||
} // Our bottom edge vs their top edge
|
||||
console.log(top);
|
||||
*/
|
||||
|
||||
private getCenter(position: Position) {
|
||||
return [
|
||||
position[0] + 0.5 * (position[1] - position[0]),
|
||||
position[2] + 0.5 * (position[3] - position[2]),
|
||||
];
|
||||
}
|
||||
|
||||
private findOuterDistance(
|
||||
current: Position,
|
||||
target: Position,
|
||||
bias: Direction
|
||||
) {
|
||||
const centerCurrent = this.getCenter(current);
|
||||
const centerTarget = this.getCenter(target);
|
||||
|
||||
return Math.sqrt(
|
||||
Math.pow(
|
||||
centerCurrent[0] - centerTarget[0],
|
||||
["left", "right"].includes(bias) ? 2 : 4
|
||||
) +
|
||||
Math.pow(
|
||||
centerCurrent[1] - centerTarget[1],
|
||||
["up", "down"].includes(bias) ? 2 : 4
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private findElementWithPredicate(
|
||||
check: (current: Position, target: Position) => boolean,
|
||||
direction: Direction
|
||||
) {
|
||||
const current = this.getCurrentPosition();
|
||||
// We want things in the x direction, with a limit on the y
|
||||
let distance = Infinity;
|
||||
let element = null;
|
||||
const nodes = this.getUniqueNavNodes();
|
||||
for (const newElement of nodes) {
|
||||
const target = this.getCurrentPosition(newElement);
|
||||
if (this.isSamePosition(current, target)) continue;
|
||||
if (target.every((v) => v == 0)) continue; // This element doesn't exist
|
||||
const newDistance = this.findOuterDistance(current, target, direction);
|
||||
console.log(
|
||||
`distance of ${newDistance} between ${current[4]} and ${target[4]}`
|
||||
);
|
||||
// If we're the wrong way, or further than the current option
|
||||
if (newDistance < 0 || newDistance > distance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!check(current, target)) {
|
||||
continue;
|
||||
}
|
||||
distance = newDistance;
|
||||
element = newElement;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
moveUp() {
|
||||
const leeway = 100; // 20px
|
||||
const element = this.findElementWithPredicate(
|
||||
([xleft, xright, ytop, ybottom], [eleft, eright, etop, ebottom]) =>
|
||||
xleft - leeway < eright && xright + leeway > eleft && ytop >= ebottom,
|
||||
"up"
|
||||
);
|
||||
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
moveDown() {
|
||||
const leeway = 20; // 20px
|
||||
const element = this.findElementWithPredicate(
|
||||
([xleft, xright, ytop, ybottom], [eleft, eright, etop, ebottom]) =>
|
||||
xleft - leeway < eright && xright + leeway > eleft && ytop <= ebottom,
|
||||
"down"
|
||||
);
|
||||
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
moveRight() {
|
||||
const leeway = 0; // 20px
|
||||
const element = this.findElementWithPredicate(
|
||||
([xleft, xright, ytop, ybottom], [eleft, eright, etop, ebottom]) =>
|
||||
ytop - leeway < ebottom && ybottom + leeway > etop && xright <= eleft,
|
||||
"right"
|
||||
);
|
||||
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
moveLeft() {
|
||||
const leeway = 20; // 20px
|
||||
const element = this.findElementWithPredicate(
|
||||
([xleft, xright, ytop, ybottom], [eleft, eright, etop, ebottom]) =>
|
||||
ytop - leeway < ebottom && ybottom + leeway > etop && xleft >= eright,
|
||||
"left"
|
||||
);
|
||||
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
recursivelyFindInteractable(element: Element): Array<HTMLElement> {
|
||||
const elements = [];
|
||||
for (const child of element.children) {
|
||||
if (!child) continue;
|
||||
if (child instanceof HTMLAnchorElement) {
|
||||
elements.push(child);
|
||||
continue;
|
||||
}
|
||||
if (child instanceof HTMLButtonElement) {
|
||||
elements.push(child);
|
||||
continue;
|
||||
}
|
||||
if (child instanceof HTMLInputElement) {
|
||||
elements.push(child);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Save ourselves a function call
|
||||
if (child.children.length > 0) {
|
||||
elements.push(...this.recursivelyFindInteractable(child));
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
getInteractionId(element: Element) {
|
||||
const id = element.getAttribute(NAVIGATE_INTERACT_ID);
|
||||
if (id) return id;
|
||||
const newId = crypto.randomUUID();
|
||||
element.setAttribute(NAVIGATE_INTERACT_ID, newId);
|
||||
return newId;
|
||||
}
|
||||
|
||||
onMutation(
|
||||
self: TVModeNavigator,
|
||||
mutationlist: Array<MutationRecord>,
|
||||
observer: unknown
|
||||
) {
|
||||
for (const mutation of mutationlist) {
|
||||
for (const node of mutation.addedNodes) {
|
||||
if (!node) continue;
|
||||
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
||||
const el = node as Element;
|
||||
|
||||
const interactiveNodes = self.recursivelyFindInteractable(el);
|
||||
|
||||
for (const v of interactiveNodes) {
|
||||
const id = self.getInteractionId(v);
|
||||
self.navigationNodes.set(id, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const interactiveElements = this.navigationNodes.values().toArray().flat();
|
||||
|
||||
// Set focus so we aren't confused
|
||||
if (!document.activeElement || document.activeElement.tagName === "BODY") {
|
||||
const active = interactiveElements.at(0);
|
||||
if (active) {
|
||||
active.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const createTVNavigator = () => new TVModeNavigator();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user