mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
Compare commits
4 Commits
e29d5c8ead
...
113-bug-li
| Author | SHA1 | Date | |
|---|---|---|---|
| fe456cc2ef | |||
| 42ff3b1331 | |||
| db485b946b | |||
| 346ee1dddc |
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<NuxtLoadingIndicator color="#2563eb" />
|
<NuxtLoadingIndicator color="#2563eb" />
|
||||||
<NuxtLayout ref="rootNode" class="select-none w-screen h-screen">
|
<NuxtLayout class="select-none w-screen h-screen">
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
<ModalStack />
|
<ModalStack />
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
@ -15,7 +15,6 @@ import {
|
|||||||
initialNavigation,
|
initialNavigation,
|
||||||
setupHooks,
|
setupHooks,
|
||||||
} from "./composables/state-navigation.js";
|
} from "./composables/state-navigation.js";
|
||||||
import { createTVNavigator } from "./composables/tvmode.js";
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@ -42,11 +41,6 @@ router.beforeEach(async () => {
|
|||||||
await fetchState();
|
await fetchState();
|
||||||
});
|
});
|
||||||
|
|
||||||
const rootNode = ref<HTMLElement>();
|
|
||||||
onMounted(() => {
|
|
||||||
const navigator = createTVNavigator(rootNode);
|
|
||||||
});
|
|
||||||
|
|
||||||
setupHooks();
|
setupHooks();
|
||||||
initialNavigation(state);
|
initialNavigation(state);
|
||||||
|
|
||||||
|
|||||||
@ -1,176 +0,0 @@
|
|||||||
const NAVIGATE_MODIFIED_PROP = "tvnav-id";
|
|
||||||
const NAVIGATE_INTERACT_ID = "tvnav-iid";
|
|
||||||
|
|
||||||
const Directions = ["left", "right", "up", "down"] as const;
|
|
||||||
type Direction = (typeof Directions)[number];
|
|
||||||
|
|
||||||
const NAVIGATE_LEFT_ID = "tvnav-left";
|
|
||||||
const NAVIGATE_RIGHT_ID = "tvnav-right";
|
|
||||||
const NAVIGATE_UP_ID = "tvnav-up";
|
|
||||||
const NAVIGATE_DOWN_ID = "tvnav-down";
|
|
||||||
|
|
||||||
interface NavigationJump {
|
|
||||||
distance: number;
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
class TVModeNavigator {
|
|
||||||
private rootNode: Ref<HTMLElement | undefined>;
|
|
||||||
private navigationNodes: Map<string, Array<Element>> = new Map();
|
|
||||||
|
|
||||||
constructor(rootNode: Ref<HTMLElement | undefined>) {
|
|
||||||
this.rootNode = rootNode;
|
|
||||||
|
|
||||||
const thisRef = this;
|
|
||||||
const observer = new MutationObserver((v, k) => {
|
|
||||||
this.onMutation(thisRef, v, k);
|
|
||||||
});
|
|
||||||
observer.observe(document.getRootNode(), {
|
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
recursivelyFindInteractable(element: Element): Array<Element> {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getNavJumpKey(direction: Direction) {
|
|
||||||
switch (direction) {
|
|
||||||
case "down":
|
|
||||||
return NAVIGATE_DOWN_ID;
|
|
||||||
case "left":
|
|
||||||
return NAVIGATE_LEFT_ID;
|
|
||||||
case "right":
|
|
||||||
return NAVIGATE_RIGHT_ID;
|
|
||||||
case "up":
|
|
||||||
return NAVIGATE_UP_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw "Invalid direction";
|
|
||||||
}
|
|
||||||
|
|
||||||
getNavJump(
|
|
||||||
element: Element,
|
|
||||||
direction: Direction
|
|
||||||
): NavigationJump | undefined {
|
|
||||||
const key = this.getNavJumpKey(direction);
|
|
||||||
const value = element.getAttribute(key);
|
|
||||||
if (!value) return undefined;
|
|
||||||
const [id, distance] = value.split("/");
|
|
||||||
return {
|
|
||||||
distance: parseFloat(distance),
|
|
||||||
id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
onMutation(
|
|
||||||
self: TVModeNavigator,
|
|
||||||
mutationlist: Array<MutationRecord>,
|
|
||||||
observer: unknown
|
|
||||||
) {
|
|
||||||
for (const mutation of mutationlist) {
|
|
||||||
for (const node of mutation.removedNodes) {
|
|
||||||
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
||||||
const el = node as Element;
|
|
||||||
const id = el.getAttribute(NAVIGATE_MODIFIED_PROP);
|
|
||||||
if (id) {
|
|
||||||
self.navigationNodes.delete(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const node of mutation.addedNodes) {
|
|
||||||
if (!node) continue;
|
|
||||||
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
||||||
const el = node as Element;
|
|
||||||
|
|
||||||
const existingId = el.getAttribute(NAVIGATE_MODIFIED_PROP);
|
|
||||||
if (existingId) {
|
|
||||||
self.navigationNodes.delete(existingId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const interactiveNodes = self.recursivelyFindInteractable(el);
|
|
||||||
|
|
||||||
const id = crypto.randomUUID();
|
|
||||||
el.setAttribute(NAVIGATE_MODIFIED_PROP, id);
|
|
||||||
|
|
||||||
self.navigationNodes.set(id, interactiveNodes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const interactiveElements = this.navigationNodes.values().toArray().flat();
|
|
||||||
for (const element of interactiveElements) {
|
|
||||||
const currentId = self.getInteractionId(element);
|
|
||||||
const directionJumps: Map<Direction, NavigationJump> = new Map();
|
|
||||||
for (const direction of Directions) {
|
|
||||||
const jump = self.getNavJump(element, direction);
|
|
||||||
if (jump) {
|
|
||||||
directionJumps.set(direction, jump);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowerX = element.clientLeft;
|
|
||||||
const upperX = element.clientLeft + element.clientWidth;
|
|
||||||
const lowerY = element.clientTop;
|
|
||||||
const upperY = element.clientTop + element.clientHeight;
|
|
||||||
|
|
||||||
for (const otherElement of interactiveElements) {
|
|
||||||
const otherId = self.getInteractionId(otherElement);
|
|
||||||
if (otherId == currentId) continue; // Skip us
|
|
||||||
|
|
||||||
const otherLowerX = otherElement.clientLeft;
|
|
||||||
const otherUpperX = otherElement.clientLeft + otherElement.clientWidth;
|
|
||||||
const otherLowerY = otherElement.clientTop;
|
|
||||||
const otherUpperY = otherElement.clientTop + otherElement.clientHeight;
|
|
||||||
|
|
||||||
for (const direction of Directions) {
|
|
||||||
let jump;
|
|
||||||
switch (direction) {
|
|
||||||
case "down":
|
|
||||||
const leeway =
|
|
||||||
0.1 * (element.clientWidth + otherElement.clientWidth);
|
|
||||||
if (
|
|
||||||
lowerX - leeway < otherUpperX ||
|
|
||||||
upperX + leeway > otherLowerX
|
|
||||||
)
|
|
||||||
break;
|
|
||||||
jump = {
|
|
||||||
id: otherId,
|
|
||||||
distance: upperY - otherUpperY,
|
|
||||||
} satisfies NavigationJump;
|
|
||||||
console.log(jump);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createTVNavigator = (rootNode: Ref<HTMLElement | undefined>) =>
|
|
||||||
new TVModeNavigator(rootNode);
|
|
||||||
@ -486,6 +486,9 @@ fn run_on_tray<T: FnOnce()>(f: T) {
|
|||||||
if match std::env::var("NO_TRAY_ICON") {
|
if match std::env::var("NO_TRAY_ICON") {
|
||||||
Ok(s) => s.to_lowercase() != "true",
|
Ok(s) => s.to_lowercase() != "true",
|
||||||
Err(_) => true,
|
Err(_) => true,
|
||||||
|
} || match option_env!("NO_TRAY_ICON") {
|
||||||
|
Some(s) => s.to_lowercase() != "true",
|
||||||
|
None => true,
|
||||||
} {
|
} {
|
||||||
(f)();
|
(f)();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::Read,
|
io::{self, Read},
|
||||||
sync::{LazyLock, Mutex},
|
sync::{LazyLock, Mutex},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
@ -22,33 +22,48 @@ struct DropHealthcheck {
|
|||||||
app_name: String,
|
app_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
static DROP_CERT_BUNDLE: LazyLock<Vec<Certificate>> = LazyLock::new(fetch_certificates);
|
static DROP_CERT_BUNDLE: LazyLock<Vec<Certificate>> = LazyLock::new(|| {
|
||||||
|
fetch_certificates().unwrap_or_else(|e| panic!("Failed to fetch certificates with error {}", e))
|
||||||
|
});
|
||||||
pub static DROP_CLIENT_SYNC: LazyLock<reqwest::blocking::Client> = LazyLock::new(get_client_sync);
|
pub static DROP_CLIENT_SYNC: LazyLock<reqwest::blocking::Client> = LazyLock::new(get_client_sync);
|
||||||
pub static DROP_CLIENT_ASYNC: LazyLock<reqwest::Client> = LazyLock::new(get_client_async);
|
pub static DROP_CLIENT_ASYNC: LazyLock<reqwest::Client> = LazyLock::new(get_client_async);
|
||||||
pub static DROP_CLIENT_WS_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(get_client_ws);
|
pub static DROP_CLIENT_WS_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(get_client_ws);
|
||||||
|
|
||||||
fn fetch_certificates() -> Vec<Certificate> {
|
fn fetch_certificates() -> Result<Vec<Certificate>, io::Error> {
|
||||||
let certificate_dir = DATA_ROOT_DIR.join("certificates");
|
let certificate_dir = DATA_ROOT_DIR.join("certificates");
|
||||||
|
|
||||||
let mut certs = Vec::new();
|
let mut certs = Vec::new();
|
||||||
match fs::read_dir(certificate_dir) {
|
match fs::read_dir(&certificate_dir) {
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
for entry in c {
|
for entry in c {
|
||||||
match entry {
|
match entry {
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
File::open(c.path()).unwrap().read_to_end(&mut buf).unwrap();
|
File::open(c.path())?.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for cert in Certificate::from_pem_bundle(&buf).unwrap() {
|
for cert in match Certificate::from_pem_bundle(&buf) {
|
||||||
|
Ok(certificates) => certificates,
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Could not parse pem bundle with error {}. Skipping", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} {
|
||||||
certs.push(cert);
|
certs.push(cert);
|
||||||
}
|
}
|
||||||
info!(
|
info!(
|
||||||
"added {} certificate(s) from {}",
|
"added {} certificate(s) from {}",
|
||||||
certs.len(),
|
certs.len(),
|
||||||
c.file_name().into_string().unwrap()
|
c.file_name().display().to_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(_) => todo!(),
|
Err(e) => {
|
||||||
|
warn!(
|
||||||
|
"Could not open directory entry {} in certificates with error {}",
|
||||||
|
certificate_dir.display(),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +71,7 @@ fn fetch_certificates() -> Vec<Certificate> {
|
|||||||
debug!("not loading certificates due to error: {e}");
|
debug!("not loading certificates due to error: {e}");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
certs
|
Ok(certs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_client_sync() -> reqwest::blocking::Client {
|
pub fn get_client_sync() -> reqwest::blocking::Client {
|
||||||
|
|||||||
@ -38,6 +38,14 @@
|
|||||||
},
|
},
|
||||||
"wix": null
|
"wix": null
|
||||||
},
|
},
|
||||||
|
"linux": {
|
||||||
|
"appimage": {
|
||||||
|
"bundleMediaFramework": false,
|
||||||
|
"files": {
|
||||||
|
"/usr/lib/libayatana-appindicator3.so.1": "/usr/lib/libayatana-appindicator3.so.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/32x32.png",
|
"icons/32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/128x128.png",
|
||||||
|
|||||||
24
tvmode/.gitignore
vendored
24
tvmode/.gitignore
vendored
@ -1,24 +0,0 @@
|
|||||||
# 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
|
|
||||||
@ -1,75 +0,0 @@
|
|||||||
# 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.
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
class TVModeNavigator {
|
|
||||||
|
|
||||||
};
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
||||||
export default defineNuxtConfig({
|
|
||||||
compatibilityDate: '2025-07-15',
|
|
||||||
devtools: { enabled: true }
|
|
||||||
})
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nuxt-app",
|
|
||||||
"type": "module",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"build": "nuxt build",
|
|
||||||
"dev": "nuxt dev",
|
|
||||||
"generate": "nuxt generate",
|
|
||||||
"preview": "nuxt preview",
|
|
||||||
"postinstall": "nuxt prepare"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"nuxt": "^4.1.2",
|
|
||||||
"vue": "^3.5.21",
|
|
||||||
"vue-router": "^4.5.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
@ -1,2 +0,0 @@
|
|||||||
User-Agent: *
|
|
||||||
Disallow:
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
// https://nuxt.com/docs/guide/concepts/typescript
|
|
||||||
"files": [],
|
|
||||||
"references": [
|
|
||||||
{
|
|
||||||
"path": "./.nuxt/tsconfig.app.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./.nuxt/tsconfig.server.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./.nuxt/tsconfig.shared.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./.nuxt/tsconfig.node.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
4839
tvmode/yarn.lock
4839
tvmode/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user