diff --git a/.editorconfig b/.editorconfig index c535b9b..074adff 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,4 +8,4 @@ root = true end_of_line = lf insert_final_newline = true indent_style = space -indent_size = 4 \ No newline at end of file +indent_size = 2 \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..109b9a0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "never", + "source.organizeImports": true + }, + "html.format.contentUnformatted": "pre,code,textarea,svg", +} \ No newline at end of file diff --git a/desktop/src/App.tsx b/desktop/src/App.tsx index a86154d..8541d20 100644 --- a/desktop/src/App.tsx +++ b/desktop/src/App.tsx @@ -1,19 +1,17 @@ import { invoke } from "@tauri-apps/api/tauri"; import { useLocalStorage } from "@uidotdev/usehooks"; import { useEffect, useRef } from "react"; -import { v4 as uuidv4 } from 'uuid'; +import { v4 as uuidv4 } from "uuid"; import successSvg from "./assets/success.svg"; import { BASE_URL } from "./config"; import { createQR } from "./qr"; import { Action, usePeer } from "./usePeer"; - function App() { - const [id, ] = useLocalStorage('id', uuidv4()) - console.log('localstorage id => ', id) - const {message, status} = usePeer(id, true) + const [id] = useLocalStorage("id", uuidv4()); + console.log("localstorage id => ", id); + const { message, status } = usePeer(id, true); const qrDiv = useRef(null); - async function renderQR() { const url = `${BASE_URL}?id=${id}`; @@ -21,7 +19,7 @@ function App() { qrDiv.current.innerHTML = ""; } const newQR = createQR(url); - + const element = await newQR._getElement(); if (element) { qrDiv.current?.appendChild(element); @@ -29,28 +27,27 @@ function App() { } useEffect(() => { - console.log('status => ', status) - if (status === 'READY') { + console.log("status => ", status); + if (status === "READY") { console.log("creating qr"); const url = `${BASE_URL}?id=${id}`; console.log("url => ", url); - renderQR() + renderQR(); } - }, [status]) + }, [status]); useEffect(() => { if (message) { invoke("press", { key: Action[message.action].toString() }); } - }, [message]) - + }, [message]); function copyURL() { const url = `${BASE_URL}?id=${id}`; navigator.clipboard.writeText(url); } - if (status === 'CONNECTED') { + if (status === "CONNECTED") { return (
CONNECTED @@ -63,7 +60,7 @@ function App() {
Ready to connect
- {status === 'INIT' && ( + {status === "INIT" && (
@@ -79,6 +76,7 @@ function App() { width="1em" xmlns="http://www.w3.org/2000/svg" > + {" "} + >{" "} + >{" "} COPY URL diff --git a/desktop/src/config.ts b/desktop/src/config.ts index 74e1f23..7a06b96 100644 --- a/desktop/src/config.ts +++ b/desktop/src/config.ts @@ -1,12 +1,14 @@ -import {PeerOptions} from 'peerjs' +import { PeerOptions } from "peerjs"; - -export const BASE_URL = import.meta.env.MODE === 'development' ? 'http://localhost:5173/mobslide/' : 'https://thewh1teagle.github.io/mobslide/' +export const BASE_URL = + import.meta.env.MODE === "development" + ? "http://localhost:5173/mobslide/" + : "https://thewh1teagle.github.io/mobslide/"; export const PEERJS_OPTIONS: PeerOptions = { - host: 'mobslide-signaling.fly.dev', - port: 443, - path: '/', - pingInterval: 2000, - secure: true, - debug: 3 -} \ No newline at end of file + host: "mobslide-signaling.fly.dev", + port: 443, + path: "/", + pingInterval: 2000, + secure: true, + debug: 3, +}; diff --git a/desktop/src/main.tsx b/desktop/src/main.tsx index d95612f..e3d50e6 100644 --- a/desktop/src/main.tsx +++ b/desktop/src/main.tsx @@ -3,5 +3,5 @@ import App from "./App"; import "./main.css"; ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - + ); diff --git a/desktop/src/qr.ts b/desktop/src/qr.ts index e9caa8b..23abcd1 100644 --- a/desktop/src/qr.ts +++ b/desktop/src/qr.ts @@ -36,7 +36,10 @@ function getOptions(url: string) { return { ...options, data: url, - dotsOptions: { type: "extra-rounded", color: isDark ? "white" : "black" }, + dotsOptions: { + type: "extra-rounded", + color: isDark ? "white" : "black", + }, } as Options; } diff --git a/desktop/src/usePeer.ts b/desktop/src/usePeer.ts index 7a12d4f..fd03c25 100644 --- a/desktop/src/usePeer.ts +++ b/desktop/src/usePeer.ts @@ -1,5 +1,5 @@ -import { useRef, useState, useEffect } from "react"; import Peer, { DataConnection } from "peerjs"; +import { useEffect, useRef, useState } from "react"; import { PEERJS_OPTIONS } from "./config"; export enum Action { diff --git a/desktop/vite.config.ts b/desktop/vite.config.ts index e884c4b..cd2b487 100644 --- a/desktop/vite.config.ts +++ b/desktop/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; +import { defineConfig } from "vite"; // https://vitejs.dev/config/ export default defineConfig(async () => ({ diff --git a/web/src/App.tsx b/web/src/App.tsx index c3728ef..990a722 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -12,7 +12,6 @@ if (!noSleep.isEnabled) { } function App() { - const { connectWrapper, sendMessage, status } = usePeer(); useEffect(() => { @@ -26,7 +25,7 @@ function App() { } } init(); - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const nextButtonBind = useLongPress(() => { @@ -37,7 +36,7 @@ function App() { sendMessage({ action: Action.ESC }); }); - if (status !== 'CONNECTED') { + if (status !== "CONNECTED") { return (
{status} diff --git a/web/src/config.ts b/web/src/config.ts index d0b1861..4107db4 100644 --- a/web/src/config.ts +++ b/web/src/config.ts @@ -1,10 +1,10 @@ -import {PeerOptions} from 'peerjs' +import { PeerOptions } from "peerjs"; export const PEERJS_OPTIONS: PeerOptions = { - host: 'mobslide-signaling.fly.dev', - port: 443, - path: '/', - pingInterval: 2000, - secure: true, - debug: 3 -} \ No newline at end of file + host: "mobslide-signaling.fly.dev", + port: 443, + path: "/", + pingInterval: 2000, + secure: true, + debug: 3, +}; diff --git a/web/src/main.tsx b/web/src/main.tsx index b39f550..e970f08 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -1,10 +1,10 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App.tsx' -import './main.css' +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App.tsx"; +import "./main.css"; -ReactDOM.createRoot(document.getElementById('root')!).render( +ReactDOM.createRoot(document.getElementById("root")!).render( - , -) + +); diff --git a/web/src/usePeer.ts b/web/src/usePeer.ts index d498ced..4ce0eca 100644 --- a/web/src/usePeer.ts +++ b/web/src/usePeer.ts @@ -1,5 +1,5 @@ -import { useRef, useState, useEffect } from "react"; import Peer, { DataConnection } from "peerjs"; +import { useEffect, useRef, useState } from "react"; import { PEERJS_OPTIONS } from "./config"; export enum Action { diff --git a/web/vite.config.ts b/web/vite.config.ts index 849b979..9827cf9 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react-swc' +import react from "@vitejs/plugin-react-swc"; +import { defineConfig } from "vite"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], - base: '/mobslide/' -}) + base: "/mobslide/", +});